tp@0: function ivmatrix = EDB1creindexmatrix(ndivvec) tp@0: % EDB1creindeixmatrix creates a matrix with index numbers. tp@0: % tp@0: % Input parameters: tp@0: % ndivvec A matrix, [1,specorder], with the maximum counter tp@0: % number for each dimension. tp@0: % tp@0: % Output parameters: tp@0: % ivmatrix A matrix, [prod(ndivvec),specorder] of all possible tp@0: % combinations of the integers tp@0: % tp@0: % ---------------------------------------------------------------------------------------------- tp@0: % This file is part of the Edge Diffraction Toolbox by Peter Svensson. tp@0: % tp@0: % The Edge Diffraction Toolbox is free software: you can redistribute it and/or modify tp@0: % it under the terms of the GNU General Public License as published by the Free Software tp@0: % Foundation, either version 3 of the License, or (at your option) any later version. tp@0: % tp@0: % The Edge Diffraction Toolbox is distributed in the hope that it will be useful, tp@0: % but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS tp@0: % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. tp@0: % tp@0: % You should have received a copy of the GNU General Public License along with the tp@0: % Edge Diffraction Toolbox. If not, see . tp@0: % ---------------------------------------------------------------------------------------------- tp@0: % Peter Svensson (svensson@iet.ntnu.no) 20050505 tp@0: % tp@0: % ivmatrix = EDB1creindexmatrix(ndivvec) tp@0: tp@0: n = length(ndivvec); tp@0: tp@0: maxval = max(ndivvec); tp@0: if maxval > 2^32 tp@0: error(['ERROR: This version of EDB1creindexmatrix can not create such large matrics']) tp@0: end tp@0: tp@0: if n == 2 tp@0: iv1 = uint32([1:ndivvec(1)].'); tp@0: iv2 = uint32([1:ndivvec(2)]); tp@0: iv1 = iv1(:,uint8(ones(1,ndivvec(2)))); tp@0: iv2 = iv2(uint8(ones(ndivvec(1),1)),:); tp@0: tp@0: ivmatrix = [reshape(iv1.',prod(ndivvec),1) reshape(iv2.',prod(ndivvec),1)]; tp@0: elseif n >= 3 tp@0: ivmatrix = EDB1creindexmatrix(ndivvec(2:n)); tp@0: ivmatrix = repmat(ivmatrix,[ndivvec(1),1]); tp@0: ivfirstcol = uint32([1:ndivvec(1)].'); tp@0: ivfirstcol = ivfirstcol(:,uint8(ones(1,prod(ndivvec(2:n))))); tp@0: ivfirstcol = reshape(ivfirstcol.',prod(ndivvec),1); tp@0: ivmatrix = [ivfirstcol ivmatrix]; tp@0: end