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