scipy.sparse.linalg.eigs

scipy.sparse.linalg.eigs(A, k=6, M=None, sigma=None, which='LM', v0=None, ncv=None, maxiter=None, tol=0, return_eigenvectors=True, Minv=None, OPinv=None, OPpart=None)

Find k eigenvalues and eigenvectors of the square matrix A.

Solves A * x[i] = w[i] * x[i], the standard eigenvalue problem for w[i] eigenvalues with corresponding eigenvectors x[i].

If M is specified, solves A * x[i] = w[i] * M * x[i], the generalized eigenvalue problem for w[i] eigenvalues with corresponding eigenvectors x[i]

Parameters :

A : An N x N matrix, array, sparse matrix, or LinearOperator representing

the operation A * x, where A is a real or complex square matrix.

k : integer

The number of eigenvalues and eigenvectors desired. k must be smaller than N. It is not possible to compute all eigenvectors of a matrix.

Returns :

w : array

Array of k eigenvalues.

v : array

An array of k eigenvectors. v[:, i] is the eigenvector corresponding to the eigenvalue w[i].

Other Parameters:
 

M : An N x N matrix, array, sparse matrix, or LinearOperator representing

the operation M*x for the generalized eigenvalue problem

A * x = w * M * x

M must represent a real symmetric matrix. For best results, M should be of the same type as A. Additionally:

  • If sigma==None, M is positive definite
  • If sigma is specified, M is positive semi-definite

If sigma==None, eigs requires an operator to compute the solution of the linear equation M * x = b. This is done internally via a (sparse) LU decomposition for an explicit matrix M, or via an iterative solver for a general linear operator. Alternatively, the user can supply the matrix or operator Minv, which gives x = Minv * b = M^-1 * b

sigma : real or complex

Find eigenvalues near sigma using shift-invert mode. This requires an operator to compute the solution of the linear system [A - sigma * M] * x = b, where M is the identity matrix if unspecified. This is computed internally via a (sparse) LU decomposition for explicit matrices A & M, or via an iterative solver if either A or M is a general linear operator. Alternatively, the user can supply the matrix or operator OPinv, which gives x = OPinv * b = [A - sigma * M]^-1 * b. For a real matrix A, shift-invert can either be done in imaginary mode or real mode, specified by the parameter OPpart (‘r’ or ‘i’). Note that when sigma is specified, the keyword ‘which’ (below) refers to the shifted eigenvalues w’[i] where:

  • If A is real and OPpart == ‘r’ (default),

    w’[i] = 1/2 * [ 1/(w[i]-sigma) + 1/(w[i]-conj(sigma)) ]

  • If A is real and OPpart == ‘i’,

    w’[i] = 1/2i * [ 1/(w[i]-sigma) - 1/(w[i]-conj(sigma)) ]

  • If A is complex,

    w’[i] = 1/(w[i]-sigma)

v0 : array

Starting vector for iteration.

ncv : integer

The number of Lanczos vectors generated ncv must be greater than k; it is recommended that ncv > 2*k.

which : string [‘LM’ | ‘SM’ | ‘LR’ | ‘SR’ | ‘LI’ | ‘SI’]

Which k eigenvectors and eigenvalues to find:
  • ‘LM’ : largest magnitude
  • ‘SM’ : smallest magnitude
  • ‘LR’ : largest real part
  • ‘SR’ : smallest real part
  • ‘LI’ : largest imaginary part
  • ‘SI’ : smallest imaginary part

When sigma != None, ‘which’ refers to the shifted eigenvalues w’[i] (see discussion in ‘sigma’, above). ARPACK is generally better at finding large values than small values. If small eigenvalues are desired, consider using shift-invert mode for better performance.

maxiter : integer

Maximum number of Arnoldi update iterations allowed

tol : float

Relative accuracy for eigenvalues (stopping criterion) The default value of 0 implies machine precision.

return_eigenvectors : boolean

Return eigenvectors (True) in addition to eigenvalues

Minv : N x N matrix, array, sparse matrix, or linear operator

See notes in M, above.

OPinv : N x N matrix, array, sparse matrix, or linear operator

See notes in sigma, above.

OPpart : ‘r’ or ‘i’.

See notes in sigma, above

Raises :

ArpackNoConvergence :

When the requested convergence is not obtained.

The currently converged eigenvalues and eigenvectors can be found as eigenvalues and eigenvectors attributes of the exception object.

See also

eigsh
eigenvalues and eigenvectors for symmetric matrix A
svds
singular value decomposition for a matrix A

Notes

This function is a wrapper to the ARPACK [R59] SNEUPD, DNEUPD, CNEUPD, ZNEUPD, functions which use the Implicitly Restarted Arnoldi Method to find the eigenvalues and eigenvectors [R60].

References

[R59](1, 2) ARPACK Software, http://www.caam.rice.edu/software/ARPACK/
[R60](1, 2) R. B. Lehoucq, D. C. Sorensen, and C. Yang, ARPACK USERS GUIDE: Solution of Large Scale Eigenvalue Problems by Implicitly Restarted Arnoldi Methods. SIAM, Philadelphia, PA, 1998.

Examples

Find 6 eigenvectors of the identity matrix:

>>> id = np.identity(13)
>>> vals, vecs = sp.sparse.linalg.eigs(id, k=6)
>>> vals
array([ 1.+0.j,  1.+0.j,  1.+0.j,  1.+0.j,  1.+0.j,  1.+0.j])
>>> vecs.shape
(13, 6)

Previous topic

scipy.sparse.linalg.lsqr

Next topic

scipy.sparse.linalg.eigsh

This Page