I am currently writing software in c++ which solves the eigenvalue problem of sparse hermitian matrices. The size of the matrix depends on the user input, but as an estimation it will roughly be 1000x1000. I will have to solve about 300 (again relies on the user input) of them for different initial conditions. What is the fastest way to do it? More specifically, I would like to know if it makes sense to do the calculations on the GPU or would it be faster to do it on the CPU and use openMP for the 300 initial conditions? What c++ library would you suggest to use and why (maybe one has some easy build-in support for GPU)? Currently I am using eigen3 for dense matrices.

  • $\begingroup$ Do you want all the eigenvalues? If not, just a few percent or most of them? Do you want the corresponding eigenvectors as well? $\endgroup$
    – Ian Bush
    Commented Jan 18, 2016 at 12:17
  • $\begingroup$ I want just a few eigenvalues and the corresponding eigenvectors. But I need to specify what eigenvalues to take, e.g. the first few >0 and the first few <0. $\endgroup$
    – DaPhil
    Commented Jan 18, 2016 at 13:49
  • $\begingroup$ For dense matrices, LAPACK will be fastest regardless of how many eigenvalues you need (because that's not the bottleneck). These matrices are likely not large enough to offload to GPU if your CPU doesn't suck. For sparse, it's even less likely that offload pays off, unless your Krylov method needs a huge number of matrix-vector products and these run much faster on the GPU than the CPU. $\endgroup$ Commented Jan 19, 2016 at 6:56
  • $\begingroup$ @Jeff In the end I have sparse matrices. I only mentioned dense matrices to state that I am familiar with eigen3. In the case there is a way to use eigen for this... But you basically say do not use GPU for a sparse matrix of size 1e3x1e3. Is there a way to state some kind of border size? How big must a sparse matrix be so that it is beneficial to put it on a GPU? $\endgroup$
    – DaPhil
    Commented Jan 20, 2016 at 8:43

1 Answer 1


What is the fastest way to do it?

This very much depends on the form of the matrix. You can exploit symmetries to reduce your problem: Is the matrix symmetric or Hermitian? Is it banded or tridiagonal? Maybe it is even block-diagonal, then you can diagonalize the blocks independent of one another.

Also if you only need a few eigenvalues, then you probably want to use an iterative solver instead of doing a full diagonalization.

You probably want to take a look at this online resource:

It is a huge table listing a lot of linear algebra codes, their level of parallelism, supported matrix and datatypes and much more.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.