Compute the eigenvalues of a complex Hermitian or real symmetric matrix. Main difference from eigh: the eigenvectors are not computed. Parameters ---------- a : (..., M, M) array_like A complex- or real-valued matrix whose eigenvalues are to be computed. UP
(a, UPLO='L')
| 1089 | |
| 1090 | @array_function_dispatch(_eigvalsh_dispatcher) |
| 1091 | def eigvalsh(a, UPLO='L'): |
| 1092 | """ |
| 1093 | Compute the eigenvalues of a complex Hermitian or real symmetric matrix. |
| 1094 | |
| 1095 | Main difference from eigh: the eigenvectors are not computed. |
| 1096 | |
| 1097 | Parameters |
| 1098 | ---------- |
| 1099 | a : (..., M, M) array_like |
| 1100 | A complex- or real-valued matrix whose eigenvalues are to be |
| 1101 | computed. |
| 1102 | UPLO : {'L', 'U'}, optional |
| 1103 | Specifies whether the calculation is done with the lower triangular |
| 1104 | part of `a` ('L', default) or the upper triangular part ('U'). |
| 1105 | Irrespective of this value only the real parts of the diagonal will |
| 1106 | be considered in the computation to preserve the notion of a Hermitian |
| 1107 | matrix. It therefore follows that the imaginary part of the diagonal |
| 1108 | will always be treated as zero. |
| 1109 | |
| 1110 | Returns |
| 1111 | ------- |
| 1112 | w : (..., M,) ndarray |
| 1113 | The eigenvalues in ascending order, each repeated according to |
| 1114 | its multiplicity. |
| 1115 | |
| 1116 | Raises |
| 1117 | ------ |
| 1118 | LinAlgError |
| 1119 | If the eigenvalue computation does not converge. |
| 1120 | |
| 1121 | See Also |
| 1122 | -------- |
| 1123 | eigh : eigenvalues and eigenvectors of real symmetric or complex Hermitian |
| 1124 | (conjugate symmetric) arrays. |
| 1125 | eigvals : eigenvalues of general real or complex arrays. |
| 1126 | eig : eigenvalues and right eigenvectors of general real or complex |
| 1127 | arrays. |
| 1128 | scipy.linalg.eigvalsh : Similar function in SciPy. |
| 1129 | |
| 1130 | Notes |
| 1131 | ----- |
| 1132 | |
| 1133 | .. versionadded:: 1.8.0 |
| 1134 | |
| 1135 | Broadcasting rules apply, see the `numpy.linalg` documentation for |
| 1136 | details. |
| 1137 | |
| 1138 | The eigenvalues are computed using LAPACK routines ``_syevd``, ``_heevd``. |
| 1139 | |
| 1140 | Examples |
| 1141 | -------- |
| 1142 | >>> from numpy import linalg as LA |
| 1143 | >>> a = np.array([[1, -2j], [2j, 5]]) |
| 1144 | >>> LA.eigvalsh(a) |
| 1145 | array([ 0.17157288, 5.82842712]) # may vary |
| 1146 | |
| 1147 | >>> # demonstrate the treatment of the imaginary part of the diagonal |
| 1148 | >>> a = np.array([[5+2j, 9-2j], [0+2j, 2-1j]]) |
no test coverage detected