comparison toolboxes/FullBNT-1.0.7/KPMtools/extend_domain_table.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 B = extend_domain_table(A, smalldom, smallsz, bigdom, bigsz)
2 % EXTEND_DOMAIN_TABLE Expand an array so it has the desired size.
3 % B = extend_domain_table(A, smalldom, smallsz, bigdom, bigsz)
4 %
5 % A is the array with domain smalldom and sizes smallsz.
6 % bigdom is the desired domain, with sizes bigsz.
7 %
8 % Example:
9 % smalldom = [1 3], smallsz = [2 4], bigdom = [1 2 3 4], bigsz = [2 1 4 5],
10 % so B(i,j,k,l) = A(i,k) for i in 1:2, j in 1:1, k in 1:4, l in 1:5
11
12 if isequal(size(A), [1 1]) % a scalar
13 B = A; % * myones(bigsz);
14 return;
15 end
16
17 map = find_equiv_posns(smalldom, bigdom);
18 sz = ones(1, length(bigdom));
19 sz(map) = smallsz;
20 B = myreshape(A, sz); % add dimensions for the stuff not in A
21 sz = bigsz;
22 sz(map) = 1; % don't replicate along A's dimensions
23 B = myrepmat(B, sz(:)');
24