In mathematics, especially in linear algebra and matrix theory, the commutation matrix is used for transforming the vectorized form of a matrix into the vectorized form of its transpose.
Specifically, the commutation matrix K(m,n) is the nm × mn permutation matrix which, for any m × n matrix A, transforms vec(A) into vec(AT): Here vec(A) is the mn × 1 column vector obtain by stacking the columns of A on top of one another: where A = [Ai,j].
The cycles and other properties of this permutation have been heavily studied for in-place matrix transposition algorithms.
In the context of quantum information theory, the commutation matrix is sometimes referred to as the swap matrix or swap operator [1] For both square and rectangular matrices of m rows and n columns, the commutation matrix can be generated by the code below.
has the following column-major and row-major vectorizations (respectively): The associated commutation matrix is (where each