Largest eigenvalues ​​(and corresponding eigenvectors) in C ++

What is the easiest and fastest way (with some library, of course) to compute the k largest eigenvalues ​​and eigenvectors for a large dense matrix in C ++? I am looking for the equivalent function of MATLAB eigs ; I looked through Armadillo and Eigen, but could not find it, and all eigenvalues ​​are calculated forever in my case (I need the first 10 eigenvectors for a dense asymmetric real matrix of size 30000x30000).

Desperate, I even tried to implement force iterations on my own with the QR Armadillo decomposition, but ran into complex pairs of eigenvalues ​​and gave up. :)

+3
source share
3 answers

AFAIK, the problem of finding the first k eigenvalues ​​of a common matrix does not have a simple solution. The Matlab eigs feature you talked about should work with sparse matrices.

Matlab probably uses Arnoldi / Lanczos, you can try if it works decently in your case, even if your matrix is ​​not sparse. The reference package for Arnlodi is ARPACK , which has a C ++ interface.

+1
source

Have you tried https://github.com/yixuan/spectra ? It is similar to ARPACK, but with a beautiful Eigen-like interface (it is compatible with Eigen!)

I used it for 30kx30k matrices (PCA) and that was pretty good

+1
source

Eigen has an EigenValues module that works very well .. But I never used it for anything more than big.

0
source

Source: https://habr.com/ru/post/1012657/


All Articles