Comparing two circularly shifted matrices

51 Views Asked by At

I am looking for a way to compare two matrices A and B where B is the result of circularly shifting rows of A i.e.

A = [1 2 3;4 5 6], B = [4 5 6;1 2 3]

Is there an operator or metric that would treat these matrices as equivalent?

The reason I'd like to do this is I have an optimization problem where I am minimizing a cost function involving B but need solutions that are consistent with the original data A (i.e. B is the result of circularly shifting rows of A).

Any help would be very much appreciated.

1

There are 1 best solutions below

4
On BEST ANSWER

We could take the metric $$ d(A,B) = \min_\sigma \|A - \sigma(B)\| $$ That is: for any norm $\|\cdot\|$, take the minimum of the norm of the difference between $A$ and the possible permutations of $B$. So, for your $2 \times 3$ example, we'd have $$ d(A,B) = \min\left\{\left\|A - \pmatrix{B_1\\B_2} \right\|,\left\|A - \pmatrix{B_2\\B_1} \right\|\right\} $$ where $B_i$ are the rows of $B$.