2017-08-03 01:38:28 +08:00
|
|
|
use std::cmp;
|
|
|
|
|
|
|
|
use na::{DMatrix, Matrix4};
|
2021-03-01 01:39:18 +08:00
|
|
|
use nl::Hessenberg;
|
2017-08-03 01:38:28 +08:00
|
|
|
|
2021-03-01 01:39:18 +08:00
|
|
|
use crate::proptest::*;
|
|
|
|
use proptest::{prop_assert, proptest};
|
2017-08-03 01:38:28 +08:00
|
|
|
|
2021-03-01 01:39:18 +08:00
|
|
|
proptest! {
|
|
|
|
#[test]
|
|
|
|
fn hessenberg(n in PROPTEST_MATRIX_DIM) {
|
|
|
|
let n = cmp::min(n, 25);
|
|
|
|
let m = DMatrix::<f64>::new_random(n, n);
|
2017-08-03 01:38:28 +08:00
|
|
|
|
2021-03-01 01:39:18 +08:00
|
|
|
if let Some(hess) = Hessenberg::new(m.clone()) {
|
|
|
|
let h = hess.h();
|
|
|
|
let p = hess.p();
|
|
|
|
|
|
|
|
prop_assert!(relative_eq!(m, &p * h * p.transpose(), epsilon = 1.0e-7))
|
2017-08-03 01:38:28 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-01 01:39:18 +08:00
|
|
|
#[test]
|
|
|
|
fn hessenberg_static(m in matrix4()) {
|
|
|
|
if let Some(hess) = Hessenberg::new(m) {
|
|
|
|
let h = hess.h();
|
|
|
|
let p = hess.p();
|
2017-08-03 01:38:28 +08:00
|
|
|
|
2021-03-01 01:39:18 +08:00
|
|
|
prop_assert!(relative_eq!(m, p * h * p.transpose(), epsilon = 1.0e-7))
|
2017-08-03 01:38:28 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|