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

Simone Bolognini simo.bolognini at gmail.com
Fri Sep 22 03:52:09 EDT 2017


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 slimport 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-user/attachments/20170922/88330b82/attachment-0001.html>


More information about the SciPy-User mailing list