Fix mint tests.

This commit is contained in:
sebcrozet 2019-03-19 22:53:21 +01:00
parent b0a9eab0b9
commit cb367a645d
5 changed files with 36 additions and 12 deletions

View File

@ -6,7 +6,7 @@ if [ -z "$NO_STD" ]; then
if [ -z "$LAPACK" ]; then
cargo test --verbose;
cargo test --verbose "arbitrary";
cargo test --verbose "debug arbitrary mint serde-serialize abomonation-serialize";
cargo test --verbose --all-features;
cd nalgebra-glm; cargo test --verbose;
else
cd nalgebra-lapack; cargo test --verbose;

View File

@ -331,9 +331,9 @@ macro_rules! impl_from_into_mint_2D(
#[cfg(feature = "mint")]
impl_from_into_mint_2D!(
(U2, U2) => ColumnMatrix2{x, y}[2];
(U2, U3) => ColumnMatrix2x3{x, y}[2];
(U2, U3) => ColumnMatrix2x3{x, y, z}[2];
(U3, U3) => ColumnMatrix3{x, y, z}[3];
(U3, U4) => ColumnMatrix3x4{x, y, z}[3];
(U3, U4) => ColumnMatrix3x4{x, y, z, w}[3];
(U4, U4) => ColumnMatrix4{x, y, z, w}[4];
);

View File

@ -3,6 +3,7 @@
use na::{DMatrix, Matrix2, Matrix3x5, Matrix4, Matrix5x3};
use core::helper::{RandScalar, RandComplex};
quickcheck! {
fn bidiagonal(m: DMatrix<RandComplex<f64>>) -> bool {
let m = m.map(|e| e.0);
@ -63,3 +64,26 @@ quickcheck! {
relative_eq!(m, &u * d * &v_t, epsilon = 1.0e-7)
}
}
#[test]
fn bidiagonal_identity() {
let m = DMatrix::<f64>::identity(10, 10);
let bidiagonal = m.clone().bidiagonalize();
let (u, d, v_t) = bidiagonal.unpack();
println!("u, s, v_t: {}{}{}", u, d, v_t);
println!("recomp: {}", &u * &d * &v_t);
assert_eq!(m, &u * d * &v_t);
let m = DMatrix::<f64>::identity(10, 15);
let bidiagonal = m.clone().bidiagonalize();
let (u, d, v_t) = bidiagonal.unpack();
println!("u, s, v_t: {}{}{}", u, d, v_t);
assert_eq!(m, &u * d * &v_t);
let m = DMatrix::<f64>::identity(15, 10);
let bidiagonal = m.clone().bidiagonalize();
let (u, d, v_t) = bidiagonal.unpack();
println!("u, s, v_t: {}{}{}", u, d, v_t);
assert_eq!(m, &u * d * &v_t);
}

View File

@ -105,11 +105,11 @@ fn symmetric_eigen_singular_24x24() {
let eig = m.clone().symmetric_eigen();
let recomp = eig.recompose();
assert!(relative_eq!(
assert_relative_eq!(
m.lower_triangle(),
recomp.lower_triangle(),
epsilon = 1.0e-5
));
);
}
// #[cfg(feature = "arbitrary")]

View File

@ -199,7 +199,7 @@ fn svd_singular() {
assert!(s.iter().all(|e| *e >= 0.0));
assert!(u.is_orthogonal(1.0e-5));
assert!(v_t.is_orthogonal(1.0e-5));
assert!(relative_eq!(m, &u * ds * &v_t, epsilon = 1.0e-5));
assert_relative_eq!(m, &u * ds * &v_t, epsilon = 1.0e-5);
}
// Same as the previous test but with one additional row.
@ -238,7 +238,7 @@ fn svd_singular_vertical() {
let ds = DMatrix::from_diagonal(&s);
assert!(s.iter().all(|e| *e >= 0.0));
assert!(relative_eq!(m, &u * ds * &v_t, epsilon = 1.0e-5));
assert_relative_eq!(m, &u * ds * &v_t, epsilon = 1.0e-5);
}
// Same as the previous test but with one additional column.
@ -275,7 +275,7 @@ fn svd_singular_horizontal() {
let ds = DMatrix::from_diagonal(&s);
assert!(s.iter().all(|e| *e >= 0.0));
assert!(relative_eq!(m, &u * ds * &v_t, epsilon = 1.0e-5));
assert_relative_eq!(m, &u * ds * &v_t, epsilon = 1.0e-5);
}
#[test]
@ -314,7 +314,7 @@ fn svd_with_delimited_subproblem() {
m[(8,8)] = 16.0; m[(3,9)] = 17.0;
m[(9,9)] = 18.0;
let svd = m.clone().svd(true, true);
assert!(relative_eq!(m, svd.recompose().unwrap(), epsilon = 1.0e-7));
assert_relative_eq!(m, svd.recompose().unwrap(), epsilon = 1.0e-7);
// Rectangular versions.
let mut m = DMatrix::<f64>::from_element(15, 10, 0.0);
@ -329,10 +329,10 @@ fn svd_with_delimited_subproblem() {
m[(8,8)] = 16.0; m[(3,9)] = 17.0;
m[(9,9)] = 18.0;
let svd = m.clone().svd(true, true);
assert!(relative_eq!(m, svd.recompose().unwrap(), epsilon = 1.0e-7));
assert_relative_eq!(m, svd.recompose().unwrap(), epsilon = 1.0e-7);
let svd = m.transpose().svd(true, true);
assert!(relative_eq!(m.transpose(), svd.recompose().unwrap(), epsilon = 1.0e-7));
assert_relative_eq!(m.transpose(), svd.recompose().unwrap(), epsilon = 1.0e-7);
}
#[test]
@ -350,7 +350,7 @@ fn svd_fail() {
println!("v: {:.5}", svd.v_t.unwrap());
let recomp = svd.recompose().unwrap();
println!("{:.5}{:.5}", m, recomp);
assert!(relative_eq!(m, recomp, epsilon = 1.0e-5));
assert_relative_eq!(m, recomp, epsilon = 1.0e-5);
}
#[test]