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