This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Eigen matrices on heap memory

Tags: None
(comma "," separated)
godfreyg
Registered Member
Posts
3
Karma
0

Eigen matrices on heap memory

Sun Jul 12, 2015 7:04 pm
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.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
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);
godfreyg
Registered Member
Posts
3
Karma
0

Re: Eigen matrices on heap memory

Sun Jul 12, 2015 9:21 pm
Thanks. My machine is running out of space.

Hadn't thought of that. ;D


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Google [Bot], Yahoo [Bot]