Can eigen matrix solver use multi threads and how?

Deadly 提交于 2020-07-10 10:22:11

问题


When factorize a 34918 x 34918 sparse matrix, it takes about 1'20" to factorize it (only a few sec to build the sparse matrix). Can sparse matrix be factorized with multi threads? (visual studio)

Here is the code:

Eigen::SparseMatrix<double> laplacian(verticesNum, verticesNum);  
// reserve space for non-zero elements in sparse matrix
laplacian.reserve(Eigen::VectorXi::Constant(verticesNum, 20));
// build matrix operator
for (int i = 0; i < vertices->size(); i++) 
{
    // ... some algorithm 
}

// build solver for matrix
Eigen::SparseLU<Eigen::SparseMatrix<double>, Eigen::COLAMDOrdering<int>> solver; 

// tailor solver to matrix
solver.analyzePattern(laplacian);
solver.factorize(laplacian);

After stepped in, I found out the last line solver.factorize(laplacian) takes more than 1 min to execute. Can I use multi threads to fasten it?

Thank you!!

来源:https://stackoverflow.com/questions/62386137/can-eigen-matrix-solver-use-multi-threads-and-how

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!