scipy.linalg.eigvals¶
-
scipy.linalg.
eigvals
(a, b=None, overwrite_a=False, check_finite=True, homogeneous_eigvals=False)[source]¶ Compute eigenvalues from an ordinary or generalized eigenvalue problem.
Find eigenvalues of a general matrix:
a vr[:,i] = w[i] b vr[:,i]
- Parameters
- a(M, M) array_like
A complex or real matrix whose eigenvalues and eigenvectors will be computed.
- b(M, M) array_like, optional
Right-hand side matrix in a generalized eigenvalue problem. If omitted, identity matrix is assumed.
- overwrite_abool, optional
Whether to overwrite data in a (may improve performance)
- check_finitebool, optional
Whether 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_eigvalsbool, optional
If True, return the eigenvalues in homogeneous coordinates. In this case
w
is a (2, M) array so that:w[1,i] a vr[:,i] = w[0,i] b vr[:,i]
Default is False.
- Returns
- w(M,) or (2, M) double or complex ndarray
The eigenvalues, each repeated according to its multiplicity but not in any specific order. The shape is (M,) unless
homogeneous_eigvals=True
.
- Raises
- LinAlgError
If eigenvalue computation does not converge
See also
eig
eigenvalues and right eigenvectors of general arrays.
eigvalsh
eigenvalues of symmetric or Hermitian arrays
eigvals_banded
eigenvalues for symmetric/Hermitian band matrices
eigvalsh_tridiagonal
eigenvalues of symmetric/Hermitian tridiagonal matrices
Examples
>>> from scipy import linalg >>> a = np.array([[0., -1.], [1., 0.]]) >>> linalg.eigvals(a) array([0.+1.j, 0.-1.j])
>>> b = np.array([[0., 1.], [1., 1.]]) >>> linalg.eigvals(a, b) array([ 1.+0.j, -1.+0.j])
>>> a = np.array([[3., 0., 0.], [0., 8., 0.], [0., 0., 7.]]) >>> linalg.eigvals(a, homogeneous_eigvals=True) array([[3.+0.j, 8.+0.j, 7.+0.j], [1.+0.j, 1.+0.j, 1.+0.j]])