[英]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.我一直在使用 Eigen 矩阵来测试我编写的新代码,我只是第一次遇到这个问题。 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;
nx; ny;
but not the case I am showing.但不是我展示的情况。 Ideally, I would like to run something as large as nx=1024;
理想情况下,我想运行像nx=1024;
这样大的东西。 and ny=1024;
并且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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.