# Matrix equation involving Kronecker product

I would like to know if exists an algorithm to find the solutions (if any) of the following matrix equation: $$A\otimes B=B\otimes A$$ in which the $N \times N$ matrix $B$ is given and the $A$ ($A\neq0$) is the unknown $N\times N$ matrix. The conditions on B are: $$B\neq 1, B\neq 0$$... Thanks.

-
$A=B$ is a solution. – Henning Makholm Jul 4 '12 at 10:47
@Henning Makholm: thanks. This is a trivial solution. Is it the only possible solution? – Riccardo.Alestra Jul 4 '12 at 10:59
Constant multiples of $A$ as well. – anon Jul 4 '12 at 11:02

$A=cB$ is a solution for any scalar $c$, but these are all the solutions as long as $B\ne0$.
As relevant here, the Kronecker product is just an outer product (since matrix multiplication is not relevant), so you can model the equation as $A (B^T) = B (A^T)$ which again boils down to a number of equations $a_ib_j=a_jb_i$ for all $i$ and $j$. From there it is easy to see that if there are nonzero entries anywhere, the two inputs must be related by a common proportionality constant.