numpy.linalg.eigvals#

linalg.eigvals(a)[source]#

Compute the eigenvalues of a general matrix.

Main difference betweeneigvals andeig: the eigenvectors aren’treturned.

Parameters:
a(…, M, M) array_like

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

Returns:
w(…, M,) ndarray

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

Raises:
LinAlgError

If the eigenvalue computation does not converge.

See also

eig

eigenvalues and right eigenvectors of general arrays

eigvalsh

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

eigh

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

scipy.linalg.eigvals

Similar function in SciPy.

Notes

Broadcasting rules apply, see thenumpy.linalg documentation fordetails.

This is implemented using the_geev LAPACK routines which computethe eigenvalues and eigenvectors of general square arrays.

Examples

Illustration, using the fact that the eigenvalues of a diagonal matrixare its diagonal elements, that multiplying a matrix on the leftby an orthogonal matrix,Q, and on the right byQ.T (the transposeofQ), preserves the eigenvalues of the “middle” matrix. In other words,ifQ is orthogonal, thenQ*A*Q.T has the same eigenvalues asA:

>>>importnumpyasnp>>>fromnumpyimportlinalgasLA>>>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 byQ on one side andbyQ.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
On this page