Skip to main content

slogdet

Function slogdet 

Source
pub fn slogdet<B: Backend, T: LinalgFloat>(
    a: &Array<B, T>,
) -> (Array<B, T>, Array<B, T>)
Expand description

The sign and the natural logarithm of the absolute value of the determinant of each square matrix, as jnp.linalg.slogdet (from the LU factorization). Singular matrices give a sign of 0 and -inf.

§Panics

Panics if a is not a batch of square matrices.

§Examples

use ruxla_core::{Array, Native, jnp};

let a = Array::<Native, f64>::from_vec(vec![0.0, 2.0, 3.0, 0.0], [2, 2]);
let (sign, logdet) = jnp::linalg::slogdet(&a);
assert_eq!(sign.to_vec(), [-1.0]);
assert!((logdet.to_vec()[0] - 6f64.ln()).abs() < 1e-12);