2018-10-22 13:00:10 +08:00
|
|
|
use nl::QR;
|
2017-08-03 01:38:28 +08:00
|
|
|
|
2021-03-01 01:39:18 +08:00
|
|
|
use crate::proptest::*;
|
|
|
|
use proptest::{prop_assert, proptest};
|
|
|
|
|
|
|
|
proptest! {
|
|
|
|
#[test]
|
|
|
|
fn qr(m in dmatrix()) {
|
2017-08-03 01:38:28 +08:00
|
|
|
let qr = QR::new(m.clone());
|
|
|
|
let q = qr.q();
|
|
|
|
let r = qr.r();
|
|
|
|
|
2021-03-01 01:39:18 +08:00
|
|
|
prop_assert!(relative_eq!(m, q * r, epsilon = 1.0e-7))
|
2017-08-03 01:38:28 +08:00
|
|
|
}
|
|
|
|
|
2021-03-01 01:39:18 +08:00
|
|
|
#[test]
|
|
|
|
fn qr_static(m in matrix5x3()) {
|
2017-08-03 01:38:28 +08:00
|
|
|
let qr = QR::new(m);
|
|
|
|
let q = qr.q();
|
|
|
|
let r = qr.r();
|
|
|
|
|
2021-03-01 01:39:18 +08:00
|
|
|
prop_assert!(relative_eq!(m, q * r, epsilon = 1.0e-7))
|
2017-08-03 01:38:28 +08:00
|
|
|
}
|
|
|
|
}
|