Skip to main content

det

Function det 

Source
pub fn det(array: impl AsRef<Array>) -> Result<Array>
Expand description

Compute the determinant of square matrices.

This operation is CPU-only at the pinned MLX version and uses the ambient stream. Integer inputs are promoted to floating point and leading dimensions are treated as batches.

use mlx_rs::{array, linalg, with_stream, Stream};

let matrix = array!([[1.0, 2.0], [3.0, 4.0]]);
let result = with_stream(&Stream::cpu(), || linalg::det(&matrix)).unwrap();
assert!(result.shape().is_empty());