I am using Eigen for a project I am working on, where runtime performance is absolutely crucial (needs to meet real-time constraints).
So far, Eigen gives me reasonably good performance. However, I need to evaluate a Kronecker product. I am using Eigen's unsupported KroneckerProduct module, but I am thinking it is suboptimal for my needs.
The two matrices I am computing the Kronecker product with are of fixed size (known at compile time), and structure. One matrix is square and diagonal, let's assume it is an Identity matrix. The other is a small, square matrix. In code, like this:
MatrixXf I = MatrixXf::Identity(4,4);
MatrixXf X = MatrixXf::Random(8,8);
MatrixXf P = kroneckerProduct(I,X);
Since I is diagonal, I am guessing that we can make this faster since we only need to evaluate 4 matrix by scalar multiplications in order to compute all of the elements (since many will be zero).
What is the fastest and most efficient way to do this with Eigen?