Compute the eigenvalues of a general matrix. Main difference between `eigvals` and `eig`: the eigenvectors aren't returned. Parameters ---------- a : (..., M, M) array_like A complex- or real-valued matrix whose eigenvalues will be computed. Returns ------
(a)
| 993 | |
| 994 | @array_function_dispatch(_unary_dispatcher) |
| 995 | def eigvals(a): |
| 996 | """ |
| 997 | Compute the eigenvalues of a general matrix. |
| 998 | |
| 999 | Main difference between `eigvals` and `eig`: the eigenvectors aren't |
| 1000 | returned. |
| 1001 | |
| 1002 | Parameters |
| 1003 | ---------- |
| 1004 | a : (..., M, M) array_like |
| 1005 | A complex- or real-valued matrix whose eigenvalues will be computed. |
| 1006 | |
| 1007 | Returns |
| 1008 | ------- |
| 1009 | w : (..., M,) ndarray |
| 1010 | The eigenvalues, each repeated according to its multiplicity. |
| 1011 | They are not necessarily ordered, nor are they necessarily |
| 1012 | real for real matrices. |
| 1013 | |
| 1014 | Raises |
| 1015 | ------ |
| 1016 | LinAlgError |
| 1017 | If the eigenvalue computation does not converge. |
| 1018 | |
| 1019 | See Also |
| 1020 | -------- |
| 1021 | eig : eigenvalues and right eigenvectors of general arrays |
| 1022 | eigvalsh : eigenvalues of real symmetric or complex Hermitian |
| 1023 | (conjugate symmetric) arrays. |
| 1024 | eigh : eigenvalues and eigenvectors of real symmetric or complex |
| 1025 | Hermitian (conjugate symmetric) arrays. |
| 1026 | scipy.linalg.eigvals : Similar function in SciPy. |
| 1027 | |
| 1028 | Notes |
| 1029 | ----- |
| 1030 | |
| 1031 | .. versionadded:: 1.8.0 |
| 1032 | |
| 1033 | Broadcasting rules apply, see the `numpy.linalg` documentation for |
| 1034 | details. |
| 1035 | |
| 1036 | This is implemented using the ``_geev`` LAPACK routines which compute |
| 1037 | the eigenvalues and eigenvectors of general square arrays. |
| 1038 | |
| 1039 | Examples |
| 1040 | -------- |
| 1041 | Illustration, using the fact that the eigenvalues of a diagonal matrix |
| 1042 | are its diagonal elements, that multiplying a matrix on the left |
| 1043 | by an orthogonal matrix, `Q`, and on the right by `Q.T` (the transpose |
| 1044 | of `Q`), preserves the eigenvalues of the "middle" matrix. In other words, |
| 1045 | if `Q` is orthogonal, then ``Q * A * Q.T`` has the same eigenvalues as |
| 1046 | ``A``: |
| 1047 | |
| 1048 | >>> from numpy import linalg as LA |
| 1049 | >>> x = np.random.random() |
| 1050 | >>> Q = np.array([[np.cos(x), -np.sin(x)], [np.sin(x), np.cos(x)]]) |
| 1051 | >>> LA.norm(Q[0, :]), LA.norm(Q[1, :]), np.dot(Q[0, :],Q[1, :]) |
| 1052 | (1.0, 1.0, 0.0) |
no test coverage detected