Skip to main content

slogdet

Function slogdet 

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

Compute determinant sign and log absolute determinant for square matrices.

This operation is CPU-only at the pinned MLX version and uses the ambient stream. A singular matrix returns zero sign and negative-infinity log_abs_det.

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::slogdet(&matrix)).unwrap();
assert!(result.sign.shape().is_empty());
assert!(result.log_abs_det.shape().is_empty());