pub fn eigvals(a: impl AsRef<Array>) -> Result<Array>Expand description
Compute the eigenvalues of a square 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.
Unlike eigvalsh, this function computes eigenvalues for general (not necessarily symmetric
or Hermitian) matrices. The eigenvalues may be complex.
§Params
a: Input array. Must be a square matrix.
§Returns
An array of eigenvalues with shape (..., N).
§Example
use mlx_rs::{linalg::*, with_stream, Array, Stream};
with_stream(&Stream::cpu(), || {
let a = Array::from_slice(&[1.0f32, 1.0, 3.0, 4.0], &[2, 2]);
let eigenvalues = eigvals(&a).unwrap();
});