Add tests for wood1().
[octave.git] / permutation_matrices.m
1 function PMs = permutation_matrices(integerN)
2 ## Generate all permutation matrices of size ``integerN``.
3 ##
4 ## INPUT:
5 ##
6 ## - ``integerN`` -- The dimension of the resulting matrices.
7 ##
8 ## OUTPUT:
9 ##
10 ## - ``PMs`` -- A cell array of permutation matrices.
11 ##
12
13 if (integerN < 1)
14 PMs = NA;
15 return;
16 end
17
18 ## Append to this as we generate them.
19 PMs = {};
20
21 ## Generate all permutations of [1,2,...,integerN].
22 permutations = perms([1:integerN]);
23
24 for idx = [ 1 : factorial(integerN) ]
25 sigma = permutations(idx,:);
26 ## Create a permutation matrix from the permutation, sigma.
27 P = eye(integerN) (sigma,:);
28 PMs{end+1} = P;
29 end
30
31 end