From d50af9dbfbba258b9baf6813f3f1804f02a47284 Mon Sep 17 00:00:00 2001 From: Mateusz Kowalczyk Date: Mon, 13 Sep 2021 09:08:37 +0900 Subject: [PATCH] Add test for Cholesky::new_with_substitute --- tests/linalg/cholesky.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/linalg/cholesky.rs b/tests/linalg/cholesky.rs index 6fd83912..891e54ca 100644 --- a/tests/linalg/cholesky.rs +++ b/tests/linalg/cholesky.rs @@ -1,5 +1,16 @@ #![cfg(all(feature = "proptest-support", feature = "debug"))] +#[test] +// #[rustfmt::skip] +fn cholesky_with_substitute() { + // Make a tiny covariance matrix with a small covariance value. + let m = na::Matrix2::new(1.0, f64::NAN, 1.0, 1e-32); + // Show that the cholesky fails for our matrix. We then try again with a substitute. + assert!(na::Cholesky::new(m).is_none()); + // ...and show that we get some result this time around. + assert!(na::Cholesky::new_with_substitute(m, 1e-8).is_some()); +} + macro_rules! gen_tests( ($module: ident, $scalar: ty) => { mod $module {