Skip to main content

cholesky

Function cholesky 

Source
pub fn cholesky<B: Backend, T: LinalgScalar>(
    x: &Array<B, T>,
    symmetrize_input: bool,
) -> Array<B, T>
Expand description

The Cholesky factor L of each symmetric positive definite matrix (x = L L^T, L lower triangular), as lax.linalg.cholesky.

With symmetrize_input, x is replaced by (x + x^T) / 2 first, which gives better derivatives; otherwise only its lower triangle is read. Matrices that are not positive definite give NaNs.

§Panics

Panics if x is not a batch of square matrices.

§Examples

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

let a = Array::<Native, f64>::from_vec(vec![4.0, 2.0, 2.0, 5.0], [2, 2]);
let l = lax::linalg::cholesky(&a, true);
assert_eq!(l.to_vec(), [2.0, 0.0, 1.0, 2.0]);