scipy 1.8.0 Pypi GitHub Homepage
Other Docs
NotesParametersRaisesReturnsBackRef
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)

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]

Notes

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

Parameters

A : ndarray, sparse matrix or LinearOperator

An array, sparse matrix, or LinearOperator representing the operation A @ x , where A is a real or complex square matrix.

k : int, optional

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

M : ndarray, sparse matrix or LinearOperator, optional

An 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 if A is real, and must represent a complex Hermitian matrix if A is complex. For best results, the data type of M should be the same as that of A. Additionally:

If :None:None:`sigma` is None, M is positive definite

If sigma is specified, M is positive semi-definite

If sigma is 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, optional

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 : ndarray, optional

Starting vector for iteration. Default: random

ncv : int, optional

The number of Lanczos vectors generated ncv must be greater than k; it is recommended that ncv > 2*k . Default: min(n, max(2*k + 1, 20))

which : str, ['LM' | 'SM' | 'LR' | 'SR' | 'LI' | 'SI'], optional

Which k eigenvectors and eigenvalues to find:

maxiter : int, optional

Maximum number of Arnoldi update iterations allowed Default: n*10

tol : float, optional

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

return_eigenvectors : bool, optional

Return eigenvectors (True) in addition to eigenvalues

Minv : ndarray, sparse matrix or LinearOperator, optional

See notes in M, above.

OPinv : ndarray, sparse matrix or LinearOperator, optional

See notes in sigma, above.

OPpart : {'r' or 'i'}, optional

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.

Returns

w : ndarray

Array of k eigenvalues.

v : ndarray

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

Find k eigenvalues and eigenvectors of the square matrix A.

See Also

eigsh

eigenvalues and eigenvectors for symmetric matrix A

svds

singular value decomposition for a matrix A

Examples

Find 6 eigenvectors of the identity matrix:

>>> from scipy.sparse.linalg import eigs
... id = np.eye(13)
... vals, vecs = 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)
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

scipy.sparse.linalg._eigen.arpack.arpack.eigs scipy.sparse.linalg._eigen.arpack.arpack.eigsh

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /scipy/sparse/linalg/_eigen/arpack/arpack.py#1096
type: <class 'function'>
Commit: