How to organize columns and rows of a matrix mathematically

60 Views Asked by At

I have a matrix M whose size i.e $8$x$8$ , as follows:

enter image description here

where $x$ can be any non-zero value. . I need to organize this matrix $M$ to move the elements $M$(3:4,3:4) to be in positions $N$(7:8,7:8). On the other hand, the elements of $M$(5:8,5:8) to be moved into $N$(3:6,3:6). It means that the matrix $N$ should be as follows:

enter image description here

My question, how should it be the permutation matrix to be multiplied by $M$ in order to get $N$? Or if there is another mathematical expression we can use to get matrix $N$ based on M. I need it in general case, it means whatever the size of matrix $M$, we can organize it to get the other matrix as in matrix $N$.

EDIT:

What I need exactly is to move the elements in red into last rows and column and then move the elements in blue into their places as follows:

enter image description here

and the resultant matrix is as below:

enter image description here

1

There are 1 best solutions below

2
On

Hint: If you want to find the matrix that swap two rows or columns just swap that rows or columns in the Identity matrix. For example if you want to swap columns $3\leftrightarrow 7$ then you should multiply (from left side or right?) your matrix to the following matrix:

$$\begin{pmatrix}1&0&\color{red}{0}&0&0&0&\color{blue}{0}&0\\ 0&1&\color{red}{0}&0&0&0&\color{blue}{0}&0\\ 0&0&\color{red}{1}&0&0&0&\color{blue}{0}&0\\ 0&0&\color{red}{0}&1&0&0&\color{blue}{0}&0\\ 0&0&\color{red}{0}&0&1&0&\color{blue}{0}&0\\ 0&0&\color{red}{0}&0&0&1&\color{blue}{0}&0\\ 0&0&\color{red}{0}&0&0&0&\color{blue}{1}&0\\ 0&0&\color{red}{0}&0&0&0&\color{blue}{0}&1\\\end{pmatrix}\to \begin{pmatrix}1&0&\color{blue}{0}&0&0&0&\color{red}{0}&0\\ 0&1&\color{blue}{0}&0&0&0&\color{red }{0}&0\\ 0&0&\color{blue}{0}&0&0&0&\color{red}{1}&0\\ 0&0&\color{blue}{0}&1&0&0&\color{red}{0}&0\\ 0&0&\color{blue}{0}&0&1&0&\color{red}{0}&0\\ 0&0&\color{blue}{0}&0&0&1&\color{red}{0}&0\\ 0&0&\color{blue}{1}&0&0&0&\color{red}{0}&0\\ 0&0&\color{blue}{0}&0&0&0&\color{red}{0}&1\\\end{pmatrix}$$

Example: Verify the following: $$\begin{pmatrix}1&2&3\\ 4&5&6\\ 7&8&9 \end{pmatrix}\times \begin{pmatrix}1&\color{red}{0}&\color{blue}{0}\\ 0&\color{red}{0}&\color{blue}{1}\\ 0&\color{red}{1}&\color{blue}{0} \end{pmatrix}=\begin{pmatrix}1&3&2\\ 4&6&5\\ 7&9&8 \end{pmatrix}$$