Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Generate a commutation matrix
ResourceFunction["CommutationMatrix"][m,n] returns the commutation matrix . |
A commutation matrix:
In[1]:= | ![]() |
Out[1]= | ![]() |
Visualize the commutation matrix:
In[2]:= | ![]() |
Out[2]= | ![]() |
Return the commutation matrix as a dense matrix:
In[3]:= | ![]() |
Out[3]= | ![]() |
Return the commutation matrix as a structured array:
In[4]:= | ![]() |
Out[4]= | ![]() |
Return the commutation matrix as a sparse array:
In[5]:= | ![]() |
Out[5]= | ![]() |
Specify the working precision for the commutation matrix:
In[6]:= | ![]() |
Out[6]= | ![]() |
The normal representation returns a full matrix with finite precision elements:
In[7]:= | ![]() |
Out[7]= | ![]() |
The commutation matrix is orthogonal, i.e. the inverse is equal to the transpose:
In[8]:= | ![]() |
Out[10]= | ![]() |
The inverse of CommutationMatrix[p,q] is given by CommutationMatrix[q,p]:
In[11]:= | ![]() |
Out[12]= | ![]() |
Define the vec operator, which stacks the columns of a matrix into a single vector:
In[13]:= | ![]() |
The commutation matrix relates the result of applying the vec operator to a matrix and its transpose:
In[14]:= | ![]() |
Out[15]= | ![]() |
The commutation 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:
In[16]:= | ![]() |
Out[17]= | ![]() |
The commutation matrix can be expressed as a sum of Kronecker products of an identity matrix with unit vectors:
In[18]:= | ![]() |
Out[19]= | ![]() |
Wolfram Language 13.1 (June 2022) or above
This work is licensed under a Creative Commons Attribution 4.0 International License