comparison toolboxes/FullBNT-1.0.7/bnt/potentials/Tables/mult_by_table2.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 bigT = mult_by_table2(bigT, bigdom, bigsz, smallT, smalldom, smallsz)
2 % MULT_BY_TABLE
3 % bigT = mult_by_table(bigT, bigdom, bigsz, smallT, smalldom, smallsz)
4 %
5
6 %Ts = extend_domain_table(smallT, smalldom, smallsz, bigdom, bigsz);
7 %bigT(:) = bigT(:) .* Ts(:); % must have bigT(:) on LHS to preserve shape
8
9 % extend_domain_table has a lot of overhead for small tables,
10 % since it calls myreshape and myrepmat, which check for 1 dimensional case.
11 % Here, we check up front.
12
13 if length(bigdom)==1 % vector
14 bigT = bigT .* smallT; % smallT can be scalar or vector
15 else
16 if (length(bigsz) == length(smallsz)) & all(bigsz == smallsz)
17 bigT = bigT .* smallT;
18 else
19 map = find_equiv_posns(smalldom, bigdom);
20 sz = ones(1, length(bigdom));
21 sz(map) = smallsz;
22 smallT = reshape(smallT, sz); % add dimensions of size 1 for missing domain
23 % we can use reshape instead of myreshape, because we know length(sz)>1
24 sz = bigsz;
25 sz(map) = 1; % don't replicate along small domain, which is shared
26 % we can use repmat instead of myrepmat, because we know length(sz)>1
27 smallT = repmat(smallT, sz(:)');
28 bigT(:) = bigT(:) .* smallT(:);
29 end
30 end