【发布时间】:2016-10-04 11:10:20
【问题描述】:
我尝试使用犰狳库解决稀疏线性系统。
#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。当系统系统用spsolvesee here中的LAPACK选项解决时,运行时间为4.01 seconds。谁能解释一下原因:
- 用 SuperLu 解决相同的方程组比 LAPACK 需要更长的时间? 我的预感是他们可能使用不同的算法来解决稀疏线性系统。欢迎任何其他想法!
编辑:我在 Ubuntu 14.04 上运行 export OPENBLAS_NUM_THREADS=4。
【问题讨论】:
标签: c++11 lapack armadillo blas