user498036
user498036

Reputation: 21

Can I have Eigen::VectorXd with size larger than the size limit (2^32)?

I'm try to initialize a VectorXd with a size 60,000,000,000. When running my software, I get the following error because of the Vector size.

Any recommendation to solve the problem?

a.out: /usr/local/EasyBuild/software/Eigen/3.3.3-intel-2018a/include/Eigen/src/Core/PlainObjectBase.h:312: void Eigen::PlainObjectBase::resize(Eigen::Index) [with Derived = Eigen::Matrix; Eigen::Index = long int]: Assertion `((SizeAtCompileTime == Dynamic && (MaxSizeAtCompileTime==Dynamic || size<=MaxSizeAtCompileTime)) || SizeAtCompileTime == size) && size>=0' failed. Aborted (core dumped)

Upvotes: 0

Views: 596

Answers (1)

PeterT
PeterT

Reputation: 8284

The value "Dynamic" is defined in Core/util/Constants.h to be

//Changing the value of Dynamic breaks the ABI, as Dynamic is often used as a template parameter for Matrix.
const int Dynamic = -1;

So you might get rid of the specific assertion by redefining it as a larger type such as

const long Dynamic = -1;

However, the template arguments are specified as int all over Eigen, so you might need to change it in a lot of places. Also, you should take note of the comment above. You'll need to make sure to compile everything that you link against with the same patched Eigen version.

Also, you'll need an unreasonable amount of RAM or swap space to make that program run.

Upvotes: 0

Related Questions