dpnp.linalg.eigvals¶
- dpnp.linalg.eigvals(a)[source]¶
Compute the eigenvalues of a general matrix.
For full documentation refer to
numpy.linalg.eigvals.- Parameters:
- a(..., M, M) {dpnp.ndarray, usm_ndarray}
A complex- or real-valued matrix whose eigenvalues will be computed.
- Returns:
- w(..., M) dpnp.ndarray
The eigenvalues, each repeated according to its multiplicity. They are not necessarily ordered, nor are they necessarily real for real matrices.
See also
dpnp.linalg.eigCompute the eigenvalues and right eigenvectors of a square array.
dpnp.linalg.eigvalshCompute the eigenvalues of a complex Hermitian or real symmetric matrix.
dpnp.linalg.eighReturn the eigenvalues and eigenvectors of a complex Hermitian (conjugate symmetric) or a real symmetric matrix.
Notes
Since there is no proper OneMKL LAPACK function, DPNP will calculate through a fallback on NumPy call.
Examples
Illustration, using the fact that the eigenvalues of a diagonal matrix are its diagonal elements, that multiplying a matrix on the left by an orthogonal matrix, Q, and on the right by Q.T (the transpose of Q), preserves the eigenvalues of the "middle" matrix. In other words, if Q is orthogonal, then
Q * A * Q.Thas the same eigenvalues asA:>>> import dpnp as np >>> from dpnp import linalg as LA >>> x = np.random.random() >>> Q = np.array([[np.cos(x), -np.sin(x)], [np.sin(x), np.cos(x)]]) >>> LA.norm(Q[0, :]), LA.norm(Q[1, :]), np.dot(Q[0, :],Q[1, :]) (array(1.), array(1.), array(0.))
Now multiply a diagonal matrix by
Qon one side and byQ.Ton the other:>>> D = np.diag((-1, 1)) >>> LA.eigvals(D) array([-1.+0.j, 1.+0.j]) >>> A = np.dot(Q, D) >>> A = np.dot(A, Q.T) >>> LA.eigvals(A) array([-1.+0.j, 1.+0.j]) # random