x = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
Rotation by 1 unit should give:
x = [[4, 1, 2],
[7, 5, 3],
[8, 9, 6]]
Basically, I want to shift each circular layer in the array by 'n' units.
I looked at numpy.roll but couldn't figure out to use it for this use case. I cannot use image rotation routines like scipy.ndimage.interpolation.rotate as they change the shape and not quite achieve the desired result.
Edit:
For the 4 X 4 matrix:
x = [[a, b, c, d],
[e, f, g, h],
[i, j, k, l],
[m, n, o, p]]
Rotation by 1 unit should give:
x = [[e, a, b, c],
[i, j, f, d],
[m, k, g, h],
[n, o, p, l]]
Edit:
Adding some clarifications on how this works for arbitrary sizes.
For a N X N matrix rotated by 1 unit, the outer 'ring' is first shifted by 1. Same logic is followed the remaining 'inner' (N-2) X (N-2) matrix recursively.
[[4, 1, 2], [7, 5, 3], [8, 9, 6]]? Because right now, I can't make sense out of it...