annotate toolboxes/FullBNT-1.0.7/KPMtools/extend_domain_table.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
rev   line source
Daniel@0 1 function B = extend_domain_table(A, smalldom, smallsz, bigdom, bigsz)
Daniel@0 2 % EXTEND_DOMAIN_TABLE Expand an array so it has the desired size.
Daniel@0 3 % B = extend_domain_table(A, smalldom, smallsz, bigdom, bigsz)
Daniel@0 4 %
Daniel@0 5 % A is the array with domain smalldom and sizes smallsz.
Daniel@0 6 % bigdom is the desired domain, with sizes bigsz.
Daniel@0 7 %
Daniel@0 8 % Example:
Daniel@0 9 % smalldom = [1 3], smallsz = [2 4], bigdom = [1 2 3 4], bigsz = [2 1 4 5],
Daniel@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
Daniel@0 11
Daniel@0 12 if isequal(size(A), [1 1]) % a scalar
Daniel@0 13 B = A; % * myones(bigsz);
Daniel@0 14 return;
Daniel@0 15 end
Daniel@0 16
Daniel@0 17 map = find_equiv_posns(smalldom, bigdom);
Daniel@0 18 sz = ones(1, length(bigdom));
Daniel@0 19 sz(map) = smallsz;
Daniel@0 20 B = myreshape(A, sz); % add dimensions for the stuff not in A
Daniel@0 21 sz = bigsz;
Daniel@0 22 sz(map) = 1; % don't replicate along A's dimensions
Daniel@0 23 B = myrepmat(B, sz(:)');
Daniel@0 24