Permutation matrix
Template:Short description Template:Use American English
In mathematics, particularly in matrix theory, a permutation matrix is a square binary matrix that has exactly one entry of 1 in each row and each column with all other entries 0.<ref name="Artin Algebra">Template:Cite book</ref>Template:Rp An Template:Math permutation matrix can represent a permutation of Template:Mvar elements. Pre-multiplying an Template:Mvar-row matrix Template:Mvar by a permutation matrix Template:Mvar, forming Template:Mvar, results in permuting the rows of Template:Mvar, while post-multiplying an Template:Mvar-column matrix Template:Mvar, forming Template:Mvar, permutes the columns of Template:Mvar.
Every permutation matrix P is orthogonal, with its inverse equal to its transpose: <math>P^{-1}=P^\mathsf{T}</math>.<ref name="Artin Algebra" />Template:Rp Indeed, permutation matrices can be characterized as the orthogonal matrices whose entries are all non-negative.<ref>Template:Cite journal</ref>
The two permutation/matrix correspondencesEdit
There are two natural one-to-one correspondences between permutations and permutation matrices, one of which works along the rows of the matrix, the other along its columns. Here is an example, starting with a permutation Template:Pi in two-line form at the upper left:
- <math>\begin{matrix}
\pi\colon\begin{pmatrix}1&2&3&4\\3&2&4&1\end{pmatrix} & \longleftrightarrow & R_\pi\colon\begin{pmatrix} 0&0&1&0\\ 0&1&0&0\\ 0&0&0&1\\ 1&0&0&0\end{pmatrix}\\[5pt] \Big\updownarrow && \Big\updownarrow\\[5pt] C_\pi\colon\begin{pmatrix} 0&0&0&1\\ 0&1&0&0\\ 1&0&0&0\\ 0&0&1&0\end{pmatrix} & \longleftrightarrow & \pi^{-1}\colon\begin{pmatrix}1&2&3&4\\4&2&1&3\end{pmatrix}\end{matrix}</math> The row-based correspondence takes the permutation Template:Pi to the matrix <math>R_\pi</math> at the upper right. The first row of <math>R_\pi</math> has its 1 in the third column because <math>\pi(1)=3</math>. More generally, we have <math>R_\pi=(r_{ij})</math> where <math>r_{ij}=1</math> when <math>j=\pi(i)</math> and <math>r_{ij}=0</math> otherwise.
The column-based correspondence takes Template:Pi to the matrix <math>C_\pi</math> at the lower left. The first column of <math>C_\pi</math> has its 1 in the third row because <math>\pi(1)=3</math>. More generally, we have <math>C_\pi=(c_{ij})</math> where <math>c_{ij}</math> is 1 when <math>i=\pi(j)</math> and 0 otherwise. Since the two recipes differ only by swapping i with j, the matrix <math>C_\pi</math> is the transpose of <math>R_\pi</math>; and, since <math>R_\pi</math> is a permutation matrix, we have <math>C_\pi=R_\pi^\mathsf{T}=R_\pi^{-1}</math>. Tracing the other two sides of the big square, we have <math>R_{\pi^{-1}}=C_\pi=R_\pi^{-1}</math> and <math>C_{\pi^{-1}}=R_\pi</math>.<ref>This terminology is not standard. Most authors use just one of the two correspondences, choosing which to be consistent with their other conventions. For example, Artin uses the column-based correspondence. We have here invented two names in order to discuss both options.</ref>
Permutation matrices permute rows or columnsEdit
Multiplying a matrix M by either <math>R_\pi</math> or <math>C_\pi</math> on either the left or the right will permute either the rows or columns of M by either Template:Pi or Template:Pi−1. The details are a bit tricky.
To begin with, when we permute the entries of a vector <math>(v_1,\ldots,v_n)</math> by some permutation Template:Pi, we move the <math>i^\text{th}</math> entry <math>v_i</math> of the input vector into the <math>\pi(i)^\text{th}</math> slot of the output vector. Which entry then ends up in, say, the first slot of the output? Answer: The entry <math>v_j</math> for which <math>\pi(j)=1</math>, and hence <math>j=\pi^{-1}(1)</math>. Arguing similarly about each of the slots, we find that the output vector is
- <math> \big(v_{\pi^{-1}(1)},v_{\pi^{-1}(2)},\ldots,v_{\pi^{-1}(n)}\big),</math>
even though we are permuting by <math>\pi</math>, not by <math>\pi^{-1}</math>. Thus, in order to permute the entries by <math>\pi</math>, we must permute the indices by <math>\pi^{-1}</math>.<ref name="Artin Algebra" />Template:Rp (Permuting the entries by <math>\pi</math> is sometimes called taking the alibi viewpoint, while permuting the indices by <math>\pi</math> would take the alias viewpoint.<ref>Template:Cite book</ref>)
Now, suppose that we pre-multiply some n-row matrix <math>M=(m_{i,j})</math> by the permutation matrix <math>C_\pi</math>. By the rule for matrix multiplication, the <math>(i,j)^\text{th}</math> entry in the product <math>C_\pi M</math> is
- <math display=block>\sum_{k=1}^n c_{i,k}m_{k,j},</math>
where <math>c_{i,k}</math> is 0 except when <math>i=\pi(k)</math>, when it is 1. Thus, the only term in the sum that survives is the term in which <math>k=\pi^{-1}(i)</math>, and the sum reduces to <math>m_{\pi^{-1}(i),j}</math>. Since we have permuted the row index by <math>\pi^{-1}</math>, we have permuted the rows of M themselves by Template:Pi.<ref name="Artin Algebra" />Template:Rp A similar argument shows that post-multiplying an n-column matrix M by <math>R_\pi</math> permutes its columns by Template:Pi.
The other two options are pre-multiplying by <math>R_\pi</math> or post-multiplying by <math>C_\pi</math>, and they permute the rows or columns respectively by Template:Pi−1, instead of by Template:Pi.
The transpose is also the inverseEdit
A related argument proves that, as we claimed above, the transpose of any permutation matrix P also acts as its inverse, which implies that P is invertible. (Artin leaves that proof as an exercise,<ref name="Artin Algebra" />Template:Rp which we here solve.) If <math>P=(p_{i,j})</math>, then the <math>(i,j)^\text{th}</math> entry of its transpose <math>P^\mathsf{T}</math> is <math>p_{j,i}</math>. The <math>(i,j)^\text{th}</math> entry of the product <math>PP^\mathsf{T}</math> is then
- <math display=block>\sum_{k=1}^n p_{i,k}p_{j,k}.</math>
Whenever <math>i\ne j</math>, the <math>k^\text{th}</math> term in this sum is the product of two different entries in the <math>k^\text{th}</math> column of P; so all terms are 0, and the sum is 0. When <math>i=j</math>, we are summing the squares of the entries in the <math>i^\text{th}</math> row of P, so the sum is 1. The product <math>PP^\mathsf{T}</math> is thus the identity matrix. A symmetric argument shows the same for <math>P^\mathsf{T}P</math>, implying that P is invertible with <math>P^{-1}=P^\mathsf{T}</math>.
Multiplying permutation matricesEdit
Given two permutations of Template:Math elements Template:Sigma and Template:Tau, the product of the corresponding column-based permutation matrices Template:Math and Template:Math is given,<ref name="Artin Algebra" />Template:Rp as you might expect, by <math display=block>C_{\sigma} C_{\tau} = C_{\sigma\,\circ\,\tau}, </math> where the composed permutation <math>\sigma\circ\tau</math> applies first Template:Tau and then Template:Sigma, working from right to left: <math display=block>(\sigma\circ\tau) (k) = \sigma \left(\tau (k) \right).</math> This follows because pre-multiplying some matrix by Template:Math and then pre-multiplying the resulting product by Template:Math gives the same result as pre-multiplying just once by the combined <math>C_{\sigma\,\circ\,\tau}</math>.
For the row-based matrices, there is a twist: The product of Template:Math and Template:Math is given by
- <math>R_{\sigma} R_{\tau} = R_{\tau\,\circ\,\sigma}, </math>
with Template:Sigma applied before Template:Tau in the composed permutation. This happens because we must post-multiply to avoid inversions under the row-based option, so we would post-multiply first by Template:Math and then by Template:Math.
Some people, when applying a function to an argument, write the function after the argument (postfix notation), rather than before it. When doing linear algebra, they work with linear spaces of row vectors, and they apply a linear map to an argument by using the map's matrix to post-multiply the argument's row vector. They often use a left-to-right composition operator, which we here denote using a semicolon; so the composition <math> \sigma\,;\,\tau</math> is defined either by
- <math>(\sigma\,;\,\tau)(k) = \tau\left(\sigma(k)\right),</math>
or, more elegantly, by
- <math>(k)(\sigma\,;\,\tau) = \left((k)\sigma \right)\tau,</math>
with Template:Sigma applied first. That notation gives us a simpler rule for multiplying row-based permutation matrices:
- <math>R_{\sigma} R_{\tau} = R_{\sigma\,;\,\tau}. </math>
Matrix groupEdit
When Template:Pi is the identity permutation, which has <math>\pi(i)=i</math> for all i, both Template:Math and Template:Math are the identity matrix.
There are Template:Math permutation matrices, since there are Template:Math permutations and the map <math>C\colon\pi\mapsto C_\pi</math> is a one-to-one correspondence between permutations and permutation matrices. (The map <math>R</math> is another such correspondence.) By the formulas above, those Template:Math permutation matrices form a group of order Template:Math under matrix multiplication, with the identity matrix as its identity element, a group that we denote <math>\mathcal{P}_n</math>. The group <math>\mathcal{P}_n</math> is a subgroup of the general linear group <math>GL_n(\mathbb{R})</math> of invertible Template:Math matrices of real numbers. Indeed, for any field F, the group <math>\mathcal{P}_n</math> is also a subgroup of the group <math>GL_n(F)</math>, where the matrix entries belong to F. (Every field contains 0 and 1 with <math>0+0=0,</math> <math>0+1=1,</math> <math>0*0=0,</math> <math>0*1=0,</math> and <math>1*1=1;</math> and that's all we need to multiply permutation matrices. Different fields disagree about whether <math>1+1=0</math>, but that sum doesn't arise.)
Let <math>S_n^\leftarrow</math> denote the symmetric group, or group of permutations, on {1,2,...,Template:Math} where the group operation is the standard, right-to-left composition "<math>\circ</math>"; and let <math>S_n^\rightarrow</math> denote the opposite group, which uses the left-to-right composition "<math>\,;\,</math>". The map <math>C\colon S_n^\leftarrow\to GL_n(\mathbb{R})</math> that takes Template:Pi to its column-based matrix <math>C_\pi</math> is a faithful representation, and similarly for the map <math>R\colon S_n^\rightarrow\to GL_n(\mathbb{R})</math> that takes Template:Pi to <math>R_\pi</math>.
Doubly stochastic matricesEdit
Every permutation matrix is doubly stochastic. The set of all doubly stochastic matrices is called the Birkhoff polytope, and the permutation matrices play a special role in that polytope. The Birkhoff–von Neumann theorem says that every doubly stochastic real matrix is a convex combination of permutation matrices of the same order, with the permutation matrices being precisely the extreme points (the vertices) of the Birkhoff polytope. The Birkhoff polytope is thus the convex hull of the permutation matrices.<ref name=Bru19>Template:Harvnb</ref>
Linear-algebraic propertiesEdit
Just as each permutation is associated with two permutation matrices, each permutation matrix is associated with two permutations, as we can see by relabeling the example in the big square above starting with the matrix P at the upper right:
- <math>\begin{matrix}
\rho_P\colon\begin{pmatrix}1&2&3&4\\3&2&4&1\end{pmatrix} & \longleftrightarrow & P\colon\begin{pmatrix} 0&0&1&0\\ 0&1&0&0\\ 0&0&0&1\\ 1&0&0&0\end{pmatrix}\\[5pt] \Big\updownarrow && \Big\updownarrow\\[5pt] P^{-1}\colon\begin{pmatrix} 0&0&0&1\\ 0&1&0&0\\ 1&0&0&0\\ 0&0&1&0\end{pmatrix} & \longleftrightarrow & \kappa_P\colon\begin{pmatrix}1&2&3&4\\4&2&1&3\end{pmatrix}\end{matrix}</math> So we are here denoting the inverse of C as <math>\kappa</math> and the inverse of R as <math>\rho</math>. We can then compute the linear-algebraic properties of P from some combinatorial properties that are shared by the two permutations <math>\kappa_P</math> and <math>\rho_P=\kappa_P^{-1}</math>.
A point is fixed by <math>\kappa_P</math> just when it is fixed by <math>\rho_P</math>, and the trace of P is the number of such shared fixed points.<ref name="Artin Algebra" />Template:Rp If the integer k is one of them, then the standard basis vector Template:Math is an eigenvector of P.<ref name="Artin Algebra" />Template:Rp
To calculate the complex eigenvalues of P, write the permutation <math>\kappa_P</math> as a composition of disjoint cycles, say <math>\kappa_P= c_{1}c_{2} \cdots c_{t}</math>. (Permutations of disjoint subsets commute, so it doesn't matter here whether we are composing right-to-left or left-to-right.) For <math>1 \le i \le t</math>, let the length of the cycle <math>c_i</math> be <math>\ell_i</math>, and let <math>L_{i}</math> be the set of complex solutions of <math>x^{\ell_{i}}=1</math>, those solutions being the <math>\ell_i^{\,\text{th}}</math> roots of unity. The multiset union of the <math>L_{i}</math> is then the multiset of eigenvalues of P. Since writing <math>\rho_P</math> as a product of cycles would give the same number of cycles of the same lengths, analyzing <math>\rho_p</math> would give the same result. The multiplicity of any eigenvalue v is the number of i for which <math>L_i</math> contains v.<ref name=J_Najnudel2010_4>Template:Harvnb</ref> (Since any permutation matrix is normal and any normal matrix is diagonalizable over the complex numbers,<ref name="Artin Algebra" />Template:Rp the algebraic and geometric multiplicities of an eigenvalue v are the same.)
From group theory we know that any permutation may be written as a composition of transpositions. Therefore, any permutation matrix factors as a product of row-switching elementary matrices, each of which has determinant −1. Thus, the determinant of the permutation matrix P is the sign of the permutation <math>\kappa_P</math>, which is also the sign of <math>\rho_P</math>.
Restricted formsEdit
- Costas array, a permutation matrix in which the displacement vectors between the entries are all distinct
- n-queens puzzle, a permutation matrix in which there is at most one entry in each diagonal and antidiagonal