Use matrixcompare 0.2 with prop_assert_matrix_eq in Cholesky test
This commit is contained in:
parent
84557d8046
commit
3453577a16
|
@ -19,5 +19,5 @@ matrixcompare-core = { version = "0.1.0", optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
itertools = "0.9"
|
itertools = "0.9"
|
||||||
matrixcompare = "0.1.3"
|
matrixcompare = { version = "0.2.0", features = [ "proptest-support" ] }
|
||||||
nalgebra = { version="0.23", path = "../", features = ["compare"] }
|
nalgebra = { version="0.23", path = "../", features = ["compare"] }
|
||||||
|
|
|
@ -6,7 +6,7 @@ use nalgebra_sparse::proptest::csc;
|
||||||
use nalgebra::{Matrix5, Vector5, Cholesky, DMatrix};
|
use nalgebra::{Matrix5, Vector5, Cholesky, DMatrix};
|
||||||
|
|
||||||
use proptest::prelude::*;
|
use proptest::prelude::*;
|
||||||
use matrixcompare::assert_matrix_eq;
|
use matrixcompare::{assert_matrix_eq, prop_assert_matrix_eq};
|
||||||
|
|
||||||
fn positive_definite() -> impl Strategy<Value=CscMatrix<f64>> {
|
fn positive_definite() -> impl Strategy<Value=CscMatrix<f64>> {
|
||||||
let csc_f64 = csc(value_strategy::<f64>(),
|
let csc_f64 = csc(value_strategy::<f64>(),
|
||||||
|
@ -29,11 +29,10 @@ proptest! {
|
||||||
let l = cholesky.take_l();
|
let l = cholesky.take_l();
|
||||||
let matrix_reconstructed = &l * l.transpose();
|
let matrix_reconstructed = &l * l.transpose();
|
||||||
|
|
||||||
// TODO: Use matrixcompare instead
|
prop_assert_matrix_eq!(matrix_reconstructed, matrix, comp = abs, tol = 1e-8);
|
||||||
let diff = DMatrix::from(&(matrix_reconstructed - matrix));
|
|
||||||
prop_assert!(diff.abs().max() < 1e-8);
|
|
||||||
|
|
||||||
// TODO: Check that L is in fact lower triangular
|
let is_lower_triangular = l.triplet_iter().all(|(i, j, _)| j <= i);
|
||||||
|
prop_assert!(is_lower_triangular);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue