Skip to main content

check_singular_diagonal

Function check_singular_diagonal 

Source
pub fn check_singular_diagonal<T: DiagSingularity + Copy + Debug>(
    t: &TypedTensor<T>,
) -> Result<()>
Expand description

Checks that every diagonal element of a (possibly batched) upper-triangular factor is non-singular and finite.

Iterates over all batch slices and inspects the diagonal entries data[i + i * rows] for i in 0..min(rows, cols). Returns Error::BackendFailure with op: "solve" on the first offending entry.

§Examples

use tenferro_tensor::validate::check_singular_diagonal;
use tenferro_tensor::TypedTensor;

let t = TypedTensor::from_vec(vec![2, 2], vec![1.0f32, 0.0, 0.0, 2.0]);
assert!(check_singular_diagonal(&t).is_ok());