numpy 1.22.4 Pypi GitHub Homepage
Other Docs
NotesParametersRaisesReturnsBackRef
eigvals(a)

Main difference between eigvals and eig : the eigenvectors aren't returned.

Notes

versionadded

Broadcasting rules apply, see the numpy.linalg documentation for details.

This is implemented using the _geev LAPACK routines which compute the eigenvalues and eigenvectors of general square arrays.

Parameters

a : (..., M, M) array_like

A complex- or real-valued matrix whose eigenvalues will be computed.

Raises

LinAlgError

If the eigenvalue computation does not converge.

Returns

w : (..., M,) ndarray

The eigenvalues, each repeated according to its multiplicity. They are not necessarily ordered, nor are they necessarily real for real matrices.

Compute the eigenvalues of a general matrix.

See Also

eig

eigenvalues and right eigenvectors of general arrays

eigh

eigenvalues and eigenvectors of real symmetric or complex Hermitian (conjugate symmetric) arrays.

eigvalsh

eigenvalues of real symmetric or complex Hermitian (conjugate symmetric) arrays.

scipy.linalg.eigvals

Similar function in SciPy.

Examples

Illustration, using the fact that the eigenvalues of a diagonal matrix are its diagonal elements, that multiplying a matrix on the left by an orthogonal matrix, :None:None:`Q`, and on the right by :None:None:`Q.T` (the transpose of :None:None:`Q`), preserves the eigenvalues of the "middle" matrix. In other words, if :None:None:`Q` is orthogonal, then Q * A * Q.T has the same eigenvalues as A :

>>> from numpy import linalg as LA
... x = np.random.random()
... Q = np.array([[np.cos(x), -np.sin(x)], [np.sin(x), np.cos(x)]])
... LA.norm(Q[0, :]), LA.norm(Q[1, :]), np.dot(Q[0, :],Q[1, :]) (1.0, 1.0, 0.0)

Now multiply a diagonal matrix by Q on one side and by Q.T on the other:

>>> D = np.diag((-1,1))
... LA.eigvals(D) array([-1., 1.])
>>> A = np.dot(Q, D)
... A = np.dot(A, Q.T)
... LA.eigvals(A) array([ 1., -1.]) # random
See :

Back References

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

numpy.linalg.eigvals numpy.linalg.eigvalsh numpy.linalg.eigh numpy.linalg.eig

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 : /numpy/linalg/linalg.py#976
type: <class 'function'>
Commit: