I'm currently trying to find a way to eliminate from a square matrix of generic dimension the duplicate (up to sign) rows and columns, obtaining a smaller dimensional matrix. I searched around here but I couldn't find an answer, neither I managed to combine methods for list manipulation in order to arrive at my result.
I'll make an example in order to clarify. Suppose I have a matrix of this form: $$ \left(\begin{array}{cccccc} x_1 & w_2 & -x_1 & -w_1 & -w_2 & w_1\\ z_2 & x_2 & -z_2 & z_1 & -x_2 & -z_1 \\ -x_1 & -w_2 & x_1 & w_1 & w_2 & -w_1\\ -y_2 & y_1 & y_2 & x_3 & -y_1 & -x_3\\ z_2 & x_2 & -z_2 & z_1 & -x_2 & -z_1\\ y_2 & -y_1 & -y_2 & -x_3 & y_1 & x_3\\ \end{array} \right) $$
I want to eliminate rows and columns 3,5,6, (copies of 1,2,4) ending up with the matrix
$$ \left(\begin{array}{ccc} x_1 & w_2 & -w_1\\ z_2 & x_2 & z_1\\ -y_2 & y_1 & x_3\\ \end{array} \right) $$
I would like to implement this operation so that it can act on matrices of arbitrary dimension.
Thank you very much!
Stefano
DeleteDuplicates
with a custom comparison function might work. $\endgroup$DeleteDuplicates
is that, even if I can tell him to eliminate both equal and opposite elements, it eliminates the elements, while I'd like to eliminate rows and columns. For example my matrix might contain a lot of zeroes and not all of them should be eliminated. $\endgroup$