PermutationMatrix
✖
PermutationMatrix

represents the permutation matrix given by permutation vector permv as a structured array.
Details and Options



- Permutation matrices, when represented as structured arrays, allow for efficient storage and more efficient operations, including Det, Inverse and LinearSolve.
- Permutation matrices typically occur in the output from matrix decomposition algorithms to represent row or column permutations (usually termed pivoting in that context).
- Given a permutation vector
, the resulting permutation matrix
is given by
. This corresponds to a matrix that has a one in column
of row
and zeros elsewhere.
- A permutation matrix
can be used to permute rows by multiplying from the left
or permute columns by multiplying its transpose from the right
.
- A permutation matrix
is an orthogonal matrix, where the inverse is equivalent to the transpose
.
- Permutation matrices are closed under matrix multiplication, so
is again a permutation matrix.
- The determinant of a permutation matrix is either
or 1 and equals Signature[permv].
- Operations that are accelerated for PermutationMatrix include:
-
Det time Dot time Inverse time LinearSolve time - For a PermutationMatrix sa, the following properties "prop" can be accessed as sa["prop"]:
-
"PermutationCycles" disjoint cycle representation of the permutation matrix "PermutationList" permutation list representation of the permutation matrix "WorkingPrecision" precision used internally "Properties" list of supported properties "Structure" type of structured array "StructuredData" internal data stored by the structured array "StructuredAlgorithms" list of functions with special methods for the structured array "Summary" summary information, represented as a Dataset - Normal[PermutationMatrix[…]] gives the permutation matrix as an ordinary matrix.
- The following options can be given:
-
TargetStructure Automatic the structure of the returned matrix WorkingPrecision Infinity precision at which to create entries - Possible settings for TargetStructure include:
-
Automatic automatically choose the representation returned "Dense" represent the matrix as a dense matrix "Orthogonal" represent the matrix as an orthogonal matrix "Sparse" represent the matrix as a sparse array "Structured" represent the matrix as a structured array "Unitary" represent the matrix as a unitary matrix - PermutationMatrix[…,TargetStructureAutomatic] is equivalent to PermutationMatrix[…,TargetStructure"Structured"].

Examples
open allclose allBasic Examples (2)Summary of the most common use cases
Construct a permutation matrix from a permutation vector:

https://wolfram.com/xid/0b0kvcg77mq-fepqs1


https://wolfram.com/xid/0b0kvcg77mq-cbmlaq

Get the normal representation:

https://wolfram.com/xid/0b0kvcg77mq-40bl

Represent a permutation matrix as a structured array:

https://wolfram.com/xid/0b0kvcg77mq-i25wn3


https://wolfram.com/xid/0b0kvcg77mq-f77dra


https://wolfram.com/xid/0b0kvcg77mq-y7v8x

Scope (7)Survey of the scope of standard use cases
Construct a permutation matrix from a disjoint cycle representation:

https://wolfram.com/xid/0b0kvcg77mq-bkzju3


https://wolfram.com/xid/0b0kvcg77mq-gbfya

Get the normal representation:

https://wolfram.com/xid/0b0kvcg77mq-qmwi51

Specify the dimension of the permutation matrix:

https://wolfram.com/xid/0b0kvcg77mq-bzemrv


https://wolfram.com/xid/0b0kvcg77mq-bvzdbt

Construct a permutation matrix from a TwoWayRule (an interchange permutation):

https://wolfram.com/xid/0b0kvcg77mq-lywqm6


https://wolfram.com/xid/0b0kvcg77mq-vhaqu

Get the normal representation:

https://wolfram.com/xid/0b0kvcg77mq-nhyw5p

Specify the dimension of the permutation matrix:

https://wolfram.com/xid/0b0kvcg77mq-cd2y14


https://wolfram.com/xid/0b0kvcg77mq-lcuqw3

Construct a permutation matrix from an explicit matrix:

https://wolfram.com/xid/0b0kvcg77mq-hosfy9


https://wolfram.com/xid/0b0kvcg77mq-f92qh5

Get the normal representation:

https://wolfram.com/xid/0b0kvcg77mq-g13vev

PermutationMatrix objects include properties that give information about the array:

https://wolfram.com/xid/0b0kvcg77mq-b621dk


https://wolfram.com/xid/0b0kvcg77mq-llpipt

"PermutationCycles" gives the disjoint cycle representation of the underlying permutation:

https://wolfram.com/xid/0b0kvcg77mq-b3ncvr

"PermutationList" gives the permutation list representation:

https://wolfram.com/xid/0b0kvcg77mq-e266ys

"WorkingPrecision" gives the precision of the matrix entries:

https://wolfram.com/xid/0b0kvcg77mq-dm0tz8

The "Summary" property gives a brief summary of information about the array:

https://wolfram.com/xid/0b0kvcg77mq-ut0aor

The "StructuredAlgorithms" property lists the functions that have structured algorithms:

https://wolfram.com/xid/0b0kvcg77mq-33g6sl

Structured algorithms are typically faster:

https://wolfram.com/xid/0b0kvcg77mq-jajv3g


https://wolfram.com/xid/0b0kvcg77mq-bnq7yv

https://wolfram.com/xid/0b0kvcg77mq-g7wc27


https://wolfram.com/xid/0b0kvcg77mq-ey9v23


https://wolfram.com/xid/0b0kvcg77mq-lr4kp4


https://wolfram.com/xid/0b0kvcg77mq-g5ps9o


https://wolfram.com/xid/0b0kvcg77mq-fbvdei


https://wolfram.com/xid/0b0kvcg77mq-ebqg40

When appropriate, structured algorithms return another PermutationMatrix object:

https://wolfram.com/xid/0b0kvcg77mq-otpl4i

The inverse allows you to easily get the inverse permutation:

https://wolfram.com/xid/0b0kvcg77mq-471hf


https://wolfram.com/xid/0b0kvcg77mq-b50vu3

Verify the inverse relationship:

https://wolfram.com/xid/0b0kvcg77mq-fi77qc

This is equivalent to the result of InversePermutation:

https://wolfram.com/xid/0b0kvcg77mq-qsaf

Generate a random 104×104 permutation vector:

https://wolfram.com/xid/0b0kvcg77mq-ctn28w
The representation and computation are efficient for the structured array:

https://wolfram.com/xid/0b0kvcg77mq-nnvdz


https://wolfram.com/xid/0b0kvcg77mq-fb80n

The normal representation is dramatically bigger (80 KB vs. 800 MB) and slower:

https://wolfram.com/xid/0b0kvcg77mq-i54wge

The inverse needs 2.4 GB of storage:

https://wolfram.com/xid/0b0kvcg77mq-bwv4or

Options (2)Common values & functionality for each option
TargetStructure (1)
Return the permutation matrix as a dense matrix:

https://wolfram.com/xid/0b0kvcg77mq-e3t5fj

Return the permutation matrix as a structured array:

https://wolfram.com/xid/0b0kvcg77mq-numczz

Return the permutation matrix as a sparse array:

https://wolfram.com/xid/0b0kvcg77mq-jnxo7

Return the permutation matrix as an orthogonal matrix:

https://wolfram.com/xid/0b0kvcg77mq-b69zd3

Return the permutation matrix as a unitary matrix:

https://wolfram.com/xid/0b0kvcg77mq-iwv2oo

Applications (4)Sample problems that can be solved with this function
A function for computing the LU decomposition of a matrix:

https://wolfram.com/xid/0b0kvcg77mq-gbi5gq

https://wolfram.com/xid/0b0kvcg77mq-cjl38l


https://wolfram.com/xid/0b0kvcg77mq-vuzi9

Generate permutation matrices corresponding to the elements of a permutation group:

https://wolfram.com/xid/0b0kvcg77mq-b2y7g

Compute a multiplication table for the group:

https://wolfram.com/xid/0b0kvcg77mq-dw8eck

This is equivalent to the result of GroupMultiplicationTable:

https://wolfram.com/xid/0b0kvcg77mq-hec4js

Define the vec operator, which stacks the columns of a matrix into a single vector:

https://wolfram.com/xid/0b0kvcg77mq-jgx3qn
Define the vec-permutation matrix, also called the commutation matrix:

https://wolfram.com/xid/0b0kvcg77mq-be4wql
The vec-permutation matrix relates the result of applying the vec operator to a matrix and its transpose:

https://wolfram.com/xid/0b0kvcg77mq-bff18k

The vec-permutation matrix can be used to express the relationship between the Kronecker product of two given matrices and the Kronecker product of the same matrices in reverse order:

https://wolfram.com/xid/0b0kvcg77mq-cmsobh

The efficiency of the fast Fourier transform (FFT) relies on being able to form a larger Fourier matrix from two smaller ones. Generate two small Fourier matrices of sizes p and q:

https://wolfram.com/xid/0b0kvcg77mq-cooljk


https://wolfram.com/xid/0b0kvcg77mq-bjetwu

The Fourier matrix of size p q can be expressed as a product of four simpler matrices:

https://wolfram.com/xid/0b0kvcg77mq-fibd5d

Show that the resulting matrix is equivalent to the result of FourierMatrix:

https://wolfram.com/xid/0b0kvcg77mq-ly5xff

The discrete Fourier transform of a vector can be computed by successively multiplying the factors of the Fourier matrix to the vector:

https://wolfram.com/xid/0b0kvcg77mq-h9ve36

The result is equivalent to applying Fourier to the vector:

https://wolfram.com/xid/0b0kvcg77mq-c46typ

Properties & Relations (6)Properties of the function, and connections to other functions
Convert an identity matrix to a permutation matrix:

https://wolfram.com/xid/0b0kvcg77mq-bqht8w

Show the disjoint cycle representation:

https://wolfram.com/xid/0b0kvcg77mq-q3qho

PermutationMatrix[p<->q] is equivalent to PermutationMatrix[Cycles[{{p,q}}]]:

https://wolfram.com/xid/0b0kvcg77mq-fhmnqd


https://wolfram.com/xid/0b0kvcg77mq-ev6hdu


https://wolfram.com/xid/0b0kvcg77mq-eogbu

Use SparseArray[PermutationMatrix[…]] to get a representation as a SparseArray:

https://wolfram.com/xid/0b0kvcg77mq-lzn6fy

Generate a random permutation list:

https://wolfram.com/xid/0b0kvcg77mq-bbj63c

Premultiplication with a permutation matrix is equivalent to using Part with a permutation list:

https://wolfram.com/xid/0b0kvcg77mq-dot9wu


https://wolfram.com/xid/0b0kvcg77mq-dy0vx6


https://wolfram.com/xid/0b0kvcg77mq-b1wh07

Postmultiplication with a permutation matrix is equivalent to using Permute with a permutation list:

https://wolfram.com/xid/0b0kvcg77mq-dmohon


https://wolfram.com/xid/0b0kvcg77mq-vm1s5

The determinant of a permutation matrix is equal to the signature of the corresponding permutation list:

https://wolfram.com/xid/0b0kvcg77mq-ixz7a0


https://wolfram.com/xid/0b0kvcg77mq-epz3ob


https://wolfram.com/xid/0b0kvcg77mq-u2jh3

The permanent of the product of a permutation matrix and a general matrix is equal to the permanent of the original matrix:

https://wolfram.com/xid/0b0kvcg77mq-b2arhv

https://wolfram.com/xid/0b0kvcg77mq-b80ffl

Neat Examples (1)Surprising or curious use cases

https://wolfram.com/xid/0b0kvcg77mq-f0641

Generate a symmetric block matrix with bidiagonal blocks (a Jordan–Wielandt matrix):

https://wolfram.com/xid/0b0kvcg77mq-c1ytu5

Define the "perfect shuffle" permutation:

https://wolfram.com/xid/0b0kvcg77mq-deqbr8
Use the perfect shuffle to transform the Jordan–Wielandt matrix into a tridiagonal matrix (a Golub–Kahan tridiagonal matrix):

https://wolfram.com/xid/0b0kvcg77mq-lkeq5z

Compute the singular values of a numerical upper bidiagonal matrix:

https://wolfram.com/xid/0b0kvcg77mq-2agsf

These are equivalent to the positive eigenvalues of the Golub–Kahan tridiagonal matrix:

https://wolfram.com/xid/0b0kvcg77mq-gm9u4b

Wolfram Research (2022), PermutationMatrix, Wolfram Language function, https://reference.wolfram.com/language/ref/PermutationMatrix.html (updated 2024).
Text
Wolfram Research (2022), PermutationMatrix, Wolfram Language function, https://reference.wolfram.com/language/ref/PermutationMatrix.html (updated 2024).
Wolfram Research (2022), PermutationMatrix, Wolfram Language function, https://reference.wolfram.com/language/ref/PermutationMatrix.html (updated 2024).
CMS
Wolfram Language. 2022. "PermutationMatrix." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/PermutationMatrix.html.
Wolfram Language. 2022. "PermutationMatrix." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/PermutationMatrix.html.
APA
Wolfram Language. (2022). PermutationMatrix. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/PermutationMatrix.html
Wolfram Language. (2022). PermutationMatrix. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/PermutationMatrix.html
BibTeX
@misc{reference.wolfram_2025_permutationmatrix, author="Wolfram Research", title="{PermutationMatrix}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/PermutationMatrix.html}", note=[Accessed: 16-May-2025
]}
BibLaTeX
@online{reference.wolfram_2025_permutationmatrix, organization={Wolfram Research}, title={PermutationMatrix}, year={2024}, url={https://reference.wolfram.com/language/ref/PermutationMatrix.html}, note=[Accessed: 16-May-2025
]}