Eigenvalue solving by lobpcg in Python

Scipy provides two sets of functions for solving eigenvalue problems:
  1. ARPACK-wrapped scipy.sparse.linalg.eigsh and scipy.sparse.linalg.eigs, and 
  2. LOBPCG-based scipy.sparse.linalg.lobpcg
The latter is new to me. However I notice something interesting.

First, the option largest= seems to work in the opposite way. If I set is as largest=False, I actually get largest eigenvalues. To get smallest eigenvalues, I set it as largest=True.

Second, the function requires an initial approximation to the eigenvectors, which is not easy for new users. As someone pointed out, sometimes it takes "a very large number of iterations to get the correct eigenvalues."

Nevertheless, the solver is not too bad compared with ARPACK-wrapped eigsh (for real symmetric square matrix or complex hermitian matrixes) and eigs (for non-symmetric square matrixes). For example, given two matrixes, I got the two eigenvalues for general eigenvalue problem:
  • by eigsh: [-1.0385276515935676e-16, 0.9194804029047039, 3.7579933101613547, 8.257545329015041, 10.44664798242384]
  • by lobpcg: [7.0329601669327232e-16, 0.91948040290470379, 3.7579933101613623, 8.2575453290150449, 10.446647982423839]

1 comment:

Timmy said...

This is cool!