0
我试图使用犰狳库来求解稀疏线性系统。使用LAPACK和SuperLU的犰狳线性稀疏系统求解器
#include <iostream>
#include<armadillo>
using namespace std;
using namespace arma;
int main(int argc, char** argv) {
int no_examples = 5000;
sp_mat A = sprandu<sp_mat>(no_examples,no_examples,0.7);
vec b = randu<vec>(no_examples);
wall_clock timer;
double t;
timer.tic();
vec x1 = spsolve(A, b,"superlu");
t= timer.toc();
cout<<"Elapsed time is:"<<t<<endl;
}
我使用g++ demo.cpp -O3 -I/usr/include/armadillo_bits -DARMA_DONT_USE_WRAPPER -lsuperlu -lopenblas -llapack
编译程序。使用superlu
选件获得的运行时间约为8.5 seconds
。当在spsolve
see here中用LAPACK
选项解决系统系统时,运行时间为4.01 seconds
。有人可以解释为什么:
- 解决方案相同的系统需要比LAPACK更长的SuperLu? 我的直觉是他们可能会使用不同的算法来解决稀疏线性系统。欢迎任何其他想法!
编辑︰我运行在Ubuntu 14.04 export OPENBLAS_NUM_THREADS=4
。
我在[0,.7]中改变了密度,但结果是一样的。 SuperLU需要比LAPACK的密集LU分解更长的时间。 – chandresh
@chandresh这很奇怪。 SuperLU时间不会改变?尝试使用矩阵大小10,000。 – ztik
与上面相同的结论。 – chandresh