我想解决C++中非常大且稀疏的线性方程组系统。目前,我从eigen使用BiCGSTAB。它适用于小矩阵,但它需要的时间太长,我需要的矩阵大小为40804x40804(未来可能会更大)。C++如何解决非常大的稀疏线性系统系统
我有一个很长的脚本,但我只是用的格式如下:
SparseMatrix<double> sj(40804,40804);
VectorXd c_(40804), sf(40804);
sj.reserve(VectorXi::Constant(40804,36)); //This is a very good estimate of how many non zeros in each column
//...Fill in actual number in sj
sj.makeCompressed();
BiCGSTAB<SparseMatrix<double> > handler;
//...Fill in sj, only in the entries that have been initialized previously
handler.analyzePattern(sj)
handler.factorize(sj);
c_.setZero();
c_=handler.solve(sf);
这需要的时间太长了!是的,该解决方案确实存在。 matlab中的稀疏函数似乎很好地处理了这个问题,但我需要在C++中才能连接到服务器。
我真的很感激你可以帮助我!
如果MATLAB做的做好你为什么不使用它在C++。 [链接](https://www.mathworks.com/help/matlab/matlab_external/calling-matlab-software-from-ac-application.html) – Logman
如果连接到服务器是至关重要的,也许你应该尝试使用pari/gp ... – jaroslawj
确保在编译器优化ON的情况下进行编译,然后您可以尝试直接求解像'Eigen :: SparseLU'(只需用'SparseLU'替换BiCGSTAB')或使用'IncompleteLUT'预处理程序在BICGSTAB。 – ggael