janmr blog

A Kronecker Product and Vec Operator Identity

Let AA be a q×nq \times n matrix and BB a p×mp \times m matrix. The Kronecker product ABA \otimes B is then a pq×nmpq \times nm matrix defined as

AB=[A11BA1nBAq1BAqnB]A \otimes B = \begin{bmatrix} A_{11} B & \cdots & A_{1n} B \\ \vdots & \ddots & \vdots \\ A_{q1} B & \cdots & A_{qn} B \end{bmatrix}

(AijA_{ij} denotes the element in the iith row and jjth column of AA).

Furthermore, the vec\operatorname{vec} operator is defined as stacking the columns of a matrix into a single column vector. For example, if XX is a m×nm \times n matrix, then vec(X)\operatorname{vec}(X) is a mn×1mn \times 1 column vector:

vec(X)=[X:,1X:,2X:,n],\operatorname{vec}(X) = \begin{bmatrix} X_{:,1} \\ X_{:,2} \\ \vdots \\ X_{:,n} \end{bmatrix},

where X:,kX_{:,k} denotes the kkth column of XX.

We will now prove the following identity:

(AB)vec(X)=vec(BXAT).(A \otimes B) \operatorname{vec}(X) = \operatorname{vec}(B X A^T).

First, we rewrite the kkth column of BXATB X A^T as

(BXAT):,k=BX(Ak,:)T=Bi=1nAk,iX:,i=[Ak,1B  Ak,2B    Ak,nB][X:,1X:,2X:,n]=(Ak,:B)vec(X)\begin{aligned} (B X A^T)_{:,k} &= B X (A_{k,:})^T = B \sum_{i=1}^n A_{k,i} X_{:,i} \\ &= \begin{bmatrix} A_{k,1} B \; A_{k,2} B \; \cdots \; A_{k,n} B \end{bmatrix} \begin{bmatrix} X_{:,1} \\ X_{:,2} \\ \vdots \\ X_{:,n} \end{bmatrix} \\ &= \big( A_{k,:} \otimes B \big) \operatorname{vec}(X) \end{aligned}

for k=1,,qk=1,\ldots,q.

Now we just need to assemble the result:

vec(BXAT)=[(BXAT):,1(BXAT):,2(BXAT):,q]=[A1,:BA2,:BAq,:B]vec(X)=(AB)vec(X).\operatorname{vec}(B X A^T) = \begin{bmatrix} (B X A^T)_{:,1} \\ (B X A^T)_{:,2} \\ \vdots \\ (B X A^T)_{:,q} \end{bmatrix} = \begin{bmatrix} A_{1,:} \otimes B \\ A_{2,:} \otimes B \\ \vdots \\ A_{q,:} \otimes B \end{bmatrix} \operatorname{vec}(X) = (A \otimes B) \operatorname{vec}(X).

A very cool result!

Note how the identity has some useful corollaries:

(InB)vec(X)=vec(BX)(I_n \otimes B) \operatorname{vec}(X) = \operatorname{vec}(B X)

and

(AIm)vec(X)=vec(XAT)(A \otimes I_m) \operatorname{vec}(X) = \operatorname{vec}(X A^T)

where InI_n and ImI_m are the identity matrices of size nn and mm, respectively.

In the paper The vec-permutation matrix, the vec operator and Kronecker products: a review, the authors point to the 1934 paper On direct product matrices by W. E. Roth as the origin of this identity. They also call the identity Roth's column lemma, although that name does not seem to be widely used.

Feel free to leave any question, correction or comment in this Mastodon thread.