TITLE: $\text{vec}\left(A\otimes B\right)$ is not $\text{vec}\left(A\right) \otimes \text{vec}\left(B\right)$
QUESTION [7 upvotes]: Let $A$ and $B$ be two square matrices of dimension $a$ and $b$. $\text{vec}\left(\cdot\right)$ is the vectorization of a matrix.
Now $v_0=\text{vec}\left(A\otimes B\right)$ is not $v_1=\text{vec}\left(A\right) \otimes \text{vec}\left(B\right)$, but the set of vector elements in both is equal, but $v_0$ and $v_1$ seem to be related by a permutation of elements: $v_0 = P_{a,b} v_1$
Can this permutation matrix $P_{a,b}$ be described in general?

REPLY [3 votes]: Allow me state it generally:
Suppose A is a $m\times n$ matrix, and B is a $q\times p$ matrix. Then the following claim holds:
$vec (A \otimes B) = (I_n \otimes K_{qm} \otimes I_p)(vec(A)\otimes vec(B))$
The proof can be found in the book "Matrix Differential Calculus with Applications in Statistics and Econometrics" by MAGNUS and NEUDECKER, Chapter 3 Miscellaneous matrix results, Subsection 7 The commutation matrix. The e-book is free to download.
Here I give you one hint to prove this theorem: write A as the sum of two vectors, one of which is a basis $e_i=[0,...,0,1,0,...,0]^T$. So $A=\sum^n_{i=1}a_ie_i^T$, and similarly $B=\sum^q_{j=1}b_ju_j^T$, where $u_j$ is also a basis.
The rationale underlying such kind of proofs, I think, is the permutation matrix $P_{a,b}$ or $K_{qm}$ in the end can be splitted into the sum of basis products as well. Hence you actually operate linear algebras of some basis and rearrange them.
============================
To make this answer complete, here are snapshots of the theorem in that book: