X-Git-Url: http://gitweb.michael.orlitzky.com/?p=octave.git;a=blobdiff_plain;f=permutation_matrices.m;h=1ad1e57dc93c07995ee09d870b9100cf7384e749;hp=9032d2e8eef5528355985d040133201a5421dea2;hb=b12c6c2a4bf4cef29b2e08b743c92889505c7ed9;hpb=e1b71b4ca7cfa08ac76744a17a3778d4ccfaa7e2 diff --git a/permutation_matrices.m b/permutation_matrices.m index 9032d2e..1ad1e57 100644 --- a/permutation_matrices.m +++ b/permutation_matrices.m @@ -1,29 +1,29 @@ function PMs = permutation_matrices(integerN) - ## Generate all permutation matrices of size ``integerN``. - ## - ## INPUT: - ## - ## - ``integerN`` -- The dimension of the resulting matrices. - ## - ## OUTPUT: - ## - ## - ``PMs`` -- A cell array of permutation matrices. - ## + % Generate all permutation matrices of size ``integerN``. + % + % INPUT: + % + % - ``integerN`` -- The dimension of the resulting matrices. + % + % OUTPUT: + % + % - ``PMs`` -- A cell array of permutation matrices. + % if (integerN < 1) PMs = NA; return; end - ## Append to this as we generate them. + % Append to this as we generate them. PMs = {}; - ## Generate all permutations of [1,2,...,integerN]. + % Generate all permutations of [1,2,...,integerN]. permutations = perms([1:integerN]); for idx = [ 1 : factorial(integerN) ] sigma = permutations(idx,:); - ## Create a permutation matrix from the permutation, sigma. + % Create a permutation matrix from the permutation, sigma. P = eye(integerN) (sigma,:); PMs{end+1} = P; end