This is a query regarding the c++ Eigen library.
In my calculation, I frequently come across matrices with a block diagonal form. A simple example of the structure is below.
Matrix6f M = Matrix6f::Zero(); //< M has a special structure
M.block<3, 3,>(0, 0) = Matrix3f::Random();
M.block<3, 3,>(3, 3) = Matrix3f::Random();
Matrix6f out = M * Matrix6f::Random(); //< Want to optimize this operation
Now, lets say I have a dense 6x6 matrix I and need to evaluate the product M*I, is there any way I can avoid having to perform redundant multiplications/additions with all the zeros that are there in M. Short of writing out the multiplication explicitly that is.
Eigen has this neat feature where if I do an auto u = v + w, I just get an operator without an actual evaluation. This also appears to work with auto z = Matrix6f::Zero() and if I ever did a Matrix6f out = z + Matrix6f::Random(), I could imagine writing an operator on the special Zero matrix so that I effectively just return the elements of the random matrix without attempting to add a zero to it.
Is something like this possible for the specific example I have list above?