forked from M-Labs/nalgebra
Fix tests
This commit is contained in:
parent
dd6c40016e
commit
148b164aaa
@ -218,47 +218,67 @@ fn remove_columns() {
|
|||||||
21, 22, 23, 24, 25,
|
21, 22, 23, 24, 25,
|
||||||
31, 32, 33, 34, 35);
|
31, 32, 33, 34, 35);
|
||||||
|
|
||||||
let expected1 = Matrix3x4::new(
|
let expected_a1 = Matrix3x4::new(
|
||||||
12, 13, 14, 15,
|
12, 13, 14, 15,
|
||||||
22, 23, 24, 25,
|
22, 23, 24, 25,
|
||||||
32, 33, 34, 35);
|
32, 33, 34, 35);
|
||||||
|
|
||||||
let expected2 = Matrix3x4::new(
|
let expected_a2 = Matrix3x4::new(
|
||||||
11, 12, 13, 14,
|
11, 12, 13, 14,
|
||||||
21, 22, 23, 24,
|
21, 22, 23, 24,
|
||||||
31, 32, 33, 34);
|
31, 32, 33, 34);
|
||||||
|
|
||||||
let expected3 = Matrix3x4::new(
|
let expected_a3 = Matrix3x4::new(
|
||||||
11, 12, 14, 15,
|
11, 12, 14, 15,
|
||||||
21, 22, 24, 25,
|
21, 22, 24, 25,
|
||||||
31, 32, 34, 35);
|
31, 32, 34, 35);
|
||||||
|
|
||||||
assert_eq!(m.remove_column(0), expected1);
|
assert_eq!(m.remove_column(0), expected_a1);
|
||||||
assert_eq!(m.remove_column(4), expected2);
|
assert_eq!(m.remove_column(4), expected_a2);
|
||||||
assert_eq!(m.remove_column(2), expected3);
|
assert_eq!(m.remove_column(2), expected_a3);
|
||||||
|
|
||||||
let expected1 = Matrix3::new(
|
let expected_b1 = Matrix3::new(
|
||||||
13, 14, 15,
|
13, 14, 15,
|
||||||
23, 24, 25,
|
23, 24, 25,
|
||||||
33, 34, 35);
|
33, 34, 35);
|
||||||
|
|
||||||
let expected2 = Matrix3::new(
|
let expected_b2 = Matrix3::new(
|
||||||
11, 12, 13,
|
11, 12, 13,
|
||||||
21, 22, 23,
|
21, 22, 23,
|
||||||
31, 32, 33);
|
31, 32, 33);
|
||||||
|
|
||||||
let expected3 = Matrix3::new(
|
let expected_b3 = Matrix3::new(
|
||||||
11, 12, 15,
|
11, 12, 15,
|
||||||
21, 22, 25,
|
21, 22, 25,
|
||||||
31, 32, 35);
|
31, 32, 35);
|
||||||
|
|
||||||
assert_eq!(m.remove_fixed_columns::<2>(0), expected1);
|
assert_eq!(m.remove_fixed_columns::<2>(0), expected_b1);
|
||||||
assert_eq!(m.remove_fixed_columns::<2>(3), expected2);
|
assert_eq!(m.remove_fixed_columns::<2>(3), expected_b2);
|
||||||
assert_eq!(m.remove_fixed_columns::<2>(2), expected3);
|
assert_eq!(m.remove_fixed_columns::<2>(2), expected_b3);
|
||||||
|
|
||||||
// The following is just to verify that the return type dimensions is correctly inferred.
|
// The following is just to verify that the return type dimensions is correctly inferred.
|
||||||
let computed: Matrix<_, U3, Dynamic, _> = m.remove_columns(3, 2);
|
let computed: Matrix<_, U3, Dynamic, _> = m.remove_columns(3, 2);
|
||||||
assert!(computed.eq(&expected2));
|
assert!(computed.eq(&expected_b2));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Same thing but using a non-copy scalar type.
|
||||||
|
*/
|
||||||
|
let m = m.map(Box::new);
|
||||||
|
let expected_a1 = expected_a1.map(Box::new);
|
||||||
|
let expected_a2 = expected_a2.map(Box::new);
|
||||||
|
let expected_a3 = expected_a3.map(Box::new);
|
||||||
|
|
||||||
|
assert_eq!(m.clone().remove_column(0), expected_a1);
|
||||||
|
assert_eq!(m.clone().remove_column(4), expected_a2);
|
||||||
|
assert_eq!(m.clone().remove_column(2), expected_a3);
|
||||||
|
|
||||||
|
let expected_b1 = expected_b1.map(Box::new);
|
||||||
|
let expected_b2 = expected_b2.map(Box::new);
|
||||||
|
let expected_b3 = expected_b3.map(Box::new);
|
||||||
|
|
||||||
|
assert_eq!(m.clone().remove_fixed_columns::<2>(0), expected_b1);
|
||||||
|
assert_eq!(m.clone().remove_fixed_columns::<2>(3), expected_b2);
|
||||||
|
assert_eq!(m.remove_fixed_columns::<2>(2), expected_b3);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -11,7 +11,7 @@ macro_rules! gen_tests(
|
|||||||
|
|
||||||
fn unzero_diagonal<T: ComplexField>(a: &mut Matrix4<T>) {
|
fn unzero_diagonal<T: ComplexField>(a: &mut Matrix4<T>) {
|
||||||
for i in 0..4 {
|
for i in 0..4 {
|
||||||
if a[(i, i)].norm1() < na::convert(1.0e-7) {
|
if a[(i, i)].clone().norm1() < na::convert(1.0e-7) {
|
||||||
a[(i, i)] = T::one();
|
a[(i, i)] = T::one();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user