forked from Edderic/BRML
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathabsorb.m
21 lines (21 loc) · 865 Bytes
/
absorb.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function [newpots,newpotb] = absorb(pota,pots,potb,varargin)
%ABSORB Update potentials in absorption message passing on a Junction Tree
% [newpots,newpotb] = absorb(pota,pots,potb,<sum/max>)
%
% Absorption: update separator potential pots and potb, after absorbing
% from potential pota. pota --> pots --> potb
% By default sum-absorption is carried out. If the optional flag is 1, sum
% absorption is performed, otherwise max-absorption is performed.
if isempty(varargin)
dosum=1;
else
dosum=varargin{1};
end
if dosum
newpots = sumpot(pota,setdiff(pota.variables,pots.variables));
else
newpots = maxpot(pota,setdiff(pota.variables,pots.variables));
end
newpots.table=newpots.table+eps; pots.table=pots.table+eps; % in case any zeros
invpots = pots; invpots.table=1./(invpots.table);
newpotb = multpots([potb newpots invpots]);