tp@0
|
1 function ivmatrix = EDB1creindexmatrix(ndivvec)
|
tp@0
|
2 % EDB1creindeixmatrix creates a matrix with index numbers.
|
tp@0
|
3 %
|
tp@0
|
4 % Input parameters:
|
tp@0
|
5 % ndivvec A matrix, [1,specorder], with the maximum counter
|
tp@0
|
6 % number for each dimension.
|
tp@0
|
7 %
|
tp@0
|
8 % Output parameters:
|
tp@0
|
9 % ivmatrix A matrix, [prod(ndivvec),specorder] of all possible
|
tp@0
|
10 % combinations of the integers
|
tp@0
|
11 %
|
tp@0
|
12 % ----------------------------------------------------------------------------------------------
|
tp@0
|
13 % This file is part of the Edge Diffraction Toolbox by Peter Svensson.
|
tp@0
|
14 %
|
tp@0
|
15 % The Edge Diffraction Toolbox is free software: you can redistribute it and/or modify
|
tp@0
|
16 % it under the terms of the GNU General Public License as published by the Free Software
|
tp@0
|
17 % Foundation, either version 3 of the License, or (at your option) any later version.
|
tp@0
|
18 %
|
tp@0
|
19 % The Edge Diffraction Toolbox is distributed in the hope that it will be useful,
|
tp@0
|
20 % but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
tp@0
|
21 % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
tp@0
|
22 %
|
tp@0
|
23 % You should have received a copy of the GNU General Public License along with the
|
tp@0
|
24 % Edge Diffraction Toolbox. If not, see <http://www.gnu.org/licenses/>.
|
tp@0
|
25 % ----------------------------------------------------------------------------------------------
|
tp@0
|
26 % Peter Svensson (svensson@iet.ntnu.no) 20050505
|
tp@0
|
27 %
|
tp@0
|
28 % ivmatrix = EDB1creindexmatrix(ndivvec)
|
tp@0
|
29
|
tp@0
|
30 n = length(ndivvec);
|
tp@0
|
31
|
tp@0
|
32 maxval = max(ndivvec);
|
tp@0
|
33 if maxval > 2^32
|
tp@0
|
34 error(['ERROR: This version of EDB1creindexmatrix can not create such large matrics'])
|
tp@0
|
35 end
|
tp@0
|
36
|
tp@0
|
37 if n == 2
|
tp@0
|
38 iv1 = uint32([1:ndivvec(1)].');
|
tp@0
|
39 iv2 = uint32([1:ndivvec(2)]);
|
tp@0
|
40 iv1 = iv1(:,uint8(ones(1,ndivvec(2))));
|
tp@0
|
41 iv2 = iv2(uint8(ones(ndivvec(1),1)),:);
|
tp@0
|
42
|
tp@0
|
43 ivmatrix = [reshape(iv1.',prod(ndivvec),1) reshape(iv2.',prod(ndivvec),1)];
|
tp@0
|
44 elseif n >= 3
|
tp@0
|
45 ivmatrix = EDB1creindexmatrix(ndivvec(2:n));
|
tp@0
|
46 ivmatrix = repmat(ivmatrix,[ndivvec(1),1]);
|
tp@0
|
47 ivfirstcol = uint32([1:ndivvec(1)].');
|
tp@0
|
48 ivfirstcol = ivfirstcol(:,uint8(ones(1,prod(ndivvec(2:n)))));
|
tp@0
|
49 ivfirstcol = reshape(ivfirstcol.',prod(ndivvec),1);
|
tp@0
|
50 ivmatrix = [ivfirstcol ivmatrix];
|
tp@0
|
51 end
|