2017-08-06 22:12:05 +08:00
|
|
|
use std::cmp;
|
|
|
|
|
|
|
|
use na::{DMatrix, Matrix4};
|
2018-11-07 01:32:20 +08:00
|
|
|
use nl::SymmetricEigen;
|
2017-08-06 22:12:05 +08:00
|
|
|
|
|
|
|
quickcheck!{
|
|
|
|
fn symmetric_eigen(n: usize) -> bool {
|
|
|
|
let n = cmp::max(1, cmp::min(n, 10));
|
|
|
|
let m = DMatrix::<f64>::new_random(n, n);
|
|
|
|
let eig = SymmetricEigen::new(m.clone());
|
|
|
|
let recomp = eig.recompose();
|
|
|
|
relative_eq!(m.lower_triangle(), recomp.lower_triangle(), epsilon = 1.0e-5)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn symmetric_eigen_static(m: Matrix4<f64>) -> bool {
|
|
|
|
let eig = SymmetricEigen::new(m);
|
|
|
|
let recomp = eig.recompose();
|
|
|
|
relative_eq!(m.lower_triangle(), recomp.lower_triangle(), epsilon = 1.0e-5)
|
|
|
|
}
|
|
|
|
}
|