This is a pre-release version (latest).Go to latest (1.18.0)
{ } Raw JSON

bundles / scipy latest / scipy / linalg / _decomp / eigvals

function

scipy.linalg._decomp:eigvals

source: build-install/usr/lib/python3.14/site-packages/scipy/linalg/_decomp.py:832

Signature

def eigvals(a, b = None, overwrite_a = False, overwrite_b = False, check_finite = True, homogeneous_eigvals = False)

Summary

Compute eigenvalues from an ordinary or generalized eigenvalue problem.

Extended Summary

Find eigenvalues, w, of a general matrix

a @ vr[:, i] = w[i] * b  @ vr[:, i]

Parameters

a : (..., N, N) array_like

A complex or real matrix (or a stack of matrices), whose eigenvalues will be computed.

b : (..., N, N) array_like, optional

Right-hand side matrix (or a stack of matrices) in a generalized eigenvalue problem. If omitted (default), identity matrix is assumed.

overwrite_a : bool, optional

Whether to overwrite data in a (may improve performance). Default is False.

overwrite_b : bool, optional

Whether to overwrite data in b (may improve performance). Default is False. See tutorial_linalg_overwrite for details.

check_finite : bool, 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_eigvals : bool, optional

If True, return the eigenvalues in homogeneous coordinates. In this case w is a (2, N) array so that

w[1, i] * a @ vr[:, i] = w[0, i] * b @ vr[:, i]

This option is sometimes useful for generalized eigenvalue problems, b is not None, where an eigenvalue, , can over- or underflow; typically, :mth:`\alpha` and are of the order of norm(a) and norm(b), respectively.

Default is False.

Returns

w : (..., N,) or (..., 2, N) complex ndarray

The eigenvalues, each repeated according to its multiplicity but not in any specific order. The shape is (..., N) unless homogeneous_eigvals=True.

Raises

: LinAlgError

If eigenvalue computation does not converge

Examples

import numpy as np
from scipy import linalg
a = np.array([[0., -1.],
              [1.,  0.]])
✓
Compute the eigenvalues (``eigvals`` is the same as ``eig(a, right=False)``)
linalg.eigvals(a)
✓
array([0.+1.j, 0.-1.j])
Solve a generalized eigenvalue problem:
b = np.array([[0., 1.], [1., 1.]])
linalg.eigvals(a, b)
✓
array([ 1.+0.j, -1.+0.j])
Inputs with ``ndim > 2`` are interpreted as a batch of matrices
a2 = np.stack((a, 2*a))
linalg.eigvals(a2)
✓
array([[0.+1.j, 0.-1.j],
       [0.+2.j, 0.-2.j]])
``homogeneous_eigvals=True`` argument effectively separates each eigenvalue into a numerator-denominator pair:
a = np.array([[3., 0., 0.],
              [0., 8., 0.],
              [0., 0., 7.]])
b = 2*np.eye(3)
linalg.eigvals(a, b, homogeneous_eigvals=True)
✓
array([[3.+0.j, 8.+0.j, 7.+0.j],
       [2.+0.j, 2.+0.j, 2.+0.j]])

See also

eig

eigenvalues and right eigenvectors of general arrays.

eigvals_banded

eigenvalues for symmetric/Hermitian band matrices

eigvalsh

eigenvalues of symmetric or Hermitian arrays

eigvalsh_tridiagonal

eigenvalues of symmetric/Hermitian tridiagonal matrices

Aliases

  • scipy.linalg.eigvals