# Permute the factors of a Kronecker product

Let two matrices $$A$$ and $$B$$ of size $$m\times n$$ and $$p \times q$$, respectively.

What is the expression of two matrices $$F$$ and $$G$$ such that $$A \otimes B = F ( B \otimes A ) G$$?

The matrices $$F$$ and $$G$$ are called commutation matrices. A commutation matrix $$K_{m,n}$$ is the unique permutation matrix that satisfies $$K_{m,n} \cdot {\rm vec}\{X\} = {\rm vec}\{X^T\}$$ for any $$X$$ of size $$m \times n$$, where $${\rm vec}\{\cdot\}$$ is the vectorization operator that stacks $$X$$ into a vector (column by column). These commutation matrices can be used to permute Kronecker products. They satisfy $$K_{m,p}^T \cdot(A \otimes B) \cdot K_{n,q} = B \otimes A,$$ where $$A$$ and $$B$$ are $$m \times n$$ and $$p\times q$$. Hence, your $$F$$ is $$K_{m,p}$$ and your $$G$$ is $$K_{n,q}^T$$. You can find a lot more details and properties about these matrices in [MN79, MN95].