Kronecker Product for Matrices with Special Structure Using LinearOperators
I have been working with very large matrices for my research lately, and some of them are sparse, while others are dense but have some special structure that can be exploited to represent them efficiently. I have also been constructing enormous matrices from these smaller building blocks using the Kronecker product. Both numpy and scipy have functions built in to compute the Kronecker product between two matrices, but they need the input matrices to be explicitly represented (as a dense numpy array or a sparse scipy matrix), and so they are not compatible with the special-structure matrices that I've been dealing with. I recently solved this problem, and that is the topic of this blog post. An Example As an example to make things more concrete, consider the two matrices shown below: $$ A = \begin{bmatrix} 1 & 1 & 1 \\ 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix} \qquad B = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 1 & 1 &