wolffd@0: function [reduced_pot,successful] = reduce_pot(pot,tailnodes) wolffd@0: % Executes the reduce operation defined in wolffd@0: % Stable Local Computation with Conditional Gaussian Distributions wolffd@0: % Steffen L. Lauritzen wolffd@0: % Frank Jensen wolffd@0: % September 1999 wolffd@0: % The potential pot is reduced if B contains any zero columns wolffd@0: % The test are restricted to the positions in tailnodes. wolffd@0: % Any columns successfully deleted are entered in the array successful wolffd@0: if nargin < 2 wolffd@0: tailnodes = pot.ctaildom; wolffd@0: end wolffd@0: wolffd@0: successful = []; wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: % Keep track of remaining tailnodes % wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: rem_tailnodes = pot.ctaildom; wolffd@0: for i = tailnodes wolffd@0: pos = find(i==rem_tailnodes); wolffd@0: successful_red = [pos]; wolffd@0: red_scgcpot = cell(1,pot.dsize); wolffd@0: j = 1; wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: % Test whether all components of pot.scgpotc can be reduced % wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: while ((j <= pot.dsize) & ~isempty(successful_red)) wolffd@0: [cpot,successful_red] = reduce_pot(pot.scgpotc{j},pos); wolffd@0: red_scgcpot{j} = cpot; wolffd@0: j = j + 1; wolffd@0: end wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: % If i is a reducible tailnode, then reduce the potential % wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: if ~isempty(successful_red) wolffd@0: successful = [successful i]; wolffd@0: pot.scgpotc = red_scgcpot; wolffd@0: rem_tailnodes = mysetdiff(rem_tailnodes,i); wolffd@0: end; wolffd@0: end wolffd@0: wolffd@0: pot.ctaildom = rem_tailnodes; wolffd@0: positions = find_equiv_posns(rem_tailnodes,pot.ctaildom); wolffd@0: pot.ctailsizes = pot.ctailsizes(positions); wolffd@0: pot.ctailsize = sum(pot.ctailsizes); wolffd@0: pot.domain = mysetdiff(pot.domain,successful); wolffd@0: reduced_pot = pot; wolffd@0: wolffd@0: wolffd@0: wolffd@0: wolffd@0: