Mercurial > hg > camir-aes2014
comparison toolboxes/FullBNT-1.0.7/bnt/potentials/Tables/marg_tableM.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e9a9cd732c1e |
---|---|
1 function smallT = marg_tableM(bigT, bigdom, bigsz, onto, maximize) | |
2 % MARG_TABLE Marginalize a table | |
3 % smallT = marg_table(bigT, bigdom, bigsz, onto, maximize) | |
4 | |
5 % marg_tableM is the same as marg_table.m, but we are sure | |
6 % it is not marg_table.c | |
7 | |
8 if nargin < 5, maximize = 0; end | |
9 | |
10 | |
11 smallT = myreshape(bigT, bigsz); % make sure it is a multi-dim array | |
12 sum_over = mysetdiff(bigdom, onto); | |
13 ndx = find_equiv_posns(sum_over, bigdom); | |
14 if maximize | |
15 for i=1:length(ndx) | |
16 smallT = max(smallT, [], ndx(i)); | |
17 end | |
18 else | |
19 for i=1:length(ndx) | |
20 smallT = sum(smallT, ndx(i)); | |
21 end | |
22 end | |
23 | |
24 | |
25 ns = zeros(1, max(bigdom)); | |
26 %ns(bigdom) = mysize(bigT); % ignores trailing dimensions of size 1 | |
27 ns(bigdom) = bigsz; | |
28 | |
29 smallT = squeeze(smallT); % remove all dimensions of size 1 | |
30 smallT = myreshape(smallT, ns(onto)); % put back relevant dims of size 1 |