MCPcopy Index your code
hub / github.com/numpy/numpy / eigh

Function eigh

numpy/linalg/_linalg.py:1514–1657  ·  view source on GitHub ↗

Return the eigenvalues and eigenvectors of a complex Hermitian (conjugate symmetric) or a real symmetric matrix. Returns two objects, a 1-D array containing the eigenvalues of `a`, and a 2-D square array or matrix (depending on the input type) of the corresponding eigenvectors

(a, UPLO='L')

Source from the content-addressed store, hash-verified

1512
1513@array_function_dispatch(_eigvalsh_dispatcher)
1514def eigh(a, UPLO='L'):
1515 """
1516 Return the eigenvalues and eigenvectors of a complex Hermitian
1517 (conjugate symmetric) or a real symmetric matrix.
1518
1519 Returns two objects, a 1-D array containing the eigenvalues of `a`, and
1520 a 2-D square array or matrix (depending on the input type) of the
1521 corresponding eigenvectors (in columns).
1522
1523 Parameters
1524 ----------
1525 a : (..., M, M) array
1526 Hermitian or real symmetric matrices whose eigenvalues and
1527 eigenvectors are to be computed.
1528 UPLO : {'L', 'U'}, optional
1529 Specifies whether the calculation is done with the lower triangular
1530 part of `a` ('L', default) or the upper triangular part ('U').
1531 Irrespective of this value only the real parts of the diagonal will
1532 be considered in the computation to preserve the notion of a Hermitian
1533 matrix. It therefore follows that the imaginary part of the diagonal
1534 will always be treated as zero.
1535
1536 Returns
1537 -------
1538 A namedtuple with the following attributes:
1539
1540 eigenvalues : (..., M) ndarray
1541 The eigenvalues in ascending order, each repeated according to
1542 its multiplicity.
1543 eigenvectors : {(..., M, M) ndarray, (..., M, M) matrix}
1544 The column ``eigenvectors[:, i]`` is the normalized eigenvector
1545 corresponding to the eigenvalue ``eigenvalues[i]``. Will return a
1546 matrix object if `a` is a matrix object.
1547
1548 Raises
1549 ------
1550 LinAlgError
1551 If the eigenvalue computation does not converge.
1552
1553 See Also
1554 --------
1555 eigvalsh : eigenvalues of real symmetric or complex Hermitian
1556 (conjugate symmetric) arrays.
1557 eig : eigenvalues and right eigenvectors for non-symmetric arrays.
1558 eigvals : eigenvalues of non-symmetric arrays.
1559 scipy.linalg.eigh : Similar function in SciPy (but also solves the
1560 generalized eigenvalue problem).
1561
1562 Notes
1563 -----
1564 Broadcasting rules apply, see the `numpy.linalg` documentation for
1565 details.
1566
1567 The eigenvalues/eigenvectors are computed using LAPACK routines ``_syevd``,
1568 ``_heevd``.
1569
1570 The eigenvalues of real symmetric or complex Hermitian matrices are always
1571 real. [1]_ The array `eigenvalues` of (column) eigenvectors is unitary and

Callers 1

svdFunction · 0.85

Calls 10

errstateClass · 0.90
_makearrayFunction · 0.85
_assert_stacked_squareFunction · 0.85
_commonTypeFunction · 0.85
isComplexTypeFunction · 0.85
_realTypeFunction · 0.85
EighResultClass · 0.85
wrapFunction · 0.85
upperMethod · 0.80
astypeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…