# [SciPy-User] Diagonalization of a tridiagonal, symmetric, sparse matrix with scipy.sparse.linalg.eigsh() Classic List Threaded 3 messages Open this post in threaded view
|

## [SciPy-User] Diagonalization of a tridiagonal, symmetric, sparse matrix with scipy.sparse.linalg.eigsh()

 Hi everyone! Here's my problem.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? What other scipy routine can I use in order to diagonalize my matrix in an efficient way?Here's a 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 mat takes 364ms, while only the last line in which the diagonalization is performed gives the reported error.Thanks a lot for the support.Simone _______________________________________________ SciPy-User mailing list [hidden email] https://mail.python.org/mailman/listinfo/scipy-user