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')
| 1268 | |
| 1269 | @array_function_dispatch(_eigvalsh_dispatcher) |
| 1270 | def eigvalsh(a, UPLO='L'): |
| 1271 | """ |
| 1272 | Compute the eigenvalues of a complex Hermitian or real symmetric matrix. |
| 1273 | |
| 1274 | Main difference from eigh: the eigenvectors are not computed. |
| 1275 | |
| 1276 | Parameters |
| 1277 | ---------- |
| 1278 | a : (..., M, M) array_like |
| 1279 | A complex- or real-valued matrix whose eigenvalues are to be |
| 1280 | computed. |
| 1281 | UPLO : {'L', 'U'}, optional |
| 1282 | Specifies whether the calculation is done with the lower triangular |
| 1283 | part of `a` ('L', default) or the upper triangular part ('U'). |
| 1284 | Irrespective of this value only the real parts of the diagonal will |
| 1285 | be considered in the computation to preserve the notion of a Hermitian |
| 1286 | matrix. It therefore follows that the imaginary part of the diagonal |
| 1287 | will always be treated as zero. |
| 1288 | |
| 1289 | Returns |
| 1290 | ------- |
| 1291 | w : (..., M,) ndarray |
| 1292 | The eigenvalues in ascending order, each repeated according to |
| 1293 | its multiplicity. |
| 1294 | |
| 1295 | Raises |
| 1296 | ------ |
| 1297 | LinAlgError |
| 1298 | If the eigenvalue computation does not converge. |
| 1299 | |
| 1300 | See Also |
| 1301 | -------- |
| 1302 | eigh : eigenvalues and eigenvectors of real symmetric or complex Hermitian |
| 1303 | (conjugate symmetric) arrays. |
| 1304 | eigvals : eigenvalues of general real or complex arrays. |
| 1305 | eig : eigenvalues and right eigenvectors of general real or complex |
| 1306 | arrays. |
| 1307 | scipy.linalg.eigvalsh : Similar function in SciPy. |
| 1308 | |
| 1309 | Notes |
| 1310 | ----- |
| 1311 | Broadcasting rules apply, see the `numpy.linalg` documentation for |
| 1312 | details. |
| 1313 | |
| 1314 | The eigenvalues are computed using LAPACK routines ``_syevd``, ``_heevd``. |
| 1315 | |
| 1316 | Examples |
| 1317 | -------- |
| 1318 | >>> import numpy as np |
| 1319 | >>> from numpy import linalg as LA |
| 1320 | >>> a = np.array([[1, -2j], [2j, 5]]) |
| 1321 | >>> LA.eigvalsh(a) |
| 1322 | array([ 0.17157288, 5.82842712]) # may vary |
| 1323 | |
| 1324 | >>> # demonstrate the treatment of the imaginary part of the diagonal |
| 1325 | >>> a = np.array([[5+2j, 9-2j], [0+2j, 2-1j]]) |
| 1326 | >>> a |
| 1327 | array([[5.+2.j, 9.-2.j], |
no test coverage detected
searching dependent graphs…