I have an NxN symmetric and tridiagonal matrix computed by a Python code and I want to diagonalize it.
In the specific case I'm dealing with N = 6000, but the matrix can become larger. Since it is sparse, I assumed the best way to diagonalize it was to use the algorithm scipy.sparse.linalg.eigsh(), which performed extremely good with other sparse and symmetric matrices (not tridiagonal ones, though) I worked with. In particular, since I need only the low lying part of the spectrum, I'm specifying k=2 and which='SM' in the function.
However, in this case this algorithm seems not to work, since after approximately 20 minutes of computation I get the following error:
ArpackNoConvergence: ARPACK error -1: No convergence (60001 iterations, 0/2 eigenvectors converged)
Why is this happening? Is it a problem related to some properties of tridiagonal matrices? Which Python (and please, only Python!) routine can I use in order to diagonalize my matrix in an efficient way?
Here's the requested minimal code to reproduce my error:
import scipy.sparse.linalg as sl
import numpy as np
dim = 6000
a = np.empty( dim - 1 )
a.fill( 1. )
diag_up = np.diag( a, 1 )
diag_bot = np.diag( a, -1 )
b = np.empty( dim )
b.fill( 1. )
mat = np.diag( b ) + diag_up + diag_bot
v, w = sl.eigsh(mat, 2, which = 'SM')
On my pc the construction of the matrix takes 364ms, while the diagonalization gives the reported error.