eigvals_device

Function eigvals_device 

Source
pub fn eigvals_device(
    a: impl AsRef<Array>,
    stream: impl AsRef<Stream>,
) -> 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::{Array, linalg::*, StreamOrDevice};

let a = Array::from_slice(&[1.0f32, 1.0, 3.0, 4.0], &[2, 2]);
let eigenvalues = eigvals_device(&a, StreamOrDevice::cpu()).unwrap();