From cb367a645d74b6c8198d5b4d86e30fb3d5a4ba38 Mon Sep 17 00:00:00 2001 From: sebcrozet Date: Tue, 19 Mar 2019 22:53:21 +0100 Subject: [PATCH] Fix mint tests. --- ci/test.sh | 2 +- src/base/conversion.rs | 4 ++-- tests/linalg/bidiagonal.rs | 24 ++++++++++++++++++++++++ tests/linalg/eigen.rs | 4 ++-- tests/linalg/svd.rs | 14 +++++++------- 5 files changed, 36 insertions(+), 12 deletions(-) diff --git a/ci/test.sh b/ci/test.sh index 88071149..a3a27fb2 100755 --- a/ci/test.sh +++ b/ci/test.sh @@ -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; diff --git a/src/base/conversion.rs b/src/base/conversion.rs index fcb6907d..750739a6 100644 --- a/src/base/conversion.rs +++ b/src/base/conversion.rs @@ -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]; ); diff --git a/tests/linalg/bidiagonal.rs b/tests/linalg/bidiagonal.rs index 28b1e3a9..d2f21a84 100644 --- a/tests/linalg/bidiagonal.rs +++ b/tests/linalg/bidiagonal.rs @@ -3,6 +3,7 @@ use na::{DMatrix, Matrix2, Matrix3x5, Matrix4, Matrix5x3}; use core::helper::{RandScalar, RandComplex}; + quickcheck! { fn bidiagonal(m: DMatrix>) -> 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::::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::::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::::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); +} \ No newline at end of file diff --git a/tests/linalg/eigen.rs b/tests/linalg/eigen.rs index 024384ce..a5dfcf6b 100644 --- a/tests/linalg/eigen.rs +++ b/tests/linalg/eigen.rs @@ -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")] diff --git a/tests/linalg/svd.rs b/tests/linalg/svd.rs index 8e98b3f7..efced01a 100644 --- a/tests/linalg/svd.rs +++ b/tests/linalg/svd.rs @@ -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::::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]