2022-02-12 15:27:29 +08:00
|
|
|
use na::DMatrix;
|
2022-02-03 19:36:41 +08:00
|
|
|
use nl::QZ;
|
2022-01-19 11:35:11 +08:00
|
|
|
|
|
|
|
use crate::proptest::*;
|
2022-02-12 15:27:29 +08:00
|
|
|
use proptest::{prop_assert, prop_compose, proptest};
|
|
|
|
|
|
|
|
prop_compose! {
|
|
|
|
fn f64_squares() (n in PROPTEST_MATRIX_DIM) (a in matrix(PROPTEST_F64,n,n), b in matrix(PROPTEST_F64,n,n)) -> (DMatrix<f64>, DMatrix<f64>){
|
|
|
|
(a,b)
|
|
|
|
}}
|
2022-01-19 11:35:11 +08:00
|
|
|
|
|
|
|
proptest! {
|
|
|
|
#[test]
|
2022-02-12 15:27:29 +08:00
|
|
|
fn qz((a,b) in f64_squares()) {
|
2022-01-19 11:35:11 +08:00
|
|
|
|
2022-02-12 15:27:29 +08:00
|
|
|
let qz = QZ::new(a.clone(), b.clone());
|
2022-01-20 10:47:44 +08:00
|
|
|
let (vsl,s,t,vsr) = qz.clone().unpack();
|
2022-02-03 19:36:41 +08:00
|
|
|
|
2022-02-12 15:27:29 +08:00
|
|
|
prop_assert!(relative_eq!(&vsl * s * vsr.transpose(), a, epsilon = 1.0e-7));
|
|
|
|
prop_assert!(relative_eq!(vsl * t * vsr.transpose(), b, epsilon = 1.0e-7));
|
2022-02-03 19:36:41 +08:00
|
|
|
|
2022-01-19 11:35:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn qz_static(a in matrix4(), b in matrix4()) {
|
2022-01-20 12:51:46 +08:00
|
|
|
let qz = QZ::new(a.clone(), b.clone());
|
|
|
|
let (vsl,s,t,vsr) = qz.unpack();
|
|
|
|
|
2022-01-19 11:35:11 +08:00
|
|
|
prop_assert!(relative_eq!(&vsl * s * vsr.transpose(), a, epsilon = 1.0e-7));
|
2022-01-20 12:51:46 +08:00
|
|
|
prop_assert!(relative_eq!(vsl * t * vsr.transpose(), b, epsilon = 1.0e-7));
|
2022-01-19 11:35:11 +08:00
|
|
|
}
|
|
|
|
}
|