Fix mint tests.
This commit is contained in:
parent
b0a9eab0b9
commit
cb367a645d
|
@ -6,7 +6,7 @@ if [ -z "$NO_STD" ]; then
|
||||||
if [ -z "$LAPACK" ]; then
|
if [ -z "$LAPACK" ]; then
|
||||||
cargo test --verbose;
|
cargo test --verbose;
|
||||||
cargo test --verbose "arbitrary";
|
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;
|
cd nalgebra-glm; cargo test --verbose;
|
||||||
else
|
else
|
||||||
cd nalgebra-lapack; cargo test --verbose;
|
cd nalgebra-lapack; cargo test --verbose;
|
||||||
|
|
|
@ -331,9 +331,9 @@ macro_rules! impl_from_into_mint_2D(
|
||||||
#[cfg(feature = "mint")]
|
#[cfg(feature = "mint")]
|
||||||
impl_from_into_mint_2D!(
|
impl_from_into_mint_2D!(
|
||||||
(U2, U2) => ColumnMatrix2{x, y}[2];
|
(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, 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];
|
(U4, U4) => ColumnMatrix4{x, y, z, w}[4];
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use na::{DMatrix, Matrix2, Matrix3x5, Matrix4, Matrix5x3};
|
use na::{DMatrix, Matrix2, Matrix3x5, Matrix4, Matrix5x3};
|
||||||
use core::helper::{RandScalar, RandComplex};
|
use core::helper::{RandScalar, RandComplex};
|
||||||
|
|
||||||
|
|
||||||
quickcheck! {
|
quickcheck! {
|
||||||
fn bidiagonal(m: DMatrix<RandComplex<f64>>) -> bool {
|
fn bidiagonal(m: DMatrix<RandComplex<f64>>) -> bool {
|
||||||
let m = m.map(|e| e.0);
|
let m = m.map(|e| e.0);
|
||||||
|
@ -63,3 +64,26 @@ quickcheck! {
|
||||||
relative_eq!(m, &u * d * &v_t, epsilon = 1.0e-7)
|
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);
|
||||||
|
}
|
|
@ -105,11 +105,11 @@ fn symmetric_eigen_singular_24x24() {
|
||||||
let eig = m.clone().symmetric_eigen();
|
let eig = m.clone().symmetric_eigen();
|
||||||
let recomp = eig.recompose();
|
let recomp = eig.recompose();
|
||||||
|
|
||||||
assert!(relative_eq!(
|
assert_relative_eq!(
|
||||||
m.lower_triangle(),
|
m.lower_triangle(),
|
||||||
recomp.lower_triangle(),
|
recomp.lower_triangle(),
|
||||||
epsilon = 1.0e-5
|
epsilon = 1.0e-5
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[cfg(feature = "arbitrary")]
|
// #[cfg(feature = "arbitrary")]
|
||||||
|
|
|
@ -199,7 +199,7 @@ fn svd_singular() {
|
||||||
assert!(s.iter().all(|e| *e >= 0.0));
|
assert!(s.iter().all(|e| *e >= 0.0));
|
||||||
assert!(u.is_orthogonal(1.0e-5));
|
assert!(u.is_orthogonal(1.0e-5));
|
||||||
assert!(v_t.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.
|
// Same as the previous test but with one additional row.
|
||||||
|
@ -238,7 +238,7 @@ fn svd_singular_vertical() {
|
||||||
let ds = DMatrix::from_diagonal(&s);
|
let ds = DMatrix::from_diagonal(&s);
|
||||||
|
|
||||||
assert!(s.iter().all(|e| *e >= 0.0));
|
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.
|
// Same as the previous test but with one additional column.
|
||||||
|
@ -275,7 +275,7 @@ fn svd_singular_horizontal() {
|
||||||
let ds = DMatrix::from_diagonal(&s);
|
let ds = DMatrix::from_diagonal(&s);
|
||||||
|
|
||||||
assert!(s.iter().all(|e| *e >= 0.0));
|
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]
|
#[test]
|
||||||
|
@ -314,7 +314,7 @@ fn svd_with_delimited_subproblem() {
|
||||||
m[(8,8)] = 16.0; m[(3,9)] = 17.0;
|
m[(8,8)] = 16.0; m[(3,9)] = 17.0;
|
||||||
m[(9,9)] = 18.0;
|
m[(9,9)] = 18.0;
|
||||||
let svd = m.clone().svd(true, true);
|
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.
|
// Rectangular versions.
|
||||||
let mut m = DMatrix::<f64>::from_element(15, 10, 0.0);
|
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[(8,8)] = 16.0; m[(3,9)] = 17.0;
|
||||||
m[(9,9)] = 18.0;
|
m[(9,9)] = 18.0;
|
||||||
let svd = m.clone().svd(true, true);
|
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);
|
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]
|
#[test]
|
||||||
|
@ -350,7 +350,7 @@ fn svd_fail() {
|
||||||
println!("v: {:.5}", svd.v_t.unwrap());
|
println!("v: {:.5}", svd.v_t.unwrap());
|
||||||
let recomp = svd.recompose().unwrap();
|
let recomp = svd.recompose().unwrap();
|
||||||
println!("{:.5}{:.5}", m, recomp);
|
println!("{:.5}{:.5}", m, recomp);
|
||||||
assert!(relative_eq!(m, recomp, epsilon = 1.0e-5));
|
assert_relative_eq!(m, recomp, epsilon = 1.0e-5);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in New Issue