Movatterモバイル変換


[0]ホーム

URL:


SciPy

numpy.linalg.eig

numpy.linalg.eig(a)[source]

Compute the eigenvalues and right eigenvectors of a square array.

Parameters:

a : (..., M, M) array

Matrices for which the eigenvalues and right eigenvectors willbe computed

Returns:

w : (..., M) array

The eigenvalues, each repeated according to its multiplicity.The eigenvalues are not necessarily ordered. The resultingarray will be of complex type, unless the imaginary part iszero in which case it will be cast to a real type. Whenais real the resulting eigenvalues will be real (0 imaginarypart) or occur in conjugate pairs

v : (..., M, M) array

The normalized (unit “length”) eigenvectors, such that thecolumnv[:,i] is the eigenvector corresponding to theeigenvaluew[i].

Raises:

LinAlgError

If the eigenvalue computation does not converge.

See also

eigvals
eigenvalues of a non-symmetric array.
eigh
eigenvalues and eigenvectors of a symmetric or Hermitian (conjugate symmetric) array.
eigvalsh
eigenvalues of a symmetric or Hermitian (conjugate symmetric) array.

Notes

New in version 1.8.0.

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.

The numberw is an eigenvalue ofa if there exists a vectorv such thatdot(a,v)=w*v. Thus, the arraysa,w, andv satisfy the equationsdot(a[:,:],v[:,i])=w[i]*v[:,i]fori \in \{0,...,M-1\}.

The arrayv of eigenvectors may not be of maximum rank, that is, someof the columns may be linearly dependent, although round-off error mayobscure that fact. If the eigenvalues are all different, then theoreticallythe eigenvectors are linearly independent. Likewise, the (complex-valued)matrix of eigenvectorsv is unitary if the matrixa is normal, i.e.,ifdot(a,a.H)=dot(a.H,a), wherea.H denotes the conjugatetranspose ofa.

Finally, it is emphasized thatv consists of theright (as inright-hand side) eigenvectors ofa. A vectory satisfyingdot(y.T,a)=z*y.T for some numberz is called alefteigenvector ofa, and, in general, the left and right eigenvectorsof a matrix are not necessarily the (perhaps conjugate) transposesof each other.

References

G. Strang,Linear Algebra and Its Applications, 2nd Ed., Orlando, FL,Academic Press, Inc., 1980, Various pp.

Examples

>>>fromnumpyimportlinalgasLA

(Almost) trivial example with real e-values and e-vectors.

>>>w,v=LA.eig(np.diag((1,2,3)))>>>w;varray([ 1.,  2.,  3.])array([[ 1.,  0.,  0.],       [ 0.,  1.,  0.],       [ 0.,  0.,  1.]])

Real matrix possessing complex e-values and e-vectors; note that thee-values are complex conjugates of each other.

>>>w,v=LA.eig(np.array([[1,-1],[1,1]]))>>>w;varray([ 1. + 1.j,  1. - 1.j])array([[ 0.70710678+0.j        ,  0.70710678+0.j        ],       [ 0.00000000-0.70710678j,  0.00000000+0.70710678j]])

Complex-valued matrix with real e-values (but complex-valued e-vectors);note that a.conj().T = a, i.e., a is Hermitian.

>>>a=np.array([[1,1j],[-1j,1]])>>>w,v=LA.eig(a)>>>w;varray([  2.00000000e+00+0.j,   5.98651912e-36+0.j]) # i.e., {2, 0}array([[ 0.00000000+0.70710678j,  0.70710678+0.j        ],       [ 0.70710678+0.j        ,  0.00000000+0.70710678j]])

Be careful about round-off error!

>>>a=np.array([[1+1e-9,0],[0,1-1e-9]])>>># Theor. e-values are 1 +/- 1e-9>>>w,v=LA.eig(a)>>>w;varray([ 1.,  1.])array([[ 1.,  0.],       [ 0.,  1.]])

Previous topic

numpy.linalg.svd

Next topic

numpy.linalg.eigh

  • © Copyright 2008-2009, The Scipy community.
  • Last updated on Jun 10, 2017.
  • Created usingSphinx 1.5.3.

[8]ページ先頭

©2009-2025 Movatter.jp