Reply to topic

Improve DynamicSparseMatrix performance for many entries

MrMage
Registered Member
Posts
10
Karma
0
Hi,

I'm working on panel-clustering methods where the problem's near field can be stored in large sparse matrices. Unfortunately, those matrices can still require about 1500 non-zero entries per row, which significantly degrades the performance of DynamicSparseMatrix (as stated in the headers, too). When I tried to use the SparseMatrix class, performance seemed to be even worse (but maybe I just used it in an incorrect way). Could you advise on how I could improve the performance of DynamicSparseMatrix or use SparseMatrix with optimal performance instead? If this helps, I am able precompute the sparsity pattern in order to achieve a specific order to fill the matrix entries.

Best and thanks in advance,

Daniel
User avatar ggael
Moderator
Posts
2195
Karma
15
OS
The best is to use SparseMatrix (because DynamicSparseMatrix is "unsupported"). The simplest way to get good perf. is to follow the recommandation of the tutorial that is to use a std::vector<Triplet<..> > and let SparseMatrix::setFromTriplets does the job. Otherwise, you could compute the exact number of non-zeros per inner-vector, store them into a std::vector<int> or Eigen::VectorXi, and call mat.resize(this_vector); to preallocate room for each inner vector. Then calling mat.insert(i,j) with increasing inner indices per outer-vector should be optimally fast.

 
Reply to topic

Bookmarks



Who is online

Registered users: AElfwine, anditosan, Baidu [Spider], bcooksley, Bing [Bot], doublerainbow64, Exabot [Bot], Google [Bot], google01103, hefeweiz3n, inksi, jensreuterberg, kainz.a, koriun, l3u, moisachedaniela, Paulms, pbCyanide, raphaelpoli, scummos, SecretCode, Sentynel, toad, tparrott, Yahoo [Bot]