bundles / scipy 1.17.1 / scipy / linalg / _decomp / eig
function
scipy.linalg._decomp:eig
source: /scipy/linalg/_decomp.py :114
Signature
def eig ( a , b = None , left = False , right = True , overwrite_a = False , overwrite_b = False , check_finite = True , homogeneous_eigvals = False ) Summary
Solve an ordinary or generalized eigenvalue problem of a square matrix.
Extended Summary
Find eigenvalues w and right or left eigenvectors of a general matrix
a vr[:,i] = w[i] b vr[:,i] a.H vl[:,i] = w[i].conj() b.H vl[:,i]
where .H is the Hermitian conjugation.
The documentation is written assuming array arguments are of specified "core" shapes. However, array argument(s) of this function may have additional "batch" dimensions prepended to the core shape. In this case, the array is treated as a batch of lower-dimensional slices; see linalg_batch for details. Note that calls with zero-size batches are unsupported and will raise a ValueError.
Parameters
a: (M, M) array_likeA complex or real matrix whose eigenvalues and eigenvectors will be computed.
b: (M, M) array_like, optionalRight-hand side matrix in a generalized eigenvalue problem. Default is None, identity matrix is assumed.
left: bool, optionalWhether to calculate and return left eigenvectors. Default is False.
right: bool, optionalWhether to calculate and return right eigenvectors. Default is True.
overwrite_a: bool, optionalWhether to overwrite
a; may improve performance. Default is False.overwrite_b: bool, optionalWhether to overwrite
b; may improve performance. Default is False.check_finite: bool, optionalWhether to check that the input matrices contain only finite numbers. Disabling may give a performance gain, but may result in problems (crashes, non-termination) if the inputs do contain infinities or NaNs.
homogeneous_eigvals: bool, optionalIf True, return the eigenvalues in homogeneous coordinates. In this case
wis a (2, M) array so thatw[1,i] a vr[:,i] = w[0,i] b vr[:,i]Default is False.
Returns
w: (M,) or (2, M) double or complex ndarrayThe eigenvalues, each repeated according to its multiplicity. The shape is (M,) unless
homogeneous_eigvals=True.vl: (M, M) double or complex ndarrayThe left eigenvector corresponding to the eigenvalue
w[i]is the columnvl[:,i]. Only returned ifleft=True. The left eigenvector is not normalized.vr: (M, M) double or complex ndarrayThe normalized right eigenvector corresponding to the eigenvalue
w[i]is the columnvr[:,i]. Only returned ifright=True.
Raises
: LinAlgErrorIf eigenvalue computation does not converge.
Examples
import numpy as np from scipy import linalg a = np.array([[0., -1.], [1., 0.]]) linalg.eigvals(a)✓
b = np.array([[0., 1.], [1., 1.]]) linalg.eigvals(a, b)✓
a = np.array([[3., 0., 0.], [0., 8., 0.], [0., 0., 7.]]) linalg.eigvals(a, homogeneous_eigvals=True)✓
a = np.array([[0., -1.], [1., 0.]]) linalg.eigvals(a) == linalg.eig(a)[0]✓
linalg.eig(a, left=True, right=False)[1] # normalized left eigenvector linalg.eig(a, left=False, right=True)[1] # normalized right eigenvector✗
See also
- eig_banded
eigenvalues and right eigenvectors for symmetric/Hermitian band matrices
- eigh
Eigenvalues and right eigenvectors for symmetric/Hermitian arrays.
- eigh_tridiagonal
eigenvalues and right eigenvectors for symmetric/Hermitian tridiagonal matrices
- eigvals
eigenvalues of general arrays
Aliases
-
scipy.linalg.eig
Referenced by
Other packages
- numpy reference:routines.linalg
- numpy reference:routines.linalg
- numpy reference:routines.linalg