Provide test case for a diagonal matrix resulting in NaN values from the QR eigenvalue computation.

This commit is contained in:
Michael Riss 2015-11-14 01:18:10 +01:00
parent 0f24c2d8fc
commit 98e0526bbb
1 changed files with 16 additions and 0 deletions

View File

@ -583,6 +583,22 @@ fn test_eigen_qr_mat6() {
test_eigen_qr_impl!(Mat6<f64>);
}
use std::f64;
use na::Iterable;
#[test]
fn test_eigen_qr_diagonal() {
let cov = Mat3::new( 1.0, 0.0, 0.0,
0.0, 1.0, 0.0,
0.0, 0.0, 1.0 );
let (eigvec, eigval) = na::eigen_qr(&cov, &f64::EPSILON, 1000);
for x in eigvec.iter() {
assert!( !x.is_nan(), "NaN values detected, eigvec = {:?}", eigvec );
}
for x in eigval.iter() {
assert!( !x.is_nan(), "NaN values detected, eigval = {:?}", eigval );
}
}
#[test]
fn test_from_fn() {
let actual: DMat<usize> = DMat::from_fn(3, 4, |i, j| 10 * i + j);