wolffd@0: function B = extend_domain_table(A, smalldom, smallsz, bigdom, bigsz) wolffd@0: % EXTEND_DOMAIN_TABLE Expand an array so it has the desired size. wolffd@0: % B = extend_domain_table(A, smalldom, smallsz, bigdom, bigsz) wolffd@0: % wolffd@0: % A is the array with domain smalldom and sizes smallsz. wolffd@0: % bigdom is the desired domain, with sizes bigsz. wolffd@0: % wolffd@0: % Example: wolffd@0: % smalldom = [1 3], smallsz = [2 4], bigdom = [1 2 3 4], bigsz = [2 1 4 5], wolffd@0: % 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: wolffd@0: if isequal(size(A), [1 1]) % a scalar wolffd@0: B = A; % * myones(bigsz); wolffd@0: return; wolffd@0: end wolffd@0: wolffd@0: map = find_equiv_posns(smalldom, bigdom); wolffd@0: sz = ones(1, length(bigdom)); wolffd@0: sz(map) = smallsz; wolffd@0: B = myreshape(A, sz); % add dimensions for the stuff not in A wolffd@0: sz = bigsz; wolffd@0: sz(map) = 1; % don't replicate along A's dimensions wolffd@0: B = myrepmat(B, sz(:)'); wolffd@0: