annotate toolboxes/FullBNT-1.0.7/bnt/potentials/@scgpot/reduce_pot.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function [reduced_pot,successful] = reduce_pot(pot,tailnodes)
wolffd@0 2 % Executes the reduce operation defined in
wolffd@0 3 % Stable Local Computation with Conditional Gaussian Distributions
wolffd@0 4 % Steffen L. Lauritzen
wolffd@0 5 % Frank Jensen
wolffd@0 6 % September 1999
wolffd@0 7 % The potential pot is reduced if B contains any zero columns
wolffd@0 8 % The test are restricted to the positions in tailnodes.
wolffd@0 9 % Any columns successfully deleted are entered in the array successful
wolffd@0 10 if nargin < 2
wolffd@0 11 tailnodes = pot.ctaildom;
wolffd@0 12 end
wolffd@0 13
wolffd@0 14 successful = [];
wolffd@0 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wolffd@0 16 % Keep track of remaining tailnodes %
wolffd@0 17 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wolffd@0 18 rem_tailnodes = pot.ctaildom;
wolffd@0 19 for i = tailnodes
wolffd@0 20 pos = find(i==rem_tailnodes);
wolffd@0 21 successful_red = [pos];
wolffd@0 22 red_scgcpot = cell(1,pot.dsize);
wolffd@0 23 j = 1;
wolffd@0 24 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wolffd@0 25 % Test whether all components of pot.scgpotc can be reduced %
wolffd@0 26 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wolffd@0 27 while ((j <= pot.dsize) & ~isempty(successful_red))
wolffd@0 28 [cpot,successful_red] = reduce_pot(pot.scgpotc{j},pos);
wolffd@0 29 red_scgcpot{j} = cpot;
wolffd@0 30 j = j + 1;
wolffd@0 31 end
wolffd@0 32
wolffd@0 33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wolffd@0 34 % If i is a reducible tailnode, then reduce the potential %
wolffd@0 35 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wolffd@0 36 if ~isempty(successful_red)
wolffd@0 37 successful = [successful i];
wolffd@0 38 pot.scgpotc = red_scgcpot;
wolffd@0 39 rem_tailnodes = mysetdiff(rem_tailnodes,i);
wolffd@0 40 end;
wolffd@0 41 end
wolffd@0 42
wolffd@0 43 pot.ctaildom = rem_tailnodes;
wolffd@0 44 positions = find_equiv_posns(rem_tailnodes,pot.ctaildom);
wolffd@0 45 pot.ctailsizes = pot.ctailsizes(positions);
wolffd@0 46 pot.ctailsize = sum(pot.ctailsizes);
wolffd@0 47 pot.domain = mysetdiff(pot.domain,successful);
wolffd@0 48 reduced_pot = pot;
wolffd@0 49
wolffd@0 50
wolffd@0 51
wolffd@0 52
wolffd@0 53