2017-08-03 01:37:44 +08:00
|
|
|
use std::cmp;
|
|
|
|
|
2017-08-14 01:52:46 +08:00
|
|
|
use na::{DMatrix, Matrix2, Matrix4};
|
2017-08-03 01:37:44 +08:00
|
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "arbitrary")]
|
|
|
|
quickcheck! {
|
|
|
|
fn symm_tridiagonal(n: usize) -> bool {
|
|
|
|
let n = cmp::max(1, cmp::min(n, 50));
|
|
|
|
let m = DMatrix::<f64>::new_random(n, n);
|
2017-08-14 01:52:46 +08:00
|
|
|
let tri = m.clone().symmetric_tridiagonalize();
|
2017-08-03 01:37:44 +08:00
|
|
|
let recomp = tri.recompose();
|
|
|
|
|
|
|
|
println!("{}{}", m.lower_triangle(), recomp.lower_triangle());
|
|
|
|
|
|
|
|
relative_eq!(m.lower_triangle(), recomp.lower_triangle(), epsilon = 1.0e-7)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn symm_tridiagonal_static_square(m: Matrix4<f64>) -> bool {
|
2017-08-14 01:52:46 +08:00
|
|
|
let tri = m.symmetric_tridiagonalize();
|
2017-08-03 01:37:44 +08:00
|
|
|
println!("{}{}", tri.internal_tri(), tri.off_diagonal());
|
|
|
|
let recomp = tri.recompose();
|
|
|
|
|
|
|
|
println!("{}{}", m.lower_triangle(), recomp.lower_triangle());
|
|
|
|
|
|
|
|
relative_eq!(m.lower_triangle(), recomp.lower_triangle(), epsilon = 1.0e-7)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn symm_tridiagonal_static_square_2x2(m: Matrix2<f64>) -> bool {
|
2017-08-14 01:52:46 +08:00
|
|
|
let tri = m.symmetric_tridiagonalize();
|
2017-08-03 01:37:44 +08:00
|
|
|
let recomp = tri.recompose();
|
|
|
|
|
|
|
|
relative_eq!(m.lower_triangle(), recomp.lower_triangle(), epsilon = 1.0e-7)
|
|
|
|
}
|
|
|
|
}
|