Registered Member
|
Hello,
I'm currently trying to define a large matrix on the heap memory but it keeps on failing. My code looks like: int nodes_x_dir =500; int nodes_y_dir =500; int total_nodes =nodes_x_dir*nodes_y_dir; Eigen::MatrixXd * a = new Eigen::MatrixXd; (*a).resize(total_nodes,total_nodes); OR Eigen::MatrixXd * a = new Eigen::MatrixXd(total_nodes,total_nodes); I get the following on execution (it compiles okay): terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc The code works for small matrices - 50*50 but fails for large matrices. My objective is to use it for matrices of size 1000*1000. I'd appreciate some help. |
Moderator
|
You are trying to allocate 465 GB ! (= total_nodes* total_nodes*sizeof(double)). Maybe you meant:
MatrixXd * a = new MatrixXd(nodes_x_dir, nodes_y_dir); |
Registered Member
|
Thanks. My machine is running out of space.
Hadn't thought of that. |
Registered users: bartoloni, Bing [Bot], Google [Bot], Yahoo [Bot]