Registered Member
|
I test SparseMatrix with eigen, it seem that when i new a 10*5billion SparseMatrix which include only a few nonzeros elements, it takes 50gb memory!
The demo code:
|
Moderator
|
Look at how sparse matrices are stored [1] to understand that in your case it needs to allocate an array of 5000000000 long int. In your case, simply use a RowMajor layout:
typedef Eigen::SparseMatrix<double, RowMajor, long int> SMatrixXd; and the previous huge array will boil down to an array of 10 long int. [1] http://eigen.tuxfamily.org/dox/group__T ... tml#title0 |
Registered Member
|
I change the code and then multi two matrix like that:
if i use mat* weight, the code will be fast and low memory, but if we use DVectorXd result = mat*weight, it will take long time and huge memory(20gb). |
Moderator
|
ok, the problem is that to compute matrix*weight, matrix have to be converted to column-major one, so you're back to the initial problem. You need either an hyper-sparse matrix (not available in Eigen but there are implementation in this forum), or work a bit on your side to completely remove empty columns.
|
Registered users: Bing [Bot], Google [Bot], Sogou [Bot]