1 % [logZ,q,qv,qf,qmap,margs] = dai_jtree(psi,varsets,opts)

2 %

3 % INPUT: psi = linear cell array containing the factors

4 % (psi{i} should be a structure with a Member field

5 % and a P field).

6 % varsets = linear cell array containing varsets for which marginals

7 % are requested.

8 % opts = string of options.

9 %

10 % OUTPUT: logZ = logarithm of the partition sum.

11 % q = linear cell array containing all calculated marginals.

12 % qv = linear cell array containing all variable marginals.

13 % qf = linear cell array containing all factor marginals.

14 % qmap = linear array containing the MAP state.

15 % margs = linear cell array containing all requested marginals.