Commutation Matrix
   HOME

TheInfoList



OR:

In
mathematics Mathematics is an area of knowledge that includes the topics of numbers, formulas and related structures, shapes and the spaces in which they are contained, and quantities and their changes. These topics are represented in modern mathematics ...
, especially in
linear algebra Linear algebra is the branch of mathematics concerning linear equations such as: :a_1x_1+\cdots +a_nx_n=b, linear maps such as: :(x_1, \ldots, x_n) \mapsto a_1x_1+\cdots +a_nx_n, and their representations in vector spaces and through matrices. ...
and
matrix theory In mathematics, a matrix (plural matrices) is a rectangular array or table of numbers, symbols, or expressions, arranged in rows and columns, which is used to represent a mathematical object or a property of such an object. For example, \begi ...
, the commutation matrix is used for transforming the vectorized form of a
matrix Matrix most commonly refers to: * ''The Matrix'' (franchise), an American media franchise ** ''The Matrix'', a 1999 science-fiction action film ** "The Matrix", a fictional setting, a virtual reality environment, within ''The Matrix'' (franchis ...
into the vectorized form of its
transpose In linear algebra, the transpose of a matrix is an operator which flips a matrix over its diagonal; that is, it switches the row and column indices of the matrix by producing another matrix, often denoted by (among other notations). The tr ...
. Specifically, the commutation matrix K(''m'',''n'') is the ''nm'' × ''mn'' matrix which, for any ''m'' × ''n'' matrix A, transforms vec(A) into vec(AT): :K(''m'',''n'') vec(A) = vec(AT) . Here vec(A) is the ''mn'' × 1
column vector In linear algebra, a column vector with m elements is an m \times 1 matrix consisting of a single column of m entries, for example, \boldsymbol = \begin x_1 \\ x_2 \\ \vdots \\ x_m \end. Similarly, a row vector is a 1 \times n matrix for some n, c ...
obtain by stacking the columns of A on top of one another: :\operatorname(\mathbf) = mathbf_, \ldots, \mathbf_, \mathbf_, \ldots, \mathbf_, \ldots, \mathbf_, \ldots, \mathbf_ where A = ''A''i'',''j'' In other words, vec(A) is the vector obtained by vectorizing A in
column-major order In computing, row-major order and column-major order are methods for storing multidimensional arrays in linear storage such as random access memory. The difference between the orders lies in which elements of an array are contiguous in memory. In ...
. Similarly, vec(AT) is the vector obtaining by vectorizing A in row-major order. In the context of
quantum information theory Quantum information is the information of the quantum state, state of a quantum system. It is the basic entity of study in quantum information theory, and can be manipulated using quantum information processing techniques. Quantum information re ...
, the commutation matrix is sometimes referred to as the swap matrix or swap operator


Properties

* The commutation matrix is a special type of
permutation matrix 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 and 0s elsewhere. Each such matrix, say , represents a permutation of elements and, when ...
, and is therefore
orthogonal In mathematics, orthogonality is the generalization of the geometric notion of ''perpendicularity''. By extension, orthogonality is also used to refer to the separation of specific features of a system. The term also has specialized meanings in ...
. In particular, K(''m'',''n'') is equal to \mathbf P_\pi, where \pi is the permutation over \ for which :: \pi(i + m(j-1)) = j + n(i-1), \quad i = 1,\dots,m, \quad j = 1,\dots,n. * Replacing A with AT in the definition of the commutation matrix shows that Therefore in the special case of ''m'' = ''n'' the commutation matrix is an
involution Involution may refer to: * Involute, a construction in the differential geometry of curves * '' Agricultural Involution: The Processes of Ecological Change in Indonesia'', a 1963 study of intensification of production through increased labour inpu ...
and
symmetric Symmetry (from grc, συμμετρία "agreement in dimensions, due proportion, arrangement") in everyday language refers to a sense of harmonious and beautiful proportion and balance. In mathematics, "symmetry" has a more precise definiti ...
. * The main use of the commutation matrix, and the source of its name, is to commute the
Kronecker product In mathematics, the Kronecker product, sometimes denoted by ⊗, is an operation on two matrices of arbitrary size resulting in a block matrix. It is a generalization of the outer product (which is denoted by the same symbol) from vectors to ...
: for every ''m'' × ''n'' matrix A and every ''r'' × ''q'' matrix B, ::\mathbf^ (\mathbf \otimes \mathbf) \mathbf^ = \mathbf \otimes \mathbf. :This property is often used in developing the higher order statistics of Wishart covariance matrices. * The case of ''n=q=1'' for the above equation states that for any column vectors v,w of sizes ''m,r'' respectively, :: \mathbf^(\mathbf v \otimes \mathbf w) = \mathbf w \otimes \mathbf v. :This property is the reason that this matrix is referred to as the "swap operator" in the context of quantum information theory. * Two explicit forms for the commutation matrix are as follows: if e''r'',''j'' denotes the ''j''-th canonical vector of dimension ''r'' (i.e. the vector with 1 in the ''j''-th coordinate and 0 elsewhere) then ::\mathbf^ = \sum_^r \sum_^m \left(\mathbf_ ^\right) \otimes \left(\mathbf_ ^\right) = \sum_^r \sum_^m \left(\mathbf_ \otimes \mathbf_\right) \left( \mathbf_ \otimes \mathbf_\right)^ . * The commutation matrix may be expressed as the following block matrix: :: \mathbf^ = \begin \mathbf_ & \cdots & \mathbf_\\ \vdots & \ddots & \vdots\\ \mathbf_ & \cdots & \mathbf_, \end, :Where the ''p,q'' entry of ''n x m'' block-matrix K''i,j'' is given by :: \mathbf K_(p,q) = \begin 1 & i=q \text j = p,\\ 0 & \text. \end :For example, :: \mathbf K^ = \left[\begin 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0\\ \hline 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0\\ \hline 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1\end\right].


Code

For both square and rectangular matrices of m rows and n columns, the commutation matrix can be generated by the code below.


Python

import numpy as np def comm_mat(m, n): # determine permutation applied by K w = np.arange(m * n).reshape((m, n), order="F").T.ravel(order="F") # apply this permutation to the rows (i.e. to each column) of identity matrix and return result return np.eye(m * n) , : Alternatively, a version without imports: # Kronecker delta def delta(i, j): return int(i

j) def comm_mat(m, n): # determine permutation applied by K v = * j + i for i in range(m) for j in range(n) # apply this permutation to the rows (i.e. to each column) of identity matrix I = delta(i, j) for j in range(m * n)for i in range(m * n)] return [ifor_i_in_v.html" ;"title=".html" ;"title="[i">[ifor i in v">.html" ;"title="[i">[ifor i in v


MATLAB

function P = com_mat(m, n) % determine permutation applied by K A = reshape(1:m*n, m, n); v = reshape(A', 1, []); % apply this permutation to the rows (i.e. to each column) of identity matrix P = eye(m*n); P = P(v,:);


Example

Let A denote the following 3 \times 2 matrix: : A = \begin 1 & 4 \\ 2 & 5 \\ 3 & 6 \\ \end. A has the following column-major and row-major vectorizations (respectively): : \mathbf v_ = \operatorname(A) = \begin 1 \\ 2 \\ 3 \\ 4 \\ 5 \\ 6 \\ \end , \quad \mathbf v_ = \operatorname(A^) = \begin 1 \\ 4 \\ 2 \\ 5 \\ 3 \\ 6 \\ \end. The associated commutation matrix is : K = \mathbf K^ = \begin 1 & \cdot & \cdot & \cdot & \cdot & \cdot \\ \cdot & \cdot & \cdot & 1 & \cdot & \cdot \\ \cdot & 1 & \cdot & \cdot & \cdot & \cdot \\ \cdot & \cdot & \cdot & \cdot & 1 & \cdot \\ \cdot & \cdot & 1 & \cdot & \cdot & \cdot \\ \cdot & \cdot & \cdot & \cdot & \cdot & 1 \\ \end, (where each \cdot denotes a zero). As expected, the following holds: : K^\mathrm K = KK^\mathrm =\mathbf I_6 : K \mathbf v_ = \mathbf v_


References

* Jan R. Magnus and Heinz Neudecker (1988), ''Matrix Differential Calculus with Applications in Statistics and Econometrics'', Wiley. {{Matrix classes Linear algebra Matrices Articles with example Python (programming language) code Articles with example MATLAB/Octave code