In investigating How to generate the 8^th order symmetric binary matrices whose sum of absolute eigenvalues is 8? I wished to avoid considering matrices that differed only by the same permutation applied to their rows and columns.
My plan was to define a function perm
transforming a matrix m
to some canonical form and consider it only if perm[m]==m
.
My naive approach defined
perm[u_?MatrixQ] := Module[{ord}, ord = Ordering[u]; #[[ord]] & /@ u[[ord]]]
but I now realise that this doesn't work as reordering the columns changes the orders of the rows. For example
m = {{0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 1, 1, 1,
1}, {0, 0, 1, 1, 0, 0}, {0, 0, 1, 0, 1, 1}, {0, 0, 1, 0, 1, 1}};
perm[m] == perm[perm[m]]
(* False *)
Is there a simple way for defining and computing a canonical permutation?