Kronecker Product

The Kronecker product is a mathematical tool for enumerating all possible combinations of elements. It is useful for many combinatorial problems, such as the Traveling Salesman Problem.

The Kronecker product $\otimes$ is defined as follows.

For $A$ $=$ $\begin{pmatrix}A_{1,1} & A_{1,2} & \cdots & A_{1,n}\\ A_{2,1} & A_{2,2} & \cdots & A_{2,n}\\ \vdots & \vdots & \ddots & \vdots\\ A_{m,1} & A_{m,2} & \cdots & A_{m,n}\\ \end{pmatrix}$, $B$ $=$ $\begin{pmatrix}B_{1,1} & B_{1,2} & \cdots & B_{1,p}\\ B_{2,1} & B_{2,2} & \cdots & B_{2,p}\\ \vdots & \vdots & \ddots & \vdots\\ B_{q,1} & B_{q,2} & \cdots & B_{q,p}\\ \end{pmatrix}$,

$A \otimes B$ $=$ $\begin{pmatrix}A_{1,1}B & A_{1,2}B & \cdots & A_{1,n}B\\ A_{2,1}B & A_{2,2}B & \cdots & A_{2,n}B\\ \vdots & \vdots & \ddots & \vdots\\ A_{m,1}B & A_{m,2}B & \cdots & A_{m,n}B\\ \end{pmatrix}$ $=$ $\begin{pmatrix}A_{1,1}B_{1,1} & A_{1,1}B_{1,2} & \cdots & A_{1,1}B_{1,p} & A_{1,2}B_{1,1} & A_{1,2}B_{1,2} & \cdots & A_{1,2}B_{1,p} & A_{1,3}B_{1,1} & \cdots & A_{1,n}B_{1,p}\\ A_{1,1}B_{2,1} & A_{1,1}B_{2,2} & \cdots & A_{1,1}B_{2,p} & A_{1,2}B_{2,1} & A_{1,2}B_{2,2} & \cdots & A_{1,2}B_{2,p} & A_{1,3}B_{2,1} & \cdots & A_{1,n}B_{2,p}\\ \vdots & \vdots & \ddots & \vdots & \vdots & \vdots & \ddots & \vdots & \vdots & \ddots & \vdots \\ A_{1,1}B_{q,1} & A_{1,1}B_{q,2} & \cdots & A_{1,1}B_{q,p} & A_{1,2}B_{q,1} & A_{1,2}B_{q,2} & \cdots & A_{1,2}B_{q,p} & A_{1,3}B_{q,1} & \cdots & A_{1,n}B_{q,p}\\ A_{2,1}B_{1,1} & A_{2,1}B_{1,2} & \cdots & A_{2,1}B_{1,p} & A_{2,2}B_{1,1} & A_{2,2}B_{1,2} & \cdots & A_{2,2}B_{1,p} & A_{2,3}B_{1,1} & \cdots & A_{2,n}B_{1,p}\\ A_{2,1}B_{2,1} & A_{2,1}B_{2,2} & \cdots & A_{2,1}B_{2,p} & A_{2,2}B_{2,1} & A_{2,2}B_{2,2} & \cdots & A_{2,2}B_{2,p} & A_{2,3}B_{2,1} & \cdots & A_{2,n}B_{2,p}\\ \vdots & \vdots & \ddots & \vdots & \vdots & \vdots & \ddots & \vdots & \vdots & \ddots & \vdots \\ A_{2,1}B_{q,1} & A_{2,1}B_{q,2} & \cdots & A_{2,1}B_{q,p} & A_{2,2}B_{q,1} & A_{2,2}B_{q,2} & \cdots & A_{2,2}B_{q,p} & A_{2,3}B_{q,1} & \cdots & A_{2,n}B_{q,p}\\ \vdots & \vdots & \ddots & \vdots & \vdots & \vdots & \ddots & \vdots & \vdots & \ddots & \vdots \\ A_{m,1}B_{q,1} & A_{m,1}B_{q,2} & \cdots & A_{m,1}B_{q,p} & A_{m,2}B_{q,1} & A_{m,2}B_{q,2} & \cdots & A_{m,2}B_{q,p} & A_{m,3}B_{q,1} & \cdots & A_{m,n}B_{q,p}\\ \end{pmatrix}$.

Note that this operation is naturally recursive, as it places scaled copies of $B$ into each submatrix.