Do not be confused with comments, those are for previous version of the question - Kuba
Imagine I have a matrix of the form:
MatrixForm[{{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}}]
I would like to apply a transform that generates a matrix of the form:
MatrixForm[{{4, 8, 12, 16}, {3, 7, 11, 15}, {2, 6, 10, 14}, {1, 5, 9, 13}}]
What would be the appropriate terminology for this transformation? It looks a bit like a 90 degree counterclockwise rotation of the elements in the matrix.
Is there a simple way to do it in Mathematica with large matrices?
Answer
This will do the job:
t = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}}
Transpose@(Reverse /@ t) // MatrixForm
It is not just ad hoc method. Reverse/@
is "reflection" in x direction (while Reverse@
in y), Transpose
is "reflection" through y= -x. So this composition is not a guess.
Using this remarks it is easily to show some kind reverse approach:
Reverse@(Transpose@ t)
I used "reflection" because is not a real reflection, only positions are reflected. In our case coordinates origin is at the center of MatrixForm
. I haven't said Matrix
intentionally to not be confused what is center of the matrix for even dimension case.
One could show good mathematical notation in this case. I'm not experienced in dealing with groups so I will not do this ;)
Comments
Post a Comment