简体   繁体   中英

Error using large Eigen matrix: " OBJECT_ALLOCATED_ON_STACK_IS_TOO_BIG"

I have been using Eigen matrices to test a new code I wrote, and I just ran into this issue for the first time. I just started reading about "Fixed vs. Dynamic size" in Eigen matrices and I thought I was using "dynamic" matrices for large sizes, but when I try using larger number of grids I get the error:

 static assertion failed: OBJECT_ALLOCATED_ON_STACK_IS_TOO_BIG

Example code:

static const int nx = 128;
static const int ny = 128; 

using namespace std;
using namespace Eigen;

int main(){
Eigen::Matrix<double, (ny+1), nx> X; //ERROR HERE
X.setZero();
//other similar initializations 

}

This code is running fine for smaller sizes of nx; ny; nx; ny; but not the case I am showing. Ideally, I would like to run something as large as nx=1024; and ny=1024; Is this not possible using Eigen matrices? Thanks.

As people pointed out in the comments, using the following fixes the issue:

Eigen::MatrixXd

or

Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM