Does anyone know an efficient way to right circular-shift a matrix? Btw, the matrix is binary but a method to solve a non-binary matrix is also fine.
Right now, I'm thinking of implementing a circular array for the rows of my matrix and updating each row whenever a shift operation is required.
Another method, I was considering was implementing a vector of pointers to columns (of the matrix) represented by vectors and swapping them around when a shift operation occurs.
E.g.
1 2 3
4 5 6
7 8 9
Right-shift
3 1 2
6 4 5
9 7 8
Another problem arises with all these solutions if I need to shift the matrix down as well. To implement both operations efficiently, is completely beyond me.
Down-shift
9 7 8
3 1 2
6 4 5