mlx.core.linalg.eigvalsh#
- eigvalsh(a: array, UPLO: str = 'L', *, stream: Optional[Union[Stream, Device]] = None) array#
Compute the eigenvalues of a complex Hermitian or real symmetric matrix.
This function supports arrays with at least 2 dimensions. When the input has more than two dimensions, the eigenvalues are computed for each matrix in the last two dimensions.
- Parameters:
a (array) – Input array. Must be a real symmetric or complex Hermitian matrix.
UPLO (str, optional) – Whether to use the upper (
"U") or lower ("L") triangle of the matrix. Default:"L".stream (Stream, optional) – Stream or device. Defaults to
Nonein which case the default stream of the default device is used.
- Returns:
The eigenvalues in ascending order.
- Return type:
Note
The input matrix is assumed to be symmetric (or Hermitian). Only the selected triangle is used. No checks for symmetry are performed.
Example
>>> A = mx.array([[1., -2.], [-2., 1.]]) >>> eigenvalues = mx.linalg.eigvalsh(A, stream=mx.cpu) >>> eigenvalues array([-1., 3.], dtype=float32)