2021-03-01 01:39:18 +08:00
|
|
|
use na::DMatrix;
|
2019-03-23 18:46:56 +08:00
|
|
|
use nl::Schur;
|
2018-10-22 13:00:10 +08:00
|
|
|
use std::cmp;
|
2017-08-07 01:41:12 +08:00
|
|
|
|
2021-03-01 01:39:18 +08:00
|
|
|
use crate::proptest::*;
|
|
|
|
use proptest::{prop_assert, proptest};
|
|
|
|
|
|
|
|
proptest! {
|
|
|
|
#[test]
|
|
|
|
fn schur(n in PROPTEST_MATRIX_DIM) {
|
2017-08-07 01:41:12 +08:00
|
|
|
let n = cmp::max(1, cmp::min(n, 10));
|
|
|
|
let m = DMatrix::<f64>::new_random(n, n);
|
|
|
|
|
2019-03-23 18:46:56 +08:00
|
|
|
let (vecs, vals) = Schur::new(m.clone()).unpack();
|
2017-08-07 01:41:12 +08:00
|
|
|
|
2021-03-01 01:39:18 +08:00
|
|
|
prop_assert!(relative_eq!(&vecs * vals * vecs.transpose(), m, epsilon = 1.0e-7))
|
2017-08-07 01:41:12 +08:00
|
|
|
}
|
|
|
|
|
2021-03-01 01:39:18 +08:00
|
|
|
#[test]
|
|
|
|
fn schur_static(m in matrix4()) {
|
2019-03-23 18:46:56 +08:00
|
|
|
let (vecs, vals) = Schur::new(m.clone()).unpack();
|
2021-03-01 01:39:18 +08:00
|
|
|
prop_assert!(relative_eq!(vecs * vals * vecs.transpose(), m, epsilon = 1.0e-7))
|
2017-08-07 01:41:12 +08:00
|
|
|
}
|
|
|
|
}
|