How to sort lists of matrices and find the index of a matrix on a list?

26 Views Asked by At

I am working with lists of 3x3 matrices with elements from the set {0,1} (modulo 2).

Problem:

As in the title I am trying to sort these lists so that I can see if another list that may contain the same matrices but in a different order is the same.

And I want to find the index of any given matrix in a list of matrix.

My (incredibly inefficient) solution:

I already have a function that converts integers 0-511 to a "binary" matrix. I have made another function that does the inverse. Using the matrix to integer function I convert the matrices to integers, sort the list and then convert back. Similarly for the index I have a function that converts the list, finds the index of the integer and just return the index.

So my solution works but it seems so inefficient.

The initial conversion of matrices is necessary due to certain formulae I iterate each matrix through. These formulae are rely on the location of each element in the matrix hence the necessity of the matrices.

0

There are 0 best solutions below