I have a class that uses a dynamic Eigen::Matrix of doubles (i.e. Eigen::MatrixXd ), that has max rows and cols specified at compile time. During use, the dimensions may be less than the maximum. The purpose of specifying the max rows and cols is to avoid dynamic reallocation using the heap if the matrix size increases.
When I compile the code, I get an OBJECT_ALLOCATED_ON_STACK_IS_TOO_BIG error. I'm using Eigen 3.2 and VisualStudio 2017 with the default options and flags. This error occurs whether in Debug or Release mode. The Target arch is x64.
Here's the code (simplified):
class MyClass {
public:
MyClass();
~MyClass();
private:
// Create a member that is an Eigen::Matrix of doubles w/ dynamic sizing and max rows and cols
// at compile time = 1024.
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, 0, 1024, 1024 > x;
// Eigen::MatrixXd x(1024, 1024); // -- FAILS too!
};
What appears to be happening is that during the template expansion, the dynamic nature of the array declaration is ignored and the expansion thinks it is a static array which causes the size checking in Eigen::internal::check_static_allocation_size() to assert. I'm not sure why the dynamic flags/constants are being ignored.
Thanks,
--Mike