Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Arpack++ sparse eigen solver many times slower than equivalent Matlab eigs()

I need to compute the n smallest magnitude eigen vectors of a very large sparse symmetric matrix in a C++ program. For my example, lets say n=30 and the matrix is 10k by 10k with about 70k non-zero values.

Upon a lot of research and experimenting with some libraries I found that ARPACK++ would probably be my best bet, I installed it following the steps in this page.

The computation is made with the following snippet:

// L is an Eigen library matrix
L.makeCompressed();

ARluSymMatrix<MTYPE> A(L.cols(), L.nonZeros(), L.valuePtr(), L.innerIndexPtr(), L.outerIndexPtr(), 'U');

ARluSymStdEig<MTYPE> eig(n, A, "SM");

TIC
eig.FindEigenvectors();
TOC

which gets me the correct result but takes about 8.5 seconds, whereas in Matlab I can get the same result in about 0.5 seconds simply by calling

tic
[V,D] = eigs(L,30,'sm');
toc

From my reasearch on the topic Matlab eigs() also calls the ARPACK fortran libs for the same computations so I don't understand why is the C++ wrapper so much slower.

Also ARPACK++ behaves very strangely in many situations such as when I try to use floats instead of doubles the program will simply stop and do nothing till I take it down, or when trying to compute the eigenvectors around a value like 0 or 0.0001, which should be equivalent to 'SM', it simply spits out garbage and crashes.

Therefore my doubt is if ARPACK++ is really that slow or all of these are symptoms of some bad configuration/installation and if so what can I do to solve it. Thanks for any help you can provide.

like image 421
Likon Avatar asked Jul 31 '14 17:07

Likon


1 Answers

Even though this post is rather old I'd like to share my experience for using ARPACK and C++:

I needed ARPACK in my C++ project as well but I did not use the ARPACK++ package. Instead there is a really nice and still maintained Github-repo that is called arpack-ng which also makes all main routines for calculating extremal eigenvalues available via a C++ header file. It also includes the parallel version of ARPACK called PARPACK.

Check it out here: https://github.com/opencollab/arpack-ng

like image 143
T. Frank Avatar answered Sep 28 '22 01:09

T. Frank