I'm using Eigen to write some C++ linear algebra code. I've got to manipulate some not-so-small matrices (greater than 4x4, but smaller than 50x50, if that matters), whose sizes are all entirely known at compile time.
I would love to benefit from the compile-time size checks that Eigen library can perform around matrix operations, which trigger an error whenever, say, a sum between different-size matrices happens in the code, however I'm also scared about the possible abuse of the stack that I could make if I don't dinamically allocate those relatively big objects. Performance concerns doesn't bother me.
The Eigen documentation has a brief paragraph about fixed and dynamic size matrices, where my previous concerns are discussed, but unfortunately there is no emphasys on the compile time checks which I would love to maintain. The documentation suggests:
Use fixed sizes for very small sizes where you can, and use dynamic sizes for larger sizes or where you have to.
In the end, my question: is there a way in Eigen to have a dynamically allocated Matrix with compile-time known size, in a way to retain the usual compile-time checks that we have for standard fixed-size matrices?
Something like this:
using MyMatrix = MatrixXd<12, 15>; // Currently I can only do Matrix<double, 12, 15>
using MyVector = MatrixXd<14, 1>;
MyMatrix M;
MyVector v;
auto w = M * v; // This should trigger an INVALID_MATRIX_PRODUCT error
where MatrixXd<n, m>
is the hypothetical dynamically allocated, compile-time known size matrix I would like to use!
Options
template parameter) – chtz