nalgebra/tests/linalg/hessenberg.rs

50 lines
1.5 KiB
Rust
Raw Normal View History

2021-03-01 00:52:14 +08:00
#![cfg(feature = "proptest-support")]
use na::Matrix2;
#[test]
fn hessenberg_simple() {
2018-10-22 13:00:10 +08:00
let m = Matrix2::new(1.0, 0.0, 1.0, 3.0);
let hess = m.hessenberg();
let (p, h) = hess.unpack();
assert!(relative_eq!(m, p * h * p.transpose(), epsilon = 1.0e-7))
}
macro_rules! gen_tests(
2021-03-01 00:52:14 +08:00
($module: ident, $scalar: expr) => {
mod $module {
#[allow(unused_imports)]
2019-03-23 21:29:07 +08:00
use crate::core::helper::{RandScalar, RandComplex};
2021-03-01 00:52:14 +08:00
use crate::proptest::*;
use proptest::{prop_assert, proptest};
2021-03-01 00:52:14 +08:00
proptest! {
#[test]
fn hessenberg(m in dmatrix_($scalar)) {
let hess = m.clone().hessenberg();
let (p, h) = hess.unpack();
2021-03-01 00:52:14 +08:00
prop_assert!(relative_eq!(m, &p * h * p.adjoint(), epsilon = 1.0e-7))
}
2021-03-01 00:52:14 +08:00
#[test]
fn hessenberg_static_mat2(m in matrix2_($scalar)) {
let hess = m.hessenberg();
let (p, h) = hess.unpack();
2021-03-01 00:52:14 +08:00
prop_assert!(relative_eq!(m, p * h * p.adjoint(), epsilon = 1.0e-7))
}
2021-03-01 00:52:14 +08:00
#[test]
fn hessenberg_static(m in matrix4_($scalar)) {
let hess = m.hessenberg();
let (p, h) = hess.unpack();
2021-03-01 00:52:14 +08:00
prop_assert!(relative_eq!(m, p * h * p.adjoint(), epsilon = 1.0e-7))
}
}
}
}
);
2021-03-01 00:52:14 +08:00
gen_tests!(complex, complex_f64());
gen_tests!(f64, PROPTEST_F64);