Reverse rows in a matrix

4.5k Views Asked by At

To rotate a matrix 180 degrees around the center point, what I am planning to do is first transverse the matrix, then reverse the rows and then do it again to produce the final result.

This works and I can do it step by step, but how would I mathematically represent the second step (switching the rows) as a matrix? as in:

[2,1] * reversing matrix = [1,2]
[1,0]                      [0,1]
2

There are 2 best solutions below

5
On BEST ANSWER

Letting $$P=\left[\begin{array}{cc}0 & 1\\1 & 0\end{array}\right],$$ we have $$\left[\begin{array}{cc}0 & 1\\1 & 0\end{array}\right]\left[\begin{array}{cc}a & b\\c & d\end{array}\right]\left[\begin{array}{cc}0 & 1\\1 & 0\end{array}\right]=\left[\begin{array}{cc}d & c\\b & a\end{array}\right].$$ Multiplication by on the right by $P$ swaps the columns of a $2\times 2$ matrix, and multiplication on the left by $P$ swaps the rows of a $2\times 2$ matrix. Doing both gives the end result of a $180^\circ$ rotation of the entries.

3
On
[1 2] [0 1]  =  [2 1] 
[3 4] [1 0]     [4 3]