diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/blas.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/blas.rs deleted file mode 100644 index 256ef7028..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/blas.rs +++ /dev/null @@ -1,120 +0,0 @@ -use na::{geometry::Quaternion, Matrix2, Vector3}; -use num_traits::{One, Zero}; - -#[test] -fn gemm_noncommutative() { - type Qf64 = Quaternion; - let i = Qf64::from_imag(Vector3::new(1.0, 0.0, 0.0)); - let j = Qf64::from_imag(Vector3::new(0.0, 1.0, 0.0)); - let k = Qf64::from_imag(Vector3::new(0.0, 0.0, 1.0)); - - let m1 = Matrix2::new(k, Qf64::zero(), j, i); - // this is the inverse of m1 - let m2 = Matrix2::new(-k, Qf64::zero(), Qf64::one(), -i); - - let mut res: Matrix2 = Matrix2::zero(); - res.gemm(Qf64::one(), &m1, &m2, Qf64::zero()); - assert_eq!(res, Matrix2::identity()); - - let mut res: Matrix2 = Matrix2::identity(); - res.gemm(k, &m1, &m2, -k); - assert_eq!(res, Matrix2::zero()); -} - -#[cfg(feature = "proptest-support")] -mod blas_proptest { - use crate::proptest::{PROPTEST_F64, PROPTEST_MATRIX_DIM}; - use na::{DMatrix, DVector}; - use proptest::{prop_assert, proptest}; - - proptest! { - /* - * - * Symmetric operators. - * - */ - #[test] - fn gemv_symm(n in PROPTEST_MATRIX_DIM, alpha in PROPTEST_F64, beta in PROPTEST_F64) { - let a = DMatrix::::new_random(n, n); - let a = &a * a.transpose(); - - let x = DVector::new_random(n); - let mut y1 = DVector::new_random(n); - let mut y2 = y1.clone(); - - y1.gemv(alpha, &a, &x, beta); - y2.sygemv(alpha, &a.lower_triangle(), &x, beta); - - prop_assert!(relative_eq!(y1, y2, epsilon = 1.0e-10)); - - y1.gemv(alpha, &a, &x, 0.0); - y2.sygemv(alpha, &a.lower_triangle(), &x, 0.0); - - prop_assert!(relative_eq!(y1, y2, epsilon = 1.0e-10)) - } - - #[test] - fn gemv_tr(n in PROPTEST_MATRIX_DIM, alpha in PROPTEST_F64, beta in PROPTEST_F64) { - let a = DMatrix::::new_random(n, n); - let x = DVector::new_random(n); - let mut y1 = DVector::new_random(n); - let mut y2 = y1.clone(); - - y1.gemv(alpha, &a, &x, beta); - y2.gemv_tr(alpha, &a.transpose(), &x, beta); - - prop_assert!(relative_eq!(y1, y2, epsilon = 1.0e-10)); - - y1.gemv(alpha, &a, &x, 0.0); - y2.gemv_tr(alpha, &a.transpose(), &x, 0.0); - - prop_assert!(relative_eq!(y1, y2, epsilon = 1.0e-10)) - } - - #[test] - fn ger_symm(n in PROPTEST_MATRIX_DIM, alpha in PROPTEST_F64, beta in PROPTEST_F64) { - let a = DMatrix::::new_random(n, n); - let mut a1 = &a * a.transpose(); - let mut a2 = a1.lower_triangle(); - - let x = DVector::new_random(n); - let y = DVector::new_random(n); - - a1.ger(alpha, &x, &y, beta); - a2.syger(alpha, &x, &y, beta); - - prop_assert!(relative_eq!(a1.lower_triangle(), a2)); - - a1.ger(alpha, &x, &y, 0.0); - a2.syger(alpha, &x, &y, 0.0); - - prop_assert!(relative_eq!(a1.lower_triangle(), a2)) - } - - #[test] - fn quadform(n in PROPTEST_MATRIX_DIM, alpha in PROPTEST_F64, beta in PROPTEST_F64) { - let rhs = DMatrix::::new_random(6, n); - let mid = DMatrix::::new_random(6, 6); - let mut res = DMatrix::new_random(n, n); - - let expected = &res * beta + rhs.transpose() * &mid * &rhs * alpha; - - res.quadform(alpha, &mid, &rhs, beta); - - prop_assert!(relative_eq!(res, expected, epsilon = 1.0e-7)) - } - - #[test] - fn quadform_tr(n in PROPTEST_MATRIX_DIM, alpha in PROPTEST_F64, beta in PROPTEST_F64) { - let lhs = DMatrix::::new_random(6, n); - let mid = DMatrix::::new_random(n, n); - let mut res = DMatrix::new_random(6, 6); - - let expected = &res * beta + &lhs * &mid * lhs.transpose() * alpha; - - res.quadform_tr(alpha, &lhs, &mid , beta); - - prop_assert!(relative_eq!(res, expected, epsilon = 1.0e-7)) - } - } -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/cg.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/cg.rs deleted file mode 100644 index 2030bc7d8..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/cg.rs +++ /dev/null @@ -1,59 +0,0 @@ -use na::{Matrix3, Matrix4, Point2, Point3, Vector2, Vector3}; - -/// See Example 3.4 of "Graphics and Visualization: Principles & Algorithms" -/// by Theoharis, Papaioannou, Platis, Patrikalakis. -#[test] -fn test_scaling_wrt_point_1() { - let a = Point2::new(0.0, 0.0); - let b = Point2::new(1.0, 1.0); - let c = Point2::new(5.0, 2.0); - - let scaling = Vector2::new(2.0, 2.0); - let scale_about = Matrix3::new_nonuniform_scaling_wrt_point(&scaling, &c); - - let expected_a = Point2::new(-5.0, -2.0); - let expected_b = Point2::new(-3.0, 0.0); - let result_a = scale_about.transform_point(&a); - let result_b = scale_about.transform_point(&b); - let result_c = scale_about.transform_point(&c); - - assert!(expected_a == result_a); - assert!(expected_b == result_b); - assert!(c == result_c); -} - -/// Based on the same example as the test above. -#[test] -fn test_scaling_wrt_point_2() { - let a = Point3::new(0.0, 0.0, 1.0); - let b = Point3::new(1.0, 1.0, 1.0); - let c = Point3::new(5.0, 2.0, 1.0); - - let scaling = Vector3::new(2.0, 2.0, 1.0); - let scale_about = Matrix4::new_nonuniform_scaling_wrt_point(&scaling, &c); - - let expected_a = Point3::new(-5.0, -2.0, 1.0); - let expected_b = Point3::new(-3.0, 0.0, 1.0); - - let result_a = scale_about.transform_point(&a); - let result_b = scale_about.transform_point(&b); - let result_c = scale_about.transform_point(&c); - - assert!(expected_a == result_a); - assert!(expected_b == result_b); - assert!(c == result_c); -} - -/// Based on https://github.com/emlowry/AiE/blob/50bae4068edb686cf8ffacdf6fab8e7cb22e7eb1/Year%201%20Classwork/MathTest/Matrix4x4TestGroup.cpp#L145 -#[test] -fn test_scaling_wrt_point_3() { - let about = Point3::new(2.0, 1.0, -2.0); - let scale = Vector3::new(2.0, 0.5, -1.0); - let pt = Point3::new(1.0, 2.0, 3.0); - let scale_about = Matrix4::new_nonuniform_scaling_wrt_point(&scale, &about); - - let expected = Point3::new(0.0, 1.5, -7.0); - let result = scale_about.transform_point(&pt); - - assert!(result == expected); -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/conversion.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/conversion.rs deleted file mode 100644 index bc8de3a7a..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/conversion.rs +++ /dev/null @@ -1,356 +0,0 @@ -#![cfg(all(feature = "proptest-support"))] -use na::{ - self, Affine3, Isometry3, Matrix2, Matrix2x3, Matrix2x4, Matrix2x5, Matrix2x6, Matrix3, - Matrix3x2, Matrix3x4, Matrix3x5, Matrix3x6, Matrix4, Matrix4x2, Matrix4x3, Matrix4x5, - Matrix4x6, Matrix5, Matrix5x2, Matrix5x3, Matrix5x4, Matrix5x6, Matrix6, Matrix6x2, Matrix6x3, - Matrix6x4, Matrix6x5, Projective3, Rotation3, RowVector1, RowVector2, RowVector3, RowVector4, - RowVector5, RowVector6, Similarity3, Transform3, UnitQuaternion, Vector1, Vector2, Vector3, - Vector4, Vector5, Vector6, -}; -use na::{DMatrix, DMatrixView, DMatrixViewMut, MatrixView, MatrixViewMut}; -use na::{U1, U3, U4}; - -use crate::proptest::*; -use proptest::{prop_assert, prop_assert_eq, proptest}; - -proptest! { - #[test] - fn translation_conversion(t in translation3(), p in point3()) { - let iso: Isometry3 = na::convert(t); - let sim: Similarity3 = na::convert(t); - let aff: Affine3 = na::convert(t); - let prj: Projective3 = na::convert(t); - let tr: Transform3 = na::convert(t); - - prop_assert_eq!(t, na::try_convert(iso).unwrap()); - prop_assert_eq!(t, na::try_convert(sim).unwrap()); - prop_assert_eq!(t, na::try_convert(aff).unwrap()); - prop_assert_eq!(t, na::try_convert(prj).unwrap()); - prop_assert_eq!(t, na::try_convert(tr).unwrap() ); - - prop_assert_eq!(t * p, iso * p); - prop_assert_eq!(t * p, sim * p); - prop_assert_eq!(t * p, aff * p); - prop_assert_eq!(t * p, prj * p); - prop_assert_eq!(t * p, tr * p); - } - - #[test] - fn rotation_conversion(r in rotation3(), v in vector3(), p in point3()) { - let uq: UnitQuaternion = na::convert(r); - let iso: Isometry3 = na::convert(r); - let sim: Similarity3 = na::convert(r); - let aff: Affine3 = na::convert(r); - let prj: Projective3 = na::convert(r); - let tr: Transform3 = na::convert(r); - - prop_assert!(relative_eq!(r, na::try_convert(uq).unwrap(), epsilon = 1.0e-7)); - prop_assert!(relative_eq!(r, na::try_convert(iso).unwrap(), epsilon = 1.0e-7)); - prop_assert!(relative_eq!(r, na::try_convert(sim).unwrap(), epsilon = 1.0e-7)); - prop_assert_eq!(r, na::try_convert(aff).unwrap()); - prop_assert_eq!(r, na::try_convert(prj).unwrap()); - prop_assert_eq!(r, na::try_convert(tr).unwrap() ); - - // NOTE: we need relative_eq because Isometry and Similarity use quaternions. - prop_assert!(relative_eq!(r * v, uq * v, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(r * v, iso * v, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(r * v, sim * v, epsilon = 1.0e-7)); - prop_assert_eq!(r * v, aff * v); - prop_assert_eq!(r * v, prj * v); - prop_assert_eq!(r * v, tr * v); - - prop_assert!(relative_eq!(r * p, uq * p, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(r * p, iso * p, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(r * p, sim * p, epsilon = 1.0e-7)); - prop_assert_eq!(r * p, aff * p); - prop_assert_eq!(r * p, prj * p); - prop_assert_eq!(r * p, tr * p); - } - - #[test] - fn unit_quaternion_conversion(uq in unit_quaternion(), v in vector3(), p in point3()) { - let rot: Rotation3 = na::convert(uq); - let iso: Isometry3 = na::convert(uq); - let sim: Similarity3 = na::convert(uq); - let aff: Affine3 = na::convert(uq); - let prj: Projective3 = na::convert(uq); - let tr: Transform3 = na::convert(uq); - - prop_assert_eq!(uq, na::try_convert(iso).unwrap()); - prop_assert_eq!(uq, na::try_convert(sim).unwrap()); - prop_assert!(relative_eq!(uq, na::try_convert(rot).unwrap(), epsilon = 1.0e-7)); - prop_assert!(relative_eq!(uq, na::try_convert(aff).unwrap(), epsilon = 1.0e-7)); - prop_assert!(relative_eq!(uq, na::try_convert(prj).unwrap(), epsilon = 1.0e-7)); - prop_assert!(relative_eq!(uq, na::try_convert(tr).unwrap(), epsilon = 1.0e-7) ); - - // NOTE: iso and sim use unit quaternions for the rotation so conversions to them are exact. - prop_assert!(relative_eq!(uq * v, rot * v, epsilon = 1.0e-7)); - prop_assert_eq!(uq * v, iso * v); - prop_assert_eq!(uq * v, sim * v); - prop_assert!(relative_eq!(uq * v, aff * v, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(uq * v, prj * v, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(uq * v, tr * v, epsilon = 1.0e-7)); - - prop_assert!(relative_eq!(uq * p, rot * p, epsilon = 1.0e-7)); - prop_assert_eq!(uq * p, iso * p); - prop_assert_eq!(uq * p, sim * p); - prop_assert!(relative_eq!(uq * p, aff * p, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(uq * p, prj * p, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(uq * p, tr * p, epsilon = 1.0e-7)); - } - - #[test] - fn isometry_conversion(iso in isometry3(), v in vector3(), p in point3()) { - let sim: Similarity3 = na::convert(iso); - let aff: Affine3 = na::convert(iso); - let prj: Projective3 = na::convert(iso); - let tr: Transform3 = na::convert(iso); - - - prop_assert_eq!(iso, na::try_convert(sim).unwrap()); - prop_assert!(relative_eq!(iso, na::try_convert(aff).unwrap(), epsilon = 1.0e-7)); - prop_assert!(relative_eq!(iso, na::try_convert(prj).unwrap(), epsilon = 1.0e-7)); - prop_assert!(relative_eq!(iso, na::try_convert(tr).unwrap(), epsilon = 1.0e-7) ); - - prop_assert_eq!(iso * v, sim * v); - prop_assert!(relative_eq!(iso * v, aff * v, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(iso * v, prj * v, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(iso * v, tr * v, epsilon = 1.0e-7)); - - prop_assert_eq!(iso * p, sim * p); - prop_assert!(relative_eq!(iso * p, aff * p, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(iso * p, prj * p, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(iso * p, tr * p, epsilon = 1.0e-7)); - } - - #[test] - fn similarity_conversion(sim in similarity3(), v in vector3(), p in point3()) { - let aff: Affine3 = na::convert(sim); - let prj: Projective3 = na::convert(sim); - let tr: Transform3 = na::convert(sim); - - prop_assert!(relative_eq!(sim, na::try_convert(aff).unwrap(), epsilon = 1.0e-7)); - prop_assert!(relative_eq!(sim, na::try_convert(prj).unwrap(), epsilon = 1.0e-7)); - prop_assert!(relative_eq!(sim, na::try_convert(tr).unwrap(), epsilon = 1.0e-7)); - - prop_assert!(relative_eq!(sim * v, aff * v, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(sim * v, prj * v, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(sim * v, tr * v, epsilon = 1.0e-7)); - - prop_assert!(relative_eq!(sim * p, aff * p, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(sim * p, prj * p, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(sim * p, tr * p, epsilon = 1.0e-7)); - } - - // XXX test Transform -} - -macro_rules! array_vector_conversion( - ($($array_vector_conversion_i: ident, $Vector: ident, $SZ: expr);* $(;)*) => {$( - #[test] - fn $array_vector_conversion_i() { - let v = $Vector::from_fn(|i, _| i); - let arr: [usize; $SZ] = v.into(); - let arr_ref: &[usize; $SZ] = v.as_ref(); - let v2 = $Vector::from(arr); - - for i in 0 .. $SZ { - assert_eq!(arr[i], i); - assert_eq!(arr_ref[i], i); - } - - assert_eq!(v, v2); - } - )*} -); - -array_vector_conversion!( - array_vector_conversion_1, Vector1, 1; - array_vector_conversion_2, Vector2, 2; - array_vector_conversion_3, Vector3, 3; - array_vector_conversion_4, Vector4, 4; - array_vector_conversion_5, Vector5, 5; - array_vector_conversion_6, Vector6, 6; -); - -macro_rules! array_row_vector_conversion( - ($($array_vector_conversion_i: ident, $Vector: ident, $SZ: expr);* $(;)*) => {$( - #[test] - fn $array_vector_conversion_i() { - let v = $Vector::from_fn(|_, i| i); - let arr: [usize; $SZ] = v.into(); - let arr_ref = v.as_ref(); - let v2 = $Vector::from(arr); - - for i in 0 .. $SZ { - assert_eq!(arr[i], i); - assert_eq!(arr_ref[i], i); - } - - assert_eq!(v, v2); - } - )*} -); - -array_row_vector_conversion!( - array_row_vector_conversion_1, RowVector1, 1; - array_row_vector_conversion_2, RowVector2, 2; - array_row_vector_conversion_3, RowVector3, 3; - array_row_vector_conversion_4, RowVector4, 4; - array_row_vector_conversion_5, RowVector5, 5; - array_row_vector_conversion_6, RowVector6, 6; -); - -macro_rules! array_matrix_conversion( - ($($array_matrix_conversion_i_j: ident, $Matrix: ident, ($NRows: expr, $NCols: expr));* $(;)*) => {$( - #[test] - fn $array_matrix_conversion_i_j() { - let m = $Matrix::from_fn(|i, j| i * 10 + j); - let arr: [[usize; $NRows]; $NCols] = m.into(); - let arr_ref = m.as_ref(); - let m2 = $Matrix::from(arr); - - for i in 0 .. $NRows { - for j in 0 .. $NCols { - assert_eq!(arr[j][i], i * 10 + j); - assert_eq!(arr_ref[j][i], i * 10 + j); - } - } - - assert_eq!(m, m2); - } - )*} -); - -array_matrix_conversion!( - array_matrix_conversion_2_2, Matrix2, (2, 2); - array_matrix_conversion_2_3, Matrix2x3, (2, 3); - array_matrix_conversion_2_4, Matrix2x4, (2, 4); - array_matrix_conversion_2_5, Matrix2x5, (2, 5); - array_matrix_conversion_2_6, Matrix2x6, (2, 6); - - array_matrix_conversion_3_2, Matrix3x2, (3, 2); - array_matrix_conversion_3_3, Matrix3, (3, 3); - array_matrix_conversion_3_4, Matrix3x4, (3, 4); - array_matrix_conversion_3_5, Matrix3x5, (3, 5); - array_matrix_conversion_3_6, Matrix3x6, (3, 6); - - array_matrix_conversion_4_2, Matrix4x2, (4, 2); - array_matrix_conversion_4_3, Matrix4x3, (4, 3); - array_matrix_conversion_4_4, Matrix4, (4, 4); - array_matrix_conversion_4_5, Matrix4x5, (4, 5); - array_matrix_conversion_4_6, Matrix4x6, (4, 6); - - array_matrix_conversion_5_2, Matrix5x2, (5, 2); - array_matrix_conversion_5_3, Matrix5x3, (5, 3); - array_matrix_conversion_5_4, Matrix5x4, (5, 4); - array_matrix_conversion_5_5, Matrix5, (5, 5); - array_matrix_conversion_5_6, Matrix5x6, (5, 6); - - array_matrix_conversion_6_2, Matrix6x2, (6, 2); - array_matrix_conversion_6_3, Matrix6x3, (6, 3); - array_matrix_conversion_6_4, Matrix6x4, (6, 4); - array_matrix_conversion_6_5, Matrix6x5, (6, 5); - array_matrix_conversion_6_6, Matrix6, (6, 6); -); - -#[test] -fn matrix_slice_from_matrix_ref() { - let a = Matrix3x4::new( - 11.0, 12.0, 13.0, 14.0, 21.0, 22.0, 23.0, 24.0, 31.0, 32.0, 33.0, 34.0, - ); - - // TODO: What's a more idiomatic/better way to convert a static matrix to a dynamic one? - let d = DMatrix::from(a.get((0..a.nrows(), 0..a.ncols())).unwrap()); - - // Note: these have to be macros, and not functions, because the input type is different - // across the different tests. Moreover, the output type depends on the stride of the input, - // which is different for static and dynamic matrices. - macro_rules! dynamic_view { - ($mref:expr) => { - DMatrixView::<_>::from($mref) - }; - } - macro_rules! dynamic_view_mut { - ($mref:expr) => { - DMatrixViewMut::<_>::from($mref) - }; - } - macro_rules! fixed_view { - ($mref:expr) => { - MatrixView::<_, U3, U4, U1, U3>::from($mref) - }; - } - macro_rules! fixed_view_mut { - ($mref:expr) => { - MatrixViewMut::<_, U3, U4, U1, U3>::from($mref) - }; - } - - // TODO: The `into_owned()` is a result of `PartialEq` not being implemented for different - // Self and RHS. See issue #674. Once this is implemented, we can remove `into_owned` - // from the below tests. - - // Construct views from reference to a - { - assert_eq!(a, fixed_view!(&a).into_owned()); - assert_eq!(d, dynamic_view!(&a).into_owned()); - } - - // Construct views from mutable reference to a - { - let mut a_clone = a.clone(); - assert_eq!(a, fixed_view!(&mut a_clone).into_owned()); - assert_eq!(d, dynamic_view!(&mut a_clone).into_owned()); - } - - // Construct mutable slices from mutable reference to a - { - let mut a_clone = a.clone(); - assert_eq!(a, fixed_view_mut!(&mut a_clone).into_owned()); - assert_eq!(d, dynamic_view_mut!(&mut a_clone).into_owned()); - } - - // Construct slices from reference to d - { - assert_eq!(a, fixed_view!(&d).into_owned()); - assert_eq!(d, dynamic_view!(&d).into_owned()); - } - - // Construct slices from mutable reference to d - { - let mut d_clone = a.clone(); - assert_eq!(a, fixed_view!(&mut d_clone).into_owned()); - assert_eq!(d, dynamic_view!(&mut d_clone).into_owned()); - } - - // Construct mutable slices from mutable reference to d - { - let mut d_clone = d.clone(); - assert_eq!(a, fixed_view_mut!(&mut d_clone).into_owned()); - assert_eq!(d, dynamic_view_mut!(&mut d_clone).into_owned()); - } - - // Construct slices from a slice of a - { - let mut a_slice = fixed_view!(&a); - assert_eq!(a, fixed_view!(&a_slice).into_owned()); - assert_eq!(a, fixed_view!(&mut a_slice).into_owned()); - assert_eq!(d, dynamic_view!(&a_slice).into_owned()); - assert_eq!(d, dynamic_view!(&mut a_slice).into_owned()); - } - - // Construct slices from a slice mut of a - { - // Need a clone of a here, so that we can both have a mutable borrow and compare equality - let mut a_clone = a.clone(); - let mut a_slice = fixed_view_mut!(&mut a_clone); - - assert_eq!(a, fixed_view!(&a_slice).into_owned()); - assert_eq!(a, fixed_view!(&mut a_slice).into_owned()); - assert_eq!(d, dynamic_view!(&a_slice).into_owned()); - assert_eq!(d, dynamic_view!(&mut a_slice).into_owned()); - assert_eq!(a, fixed_view_mut!(&mut a_slice).into_owned()); - assert_eq!(d, dynamic_view_mut!(&mut a_slice).into_owned()); - } -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/edition.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/edition.rs deleted file mode 100644 index f2444996d..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/edition.rs +++ /dev/null @@ -1,702 +0,0 @@ -use na::{ - DMatrix, Matrix, Matrix3, Matrix3x4, Matrix3x5, Matrix4, Matrix4x3, Matrix4x5, Matrix5, - Matrix5x3, Matrix5x4, -}; -use na::{Dyn, U3, U5}; - -#[test] -#[rustfmt::skip] -fn upper_lower_triangular() { - let m = Matrix4::new( - 11.0, 12.0, 13.0, 14.0, - 21.0, 22.0, 23.0, 24.0, - 31.0, 32.0, 33.0, 34.0, - 41.0, 42.0, 43.0, 44.0); - - let um = Matrix4::new( - 11.0, 12.0, 13.0, 14.0, - 0.0, 22.0, 23.0, 24.0, - 0.0, 0.0, 33.0, 34.0, - 0.0, 0.0, 0.0, 44.0); - - let lm = Matrix4::new( - 11.0, 0.0, 0.0, 0.0, - 21.0, 22.0, 0.0, 0.0, - 31.0, 32.0, 33.0, 0.0, - 41.0, 42.0, 43.0, 44.0); - - let computed_um = m.upper_triangle(); - let computed_lm = m.lower_triangle(); - - assert_eq!(um, computed_um); - assert_eq!(lm, computed_lm); - - let symm_um = Matrix4::new( - 11.0, 12.0, 13.0, 14.0, - 12.0, 22.0, 23.0, 24.0, - 13.0, 23.0, 33.0, 34.0, - 14.0, 24.0, 34.0, 44.0); - - let symm_lm = Matrix4::new( - 11.0, 21.0, 31.0, 41.0, - 21.0, 22.0, 32.0, 42.0, - 31.0, 32.0, 33.0, 43.0, - 41.0, 42.0, 43.0, 44.0); - - let mut computed_symm_um = m.clone(); - let mut computed_symm_lm = m.clone(); - - computed_symm_um.fill_lower_triangle_with_upper_triangle(); - computed_symm_lm.fill_upper_triangle_with_lower_triangle(); - assert_eq!(symm_um, computed_symm_um); - assert_eq!(symm_lm, computed_symm_lm); - - - let m = Matrix5x3::new( - 11.0, 12.0, 13.0, - 21.0, 22.0, 23.0, - 31.0, 32.0, 33.0, - 41.0, 42.0, 43.0, - 51.0, 52.0, 53.0); - - let um = Matrix5x3::new( - 11.0, 12.0, 13.0, - 0.0, 22.0, 23.0, - 0.0, 0.0, 33.0, - 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0); - - let lm = Matrix5x3::new( - 11.0, 0.0, 0.0, - 21.0, 22.0, 0.0, - 31.0, 32.0, 33.0, - 41.0, 42.0, 43.0, - 51.0, 52.0, 53.0); - - let computed_um = m.upper_triangle(); - let computed_lm = m.lower_triangle(); - - assert_eq!(um, computed_um); - assert_eq!(lm, computed_lm); - - - let m = Matrix3x5::new( - 11.0, 12.0, 13.0, 14.0, 15.0, - 21.0, 22.0, 23.0, 24.0, 25.0, - 31.0, 32.0, 33.0, 34.0, 35.0); - - let um = Matrix3x5::new( - 11.0, 12.0, 13.0, 14.0, 15.0, - 0.0, 22.0, 23.0, 24.0, 25.0, - 0.0, 0.0, 33.0, 34.0, 35.0); - - let lm = Matrix3x5::new( - 11.0, 0.0, 0.0, 0.0, 0.0, - 21.0, 22.0, 0.0, 0.0, 0.0, - 31.0, 32.0, 33.0, 0.0, 0.0); - - let computed_um = m.upper_triangle(); - let computed_lm = m.lower_triangle(); - - assert_eq!(um, computed_um); - assert_eq!(lm, computed_lm); - - let mut m = Matrix4x5::new( - 11.0, 12.0, 13.0, 14.0, 15.0, - 21.0, 22.0, 23.0, 24.0, 25.0, - 31.0, 32.0, 33.0, 34.0, 35.0, - 41.0, 42.0, 43.0, 44.0, 45.0); - - let expected_m = Matrix4x5::new( - 11.0, 12.0, 0.0, 0.0, 0.0, - 21.0, 22.0, 23.0, 0.0, 0.0, - 31.0, 32.0, 33.0, 34.0, 0.0, - 41.0, 42.0, 43.0, 44.0, 45.0); - - m.fill_upper_triangle(0.0, 2); - - assert_eq!(m, expected_m); - - let mut m = Matrix4x5::new( - 11.0, 12.0, 13.0, 14.0, 15.0, - 21.0, 22.0, 23.0, 24.0, 25.0, - 31.0, 32.0, 33.0, 34.0, 35.0, - 41.0, 42.0, 43.0, 44.0, 45.0); - - let expected_m = Matrix4x5::new( - 11.0, 12.0, 13.0, 14.0, 15.0, - 21.0, 22.0, 23.0, 24.0, 25.0, - 0.0, 32.0, 33.0, 34.0, 35.0, - 0.0, 0.0, 43.0, 44.0, 45.0); - - m.fill_lower_triangle(0.0, 2); - - assert_eq!(m, expected_m); - - let mut m = Matrix5x4::new( - 11.0, 12.0, 13.0, 14.0, - 21.0, 22.0, 23.0, 24.0, - 31.0, 32.0, 33.0, 34.0, - 41.0, 42.0, 43.0, 44.0, - 51.0, 52.0, 53.0, 54.0); - - let expected_m = Matrix5x4::new( - 11.0, 12.0, 0.0, 0.0, - 21.0, 22.0, 23.0, 0.0, - 31.0, 32.0, 33.0, 34.0, - 41.0, 42.0, 43.0, 44.0, - 51.0, 52.0, 53.0, 54.0); - - m.fill_upper_triangle(0.0, 2); - - assert_eq!(m, expected_m); - - let mut m = Matrix5x4::new( - 11.0, 12.0, 13.0, 14.0, - 21.0, 22.0, 23.0, 24.0, - 31.0, 32.0, 33.0, 34.0, - 41.0, 42.0, 43.0, 44.0, - 51.0, 52.0, 53.0, 54.0); - - let expected_m = Matrix5x4::new( - 11.0, 12.0, 13.0, 14.0, - 21.0, 22.0, 23.0, 24.0, - 0.0, 32.0, 33.0, 34.0, - 0.0, 0.0, 43.0, 44.0, - 0.0, 0.0, 0.0, 54.0); - - m.fill_lower_triangle(0.0, 2); - - assert_eq!(m, expected_m); -} - -#[test] -#[rustfmt::skip] -fn swap_rows() { - let mut m = Matrix5x3::new( - 11.0, 12.0, 13.0, - 21.0, 22.0, 23.0, - 31.0, 32.0, 33.0, - 41.0, 42.0, 43.0, - 51.0, 52.0, 53.0); - - let expected = Matrix5x3::new( - 11.0, 12.0, 13.0, - 41.0, 42.0, 43.0, - 31.0, 32.0, 33.0, - 21.0, 22.0, 23.0, - 51.0, 52.0, 53.0); - - m.swap_rows(1, 3); - - assert_eq!(m, expected); -} - -#[test] -#[rustfmt::skip] -fn swap_columns() { - let mut m = Matrix3x5::new( - 11.0, 12.0, 13.0, 14.0, 15.0, - 21.0, 22.0, 23.0, 24.0, 25.0, - 31.0, 32.0, 33.0, 34.0, 35.0); - - let expected = Matrix3x5::new( - 11.0, 14.0, 13.0, 12.0, 15.0, - 21.0, 24.0, 23.0, 22.0, 25.0, - 31.0, 34.0, 33.0, 32.0, 35.0); - - m.swap_columns(1, 3); - - assert_eq!(m, expected); -} - -#[test] -#[rustfmt::skip] -fn remove_columns() { - let m = Matrix3x5::new( - 11, 12, 13, 14, 15, - 21, 22, 23, 24, 25, - 31, 32, 33, 34, 35); - - let expected_a1 = Matrix3x4::new( - 12, 13, 14, 15, - 22, 23, 24, 25, - 32, 33, 34, 35); - - let expected_a2 = Matrix3x4::new( - 11, 12, 13, 14, - 21, 22, 23, 24, - 31, 32, 33, 34); - - let expected_a3 = Matrix3x4::new( - 11, 12, 14, 15, - 21, 22, 24, 25, - 31, 32, 34, 35); - - assert_eq!(m.remove_column(0), expected_a1); - assert_eq!(m.remove_column(4), expected_a2); - assert_eq!(m.remove_column(2), expected_a3); - - let expected_b1 = Matrix3::new( - 13, 14, 15, - 23, 24, 25, - 33, 34, 35); - - let expected_b2 = Matrix3::new( - 11, 12, 13, - 21, 22, 23, - 31, 32, 33); - - let expected_b3 = Matrix3::new( - 11, 12, 15, - 21, 22, 25, - 31, 32, 35); - - assert_eq!(m.remove_fixed_columns::<2>(0), expected_b1); - assert_eq!(m.remove_fixed_columns::<2>(3), expected_b2); - assert_eq!(m.remove_fixed_columns::<2>(2), expected_b3); - - // The following is just to verify that the return type dimensions is correctly inferred. - let computed: Matrix<_, U3, Dyn, _> = m.remove_columns(3, 2); - 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] -#[rustfmt::skip] -fn remove_columns_at() { - let m = DMatrix::from_row_slice(5, 5, &[ - 11, 12, 13, 14, 15, - 21, 22, 23, 24, 25, - 31, 32, 33, 34, 35, - 41, 42, 43, 44, 45, - 51, 52, 53, 54, 55 - ]); - - let expected1 = DMatrix::from_row_slice(5, 4, &[ - 12, 13, 14, 15, - 22, 23, 24, 25, - 32, 33, 34, 35, - 42, 43, 44, 45, - 52, 53, 54, 55 - ]); - - assert_eq!(m.remove_columns_at(&[0]), expected1); - - let m = DMatrix::from_row_slice(5, 5, &[ - 11, 12, 13, 14, 15, - 21, 22, 23, 24, 25, - 31, 32, 33, 34, 35, - 41, 42, 43, 44, 45, - 51, 52, 53, 54, 55 - ]); - - let expected2 = DMatrix::from_row_slice(5, 3, &[ - 11, 13, 15, - 21, 23, 25, - 31, 33, 35, - 41, 43, 45, - 51, 53, 55 - ]); - - assert_eq!(m.remove_columns_at(&[1,3]), expected2); - - let m = DMatrix::from_row_slice(5, 5, &[ - 11, 12, 13, 14, 15, - 21, 22, 23, 24, 25, - 31, 32, 33, 34, 35, - 41, 42, 43, 44, 45, - 51, 52, 53, 54, 55 - ]); - - let expected3 = DMatrix::from_row_slice(5, 2, &[ - 12, 13, - 22, 23, - 32, 33, - 42, 43, - 52, 53, - ]); - - assert_eq!(m.remove_columns_at(&[0,3,4]), expected3); -} - -#[test] -#[rustfmt::skip] -fn remove_rows() { - let m = Matrix5x3::new( - 11, 12, 13, - 21, 22, 23, - 31, 32, 33, - 41, 42, 43, - 51, 52, 53); - - let expected1 = Matrix4x3::new( - 21, 22, 23, - 31, 32, 33, - 41, 42, 43, - 51, 52, 53); - - let expected2 = Matrix4x3::new( - 11, 12, 13, - 21, 22, 23, - 31, 32, 33, - 41, 42, 43); - - let expected3 = Matrix4x3::new( - 11, 12, 13, - 21, 22, 23, - 41, 42, 43, - 51, 52, 53); - - assert_eq!(m.remove_row(0), expected1); - assert_eq!(m.remove_row(4), expected2); - assert_eq!(m.remove_row(2), expected3); - - let expected1 = Matrix3::new( - 31, 32, 33, - 41, 42, 43, - 51, 52, 53); - - let expected2 = Matrix3::new( - 11, 12, 13, - 21, 22, 23, - 31, 32, 33); - - let expected3 = Matrix3::new( - 11, 12, 13, - 21, 22, 23, - 51, 52, 53); - - assert_eq!(m.remove_fixed_rows::<2>(0), expected1); - assert_eq!(m.remove_fixed_rows::<2>(3), expected2); - assert_eq!(m.remove_fixed_rows::<2>(2), expected3); - - // The following is just to verify that the return type dimensions is correctly inferred. - let computed: Matrix<_, Dyn, U3, _> = m.remove_rows(3, 2); - assert!(computed.eq(&expected2)); -} - -#[test] -#[rustfmt::skip] -fn remove_rows_at() { - let m = DMatrix::from_row_slice(5, 5, &[ - 11, 12, 13, 14, 15, - 21, 22, 23, 24, 25, - 31, 32, 33, 34, 35, - 41, 42, 43, 44, 45, - 51, 52, 53, 54, 55 - ]); - - let expected1 = DMatrix::from_row_slice(4, 5, &[ - 21, 22, 23, 24, 25, - 31, 32, 33, 34, 35, - 41, 42, 43, 44, 45, - 51, 52, 53, 54, 55 - ]); - - assert_eq!(m.remove_rows_at(&[0]), expected1); - - let m = DMatrix::from_row_slice(5, 5, &[ - 11, 12, 13, 14, 15, - 21, 22, 23, 24, 25, - 31, 32, 33, 34, 35, - 41, 42, 43, 44, 45, - 51, 52, 53, 54, 55 - ]); - - let expected2 = DMatrix::from_row_slice(3, 5, &[ - 11, 12, 13, 14, 15, - 31, 32, 33, 34, 35, - 51, 52, 53, 54, 55 - ]); - - assert_eq!(m.remove_rows_at(&[1,3]), expected2); - - let m = DMatrix::from_row_slice(5, 5, &[ - 11, 12, 13, 14, 15, - 21, 22, 23, 24, 25, - 31, 32, 33, 34, 35, - 41, 42, 43, 44, 45, - 51, 52, 53, 54, 55 - ]); - - let expected3 = DMatrix::from_row_slice(2, 5, &[ - 21, 22, 23, 24, 25, - 31, 32, 33, 34, 35 - ]); - - assert_eq!(m.remove_rows_at(&[0,3,4]), expected3); -} - -#[test] -#[rustfmt::skip] -fn insert_columns() { - let m = Matrix5x3::new( - 11, 12, 13, - 21, 22, 23, - 31, 32, 33, - 41, 42, 43, - 51, 52, 53); - - let expected1 = Matrix5x4::new( - 0, 11, 12, 13, - 0, 21, 22, 23, - 0, 31, 32, 33, - 0, 41, 42, 43, - 0, 51, 52, 53); - - let expected2 = Matrix5x4::new( - 11, 12, 13, 0, - 21, 22, 23, 0, - 31, 32, 33, 0, - 41, 42, 43, 0, - 51, 52, 53, 0); - - let expected3 = Matrix5x4::new( - 11, 12, 0, 13, - 21, 22, 0, 23, - 31, 32, 0, 33, - 41, 42, 0, 43, - 51, 52, 0, 53); - - assert_eq!(m.insert_column(0, 0), expected1); - assert_eq!(m.insert_column(3, 0), expected2); - assert_eq!(m.insert_column(2, 0), expected3); - - let expected1 = Matrix5::new( - 0, 0, 11, 12, 13, - 0, 0, 21, 22, 23, - 0, 0, 31, 32, 33, - 0, 0, 41, 42, 43, - 0, 0, 51, 52, 53); - - let expected2 = Matrix5::new( - 11, 12, 13, 0, 0, - 21, 22, 23, 0, 0, - 31, 32, 33, 0, 0, - 41, 42, 43, 0, 0, - 51, 52, 53, 0, 0); - - let expected3 = Matrix5::new( - 11, 12, 0, 0, 13, - 21, 22, 0, 0, 23, - 31, 32, 0, 0, 33, - 41, 42, 0, 0, 43, - 51, 52, 0, 0, 53); - - assert_eq!(m.insert_fixed_columns::<2>(0, 0), expected1); - assert_eq!(m.insert_fixed_columns::<2>(3, 0), expected2); - assert_eq!(m.insert_fixed_columns::<2>(2, 0), expected3); - - // The following is just to verify that the return type dimensions is correctly inferred. - let computed: Matrix<_, U5, Dyn, _> = m.insert_columns(3, 2, 0); - assert!(computed.eq(&expected2)); -} - -#[test] -#[rustfmt::skip] -fn insert_columns_to_empty_matrix() { - let m1 = DMatrix::repeat(0, 0, 0); - let m2 = DMatrix::repeat(3, 0, 0); - - let expected1 = DMatrix::repeat(0, 5, 42); - let expected2 = DMatrix::repeat(3, 5, 42); - - assert_eq!(expected1, m1.insert_columns(0, 5, 42)); - assert_eq!(expected2, m2.insert_columns(0, 5, 42)); -} - -#[test] -#[rustfmt::skip] -fn insert_rows() { - let m = Matrix3x5::new( - 11, 12, 13, 14, 15, - 21, 22, 23, 24, 25, - 31, 32, 33, 34, 35); - - let expected1 = Matrix4x5::new( - 0, 0, 0, 0, 0, - 11, 12, 13, 14, 15, - 21, 22, 23, 24, 25, - 31, 32, 33, 34, 35); - - let expected2 = Matrix4x5::new( - 11, 12, 13, 14, 15, - 21, 22, 23, 24, 25, - 31, 32, 33, 34, 35, - 0, 0, 0, 0, 0); - - let expected3 = Matrix4x5::new( - 11, 12, 13, 14, 15, - 21, 22, 23, 24, 25, - 0, 0, 0, 0, 0, - 31, 32, 33, 34, 35); - - assert_eq!(m.insert_row(0, 0), expected1); - assert_eq!(m.insert_row(3, 0), expected2); - assert_eq!(m.insert_row(2, 0), expected3); - - let expected1 = Matrix5::new( - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 11, 12, 13, 14, 15, - 21, 22, 23, 24, 25, - 31, 32, 33, 34, 35); - - let expected2 = Matrix5::new( - 11, 12, 13, 14, 15, - 21, 22, 23, 24, 25, - 31, 32, 33, 34, 35, - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0); - - let expected3 = Matrix5::new( - 11, 12, 13, 14, 15, - 21, 22, 23, 24, 25, - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 31, 32, 33, 34, 35); - - assert_eq!(m.insert_fixed_rows::<2>(0, 0), expected1); - assert_eq!(m.insert_fixed_rows::<2>(3, 0), expected2); - assert_eq!(m.insert_fixed_rows::<2>(2, 0), expected3); - - // The following is just to verify that the return type dimensions is correctly inferred. - let computed: Matrix<_, Dyn, U5, _> = m.insert_rows(3, 2, 0); - assert!(computed.eq(&expected2)); -} - -#[test] -fn insert_rows_to_empty_matrix() { - let m1 = DMatrix::repeat(0, 0, 0); - let m2 = DMatrix::repeat(0, 5, 0); - - let expected1 = DMatrix::repeat(3, 0, 42); - let expected2 = DMatrix::repeat(3, 5, 42); - - assert_eq!(expected1, m1.insert_rows(0, 3, 42)); - assert_eq!(expected2, m2.insert_rows(0, 3, 42)); -} - -#[test] -#[rustfmt::skip] -fn resize() { - let m = Matrix3x5::new( - 11, 12, 13, 14, 15, - 21, 22, 23, 24, 25, - 31, 32, 33, 34, 35); - - let add_colls = DMatrix::from_row_slice(3, 6, &[ - 11, 12, 13, 14, 15, 42, - 21, 22, 23, 24, 25, 42, - 31, 32, 33, 34, 35, 42]); - - let del_colls = DMatrix::from_row_slice(3, 4, &[ - 11, 12, 13, 14, - 21, 22, 23, 24, - 31, 32, 33, 34]); - - let add_rows = DMatrix::from_row_slice(4, 5, &[ - 11, 12, 13, 14, 15, - 21, 22, 23, 24, 25, - 31, 32, 33, 34, 35, - 42, 42, 42, 42, 42]); - - let del_rows = DMatrix::from_row_slice(2, 5, &[ - 11, 12, 13, 14, 15, - 21, 22, 23, 24, 25]); - - let add_add = DMatrix::from_row_slice(5, 6, &[ - 11, 12, 13, 14, 15, 42, - 21, 22, 23, 24, 25, 42, - 31, 32, 33, 34, 35, 42, - 42, 42, 42, 42, 42, 42, - 42, 42, 42, 42, 42, 42]); - - let del_del = DMatrix::from_row_slice(1, 2, &[11, 12]); - - let add_del = DMatrix::from_row_slice(5, 2, &[ - 11, 12, - 21, 22, - 31, 32, - 42, 42, - 42, 42]); - - let del_add = DMatrix::from_row_slice(1, 8, &[ - 11, 12, 13, 14, 15, 42, 42, 42]); - - assert_eq!(add_colls, m.resize(3, 6, 42)); - assert_eq!(del_colls, m.resize(3, 4, 42)); - assert_eq!(add_rows, m.resize(4, 5, 42)); - assert_eq!(del_rows, m.resize(2, 5, 42)); - assert_eq!(del_del, m.resize(1, 2, 42)); - assert_eq!(add_add, m.resize(5, 6, 42)); - assert_eq!(add_del, m.resize(5, 2, 42)); - assert_eq!(del_add, m.resize(1, 8, 42)); -} - -#[test] -fn resize_empty_matrix() { - let m1 = DMatrix::repeat(0, 0, 0); - let m2 = DMatrix::repeat(1, 0, 0); // Less rows than target size. - let m3 = DMatrix::repeat(3, 0, 0); // Same rows as target size. - let m4 = DMatrix::repeat(9, 0, 0); // More rows than target size. - let m5 = DMatrix::repeat(0, 1, 0); // Less columns than target size. - let m6 = DMatrix::repeat(0, 5, 0); // Same columns as target size. - let m7 = DMatrix::repeat(0, 9, 0); // More columns than target size. - - let resized = DMatrix::repeat(3, 5, 42); - let resized_wo_rows = DMatrix::repeat(0, 5, 42); - let resized_wo_cols = DMatrix::repeat(3, 0, 42); - - assert_eq!(resized, m1.clone().resize(3, 5, 42)); - assert_eq!(resized, m2.clone().resize(3, 5, 42)); - assert_eq!(resized, m3.clone().resize(3, 5, 42)); - assert_eq!(resized, m4.clone().resize(3, 5, 42)); - assert_eq!(resized, m5.clone().resize(3, 5, 42)); - assert_eq!(resized, m6.clone().resize(3, 5, 42)); - assert_eq!(resized, m7.clone().resize(3, 5, 42)); - - assert_eq!(resized_wo_rows, m1.clone().resize(0, 5, 42)); - assert_eq!(resized_wo_rows, m2.clone().resize(0, 5, 42)); - assert_eq!(resized_wo_rows, m3.clone().resize(0, 5, 42)); - assert_eq!(resized_wo_rows, m4.clone().resize(0, 5, 42)); - assert_eq!(resized_wo_rows, m5.clone().resize(0, 5, 42)); - assert_eq!(resized_wo_rows, m6.clone().resize(0, 5, 42)); - assert_eq!(resized_wo_rows, m7.clone().resize(0, 5, 42)); - - assert_eq!(resized_wo_cols, m1.clone().resize(3, 0, 42)); - assert_eq!(resized_wo_cols, m2.clone().resize(3, 0, 42)); - assert_eq!(resized_wo_cols, m3.clone().resize(3, 0, 42)); - assert_eq!(resized_wo_cols, m4.clone().resize(3, 0, 42)); - assert_eq!(resized_wo_cols, m5.clone().resize(3, 0, 42)); - assert_eq!(resized_wo_cols, m6.clone().resize(3, 0, 42)); - assert_eq!(resized_wo_cols, m7.clone().resize(3, 0, 42)); - - assert_eq!(m1, m1.clone().resize(0, 0, 42)); - assert_eq!(m1, m2.resize(0, 0, 42)); - assert_eq!(m1, m3.resize(0, 0, 42)); - assert_eq!(m1, m4.resize(0, 0, 42)); - assert_eq!(m1, m5.resize(0, 0, 42)); - assert_eq!(m1, m6.resize(0, 0, 42)); - assert_eq!(m1, m7.resize(0, 0, 42)); -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/empty.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/empty.rs deleted file mode 100644 index 955424f6f..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/empty.rs +++ /dev/null @@ -1,60 +0,0 @@ -use na::{DMatrix, DVector}; - -#[test] -fn empty_matrix_mul_vector() { - // Issue #644 - let m = DMatrix::::zeros(8, 0); - let v = DVector::::zeros(0); - assert_eq!(m * v, DVector::zeros(8)); -} - -#[test] -fn empty_matrix_mul_matrix() { - let m1 = DMatrix::::zeros(3, 0); - let m2 = DMatrix::::zeros(0, 4); - assert_eq!(m1 * m2, DMatrix::zeros(3, 4)); - - // Still works with larger matrices. - let m1 = DMatrix::::zeros(13, 0); - let m2 = DMatrix::::zeros(0, 14); - assert_eq!(m1 * m2, DMatrix::zeros(13, 14)); -} - -#[test] -fn empty_matrix_tr_mul_vector() { - let m = DMatrix::::zeros(0, 5); - let v = DVector::::zeros(0); - assert_eq!(m.tr_mul(&v), DVector::zeros(5)); -} - -#[test] -fn empty_matrix_tr_mul_matrix() { - let m1 = DMatrix::::zeros(0, 3); - let m2 = DMatrix::::zeros(0, 4); - assert_eq!(m1.tr_mul(&m2), DMatrix::zeros(3, 4)); -} - -#[test] -fn empty_matrix_gemm() { - let mut res = DMatrix::repeat(3, 4, 1.0); - let m1 = DMatrix::::zeros(3, 0); - let m2 = DMatrix::::zeros(0, 4); - res.gemm(1.0, &m1, &m2, 0.5); - assert_eq!(res, DMatrix::repeat(3, 4, 0.5)); - - // Still works with lager matrices. - let mut res = DMatrix::repeat(13, 14, 1.0); - let m1 = DMatrix::::zeros(13, 0); - let m2 = DMatrix::::zeros(0, 14); - res.gemm(1.0, &m1, &m2, 0.5); - assert_eq!(res, DMatrix::repeat(13, 14, 0.5)); -} - -#[test] -fn empty_matrix_gemm_tr() { - let mut res = DMatrix::repeat(3, 4, 1.0); - let m1 = DMatrix::::zeros(0, 3); - let m2 = DMatrix::::zeros(0, 4); - res.gemm_tr(1.0, &m1, &m2, 0.5); - assert_eq!(res, DMatrix::repeat(3, 4, 0.5)); -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/helper.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/helper.rs deleted file mode 100644 index 5f6a6183f..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/helper.rs +++ /dev/null @@ -1,56 +0,0 @@ -// This module implement several methods to fill some -// missing features of num-complex when it comes to randomness. - -use na::RealField; -use num_complex::Complex; -use quickcheck::{Arbitrary, Gen}; -use rand::distributions::{Distribution, Standard}; -use rand::Rng; - -#[derive(Copy, Clone, Debug, PartialEq, Eq)] -pub struct RandComplex(pub Complex); - -impl Arbitrary for RandComplex { - #[inline] - fn arbitrary(rng: &mut Gen) -> Self { - let im = Arbitrary::arbitrary(rng); - let re = Arbitrary::arbitrary(rng); - RandComplex(Complex::new(re, im)) - } -} - -impl Distribution> for Standard -where - Standard: Distribution, -{ - #[inline] - fn sample<'a, G: Rng + ?Sized>(&self, rng: &'a mut G) -> RandComplex { - let re = rng.gen(); - let im = rng.gen(); - RandComplex(Complex::new(re, im)) - } -} - -// This is a wrapper similar to RandComplex, but for non-complex. -// This exists only to make generic tests easier to write. -// -// Generates variates in the range [0, 1). -#[derive(Copy, Clone, Debug, PartialEq, Eq)] -pub struct RandScalar(pub T); - -impl Arbitrary for RandScalar { - #[inline] - fn arbitrary(rng: &mut Gen) -> Self { - RandScalar(Arbitrary::arbitrary(rng)) - } -} - -impl Distribution> for Standard -where - Standard: Distribution, -{ - #[inline] - fn sample<'a, G: Rng + ?Sized>(&self, rng: &'a mut G) -> RandScalar { - RandScalar(self.sample(rng)) - } -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/macros.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/macros.rs deleted file mode 100644 index 5a75dc616..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/macros.rs +++ /dev/null @@ -1,12 +0,0 @@ -use nalgebra::{dmatrix, dvector, matrix, point, vector}; - -#[test] -fn sanity_test() { - // The macros are already tested in `nalgebra-macros`. Here we just test that they compile fine. - - let _ = matrix![1, 2, 3; 4, 5, 6]; - let _ = dmatrix![1, 2, 3; 4, 5, 6]; - let _ = point![1, 2, 3, 4, 5, 6]; - let _ = vector![1, 2, 3, 4, 5, 6]; - let _ = dvector![1, 2, 3, 4, 5, 6]; -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/matrix.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/matrix.rs deleted file mode 100644 index f7d788eeb..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/matrix.rs +++ /dev/null @@ -1,1344 +0,0 @@ -use na::iter::MatrixIter; -use num::{One, Zero}; -use std::cmp::Ordering; - -use na::dimension::{U15, U8}; -use na::{ - self, Const, DMatrix, DVector, Matrix2, Matrix2x3, Matrix2x4, Matrix3, Matrix3x2, Matrix3x4, - Matrix4, Matrix4x3, Matrix4x5, Matrix5, Matrix6, MatrixView2x3, MatrixViewMut2x3, OMatrix, - RowVector3, RowVector4, RowVector5, Vector1, Vector2, Vector3, Vector4, Vector5, Vector6, -}; - -#[test] -fn iter() { - let a = Matrix2x3::new(1.0, 2.0, 3.0, 4.0, 5.0, 6.0); - let view: MatrixView2x3<_> = (&a).into(); - - fn test<'a, F: Fn() -> I, I: Iterator + DoubleEndedIterator>(it: F) { - { - let mut it = it(); - assert_eq!(*it.next().unwrap(), 1.0); - assert_eq!(*it.next().unwrap(), 4.0); - assert_eq!(*it.next().unwrap(), 2.0); - assert_eq!(*it.next().unwrap(), 5.0); - assert_eq!(*it.next().unwrap(), 3.0); - assert_eq!(*it.next().unwrap(), 6.0); - assert!(it.next().is_none()); - } - - { - let mut it = it(); - assert_eq!(*it.next().unwrap(), 1.0); - assert_eq!(*it.next_back().unwrap(), 6.0); - assert_eq!(*it.next_back().unwrap(), 3.0); - assert_eq!(*it.next_back().unwrap(), 5.0); - assert_eq!(*it.next().unwrap(), 4.0); - assert_eq!(*it.next().unwrap(), 2.0); - assert!(it.next().is_none()); - } - { - let mut it = it().rev(); - assert_eq!(*it.next().unwrap(), 6.0); - assert_eq!(*it.next().unwrap(), 3.0); - assert_eq!(*it.next().unwrap(), 5.0); - assert_eq!(*it.next().unwrap(), 2.0); - assert_eq!(*it.next().unwrap(), 4.0); - assert_eq!(*it.next().unwrap(), 1.0); - assert!(it.next().is_none()); - } - } - - test(|| a.iter()); - test(|| view.into_iter()); - - let row = a.row(0); - let row_test = |mut it: MatrixIter<_, _, _, _>| { - assert_eq!(*it.next().unwrap(), 1.0); - assert_eq!(*it.next().unwrap(), 2.0); - assert_eq!(*it.next().unwrap(), 3.0); - assert!(it.next().is_none()); - }; - row_test(row.iter()); - row_test(row.into_iter()); - - let row = a.row(1); - let row_test = |mut it: MatrixIter<_, _, _, _>| { - assert_eq!(*it.next().unwrap(), 4.0); - assert_eq!(*it.next().unwrap(), 5.0); - assert_eq!(*it.next().unwrap(), 6.0); - assert!(it.next().is_none()); - }; - row_test(row.iter()); - row_test(row.into_iter()); - - let m22 = row.column(1); - let m22_test = |mut it: MatrixIter<_, _, _, _>| { - assert_eq!(*it.next().unwrap(), 5.0); - assert!(it.next().is_none()); - }; - m22_test(m22.iter()); - m22_test(m22.into_iter()); - - let col = a.column(0); - let col_test = |mut it: MatrixIter<_, _, _, _>| { - assert_eq!(*it.next().unwrap(), 1.0); - assert_eq!(*it.next().unwrap(), 4.0); - assert!(it.next().is_none()); - }; - col_test(col.iter()); - col_test(col.into_iter()); - - let col = a.column(1); - let col_test = |mut it: MatrixIter<_, _, _, _>| { - assert_eq!(*it.next().unwrap(), 2.0); - assert_eq!(*it.next().unwrap(), 5.0); - assert!(it.next().is_none()); - }; - col_test(col.iter()); - col_test(col.into_iter()); - - let col = a.column(2); - let col_test = |mut it: MatrixIter<_, _, _, _>| { - assert_eq!(*it.next().unwrap(), 3.0); - assert_eq!(*it.next().unwrap(), 6.0); - assert!(it.next().is_none()); - }; - col_test(col.iter()); - col_test(col.into_iter()); -} - -#[test] -fn iter_mut() { - let mut a = Matrix2x3::new(1.0, 2.0, 3.0, 4.0, 5.0, 6.0); - - for v in a.iter_mut() { - *v *= 2.0; - } - assert_eq!(a, Matrix2x3::new(2.0, 4.0, 6.0, 8.0, 10.0, 12.0)); - - let view: MatrixViewMut2x3<_> = MatrixViewMut2x3::from(&mut a); - for v in view.into_iter() { - *v *= 2.0; - } - assert_eq!(a, Matrix2x3::new(4.0, 8.0, 12.0, 16.0, 20.0, 24.0)); -} - -#[test] -fn debug_output_corresponds_to_data_container() { - let m = Matrix2::new(1.0, 2.0, 3.0, 4.0); - let output_stable = "[[1, 3], [2, 4]]"; // Current output on the stable channel. - let output_nightly = "[[1.0, 3.0], [2.0, 4.0]]"; // Current output on the nightly channel. - let current_output = format!("{:?}", m); - dbg!(output_stable); - dbg!(output_nightly); - dbg!(¤t_output); - - assert!(current_output == output_stable || current_output == output_nightly); -} - -#[test] -fn is_column_major() { - let a = Matrix2x3::new(1.0, 2.0, 3.0, 4.0, 5.0, 6.0); - - let expected = &[1.0, 4.0, 2.0, 5.0, 3.0, 6.0]; - - assert_eq!(a.as_slice(), expected); - - let a = Matrix2x3::from_row_slice(&[1.0, 2.0, 3.0, 4.0, 5.0, 6.0]); - - assert_eq!(a.as_slice(), expected); - - let a = Matrix2x3::from_column_slice(&[1.0, 4.0, 2.0, 5.0, 3.0, 6.0]); - - assert_eq!(a.as_slice(), expected); -} - -#[test] -fn linear_index() { - let a = Matrix2x3::new(1, 2, 3, 4, 5, 6); - - assert_eq!(a[0], 1); - assert_eq!(a[1], 4); - assert_eq!(a[2], 2); - assert_eq!(a[3], 5); - assert_eq!(a[4], 3); - assert_eq!(a[5], 6); - - let b = Vector4::new(1, 2, 3, 4); - - assert_eq!(b[0], 1); - assert_eq!(b[1], 2); - assert_eq!(b[2], 3); - assert_eq!(b[3], 4); - - let c = RowVector4::new(1, 2, 3, 4); - - assert_eq!(c[0], 1); - assert_eq!(c[1], 2); - assert_eq!(c[2], 3); - assert_eq!(c[3], 4); -} - -#[test] -fn identity() { - let id1 = Matrix3::::identity(); - let id2 = Matrix3x4::new(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); - let id2bis = Matrix3x4::identity(); - let id3 = Matrix4x3::new(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0); - let id3bis = Matrix4x3::identity(); - - let not_id1 = Matrix3::identity() * 2.0; - let not_id2 = Matrix3x4::new(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0); - let not_id3 = Matrix4x3::new(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0); - - assert_eq!(id2, id2bis); - assert_eq!(id3, id3bis); - assert!(id1.is_identity(0.0)); - assert!(id2.is_identity(0.0)); - assert!(id3.is_identity(0.0)); - assert!(!not_id1.is_identity(0.0)); - assert!(!not_id2.is_identity(0.0)); - assert!(!not_id3.is_identity(0.0)); -} - -#[test] -fn coordinates() { - let a = Matrix3x4::new(11, 12, 13, 14, 21, 22, 23, 24, 31, 32, 33, 34); - - assert_eq!(a.m11, 11); - assert_eq!(a.m12, 12); - assert_eq!(a.m13, 13); - assert_eq!(a.m14, 14); - - assert_eq!(a.m21, 21); - assert_eq!(a.m22, 22); - assert_eq!(a.m23, 23); - assert_eq!(a.m24, 24); - - assert_eq!(a.m31, 31); - assert_eq!(a.m32, 32); - assert_eq!(a.m33, 33); - assert_eq!(a.m34, 34); -} - -#[test] -fn from_diagonal() { - let diag = Vector3::new(1, 2, 3); - let expected = Matrix3::new(1, 0, 0, 0, 2, 0, 0, 0, 3); - let a = Matrix3::from_diagonal(&diag); - - assert_eq!(a, expected); -} - -#[test] -fn from_rows() { - let rows = &[ - RowVector4::new(11, 12, 13, 14), - RowVector4::new(21, 22, 23, 24), - RowVector4::new(31, 32, 33, 34), - ]; - - let expected = Matrix3x4::new(11, 12, 13, 14, 21, 22, 23, 24, 31, 32, 33, 34); - - let a = Matrix3x4::from_rows(rows); - - assert_eq!(a, expected); -} - -#[test] -fn from_columns() { - let columns = &[ - Vector3::new(11, 21, 31), - Vector3::new(12, 22, 32), - Vector3::new(13, 23, 33), - Vector3::new(14, 24, 34), - ]; - - let expected = Matrix3x4::new(11, 12, 13, 14, 21, 22, 23, 24, 31, 32, 33, 34); - - let a = Matrix3x4::from_columns(columns); - - assert_eq!(a, expected); -} - -#[test] -fn from_columns_dynamic() { - let columns = &[ - DVector::from_row_slice(&[11, 21, 31]), - DVector::from_row_slice(&[12, 22, 32]), - DVector::from_row_slice(&[13, 23, 33]), - DVector::from_row_slice(&[14, 24, 34]), - ]; - - let expected = DMatrix::from_row_slice(3, 4, &[11, 12, 13, 14, 21, 22, 23, 24, 31, 32, 33, 34]); - - let a = DMatrix::from_columns(columns); - - assert_eq!(a, expected); -} - -#[test] -#[should_panic] -fn from_too_many_rows() { - let rows = &[ - RowVector4::new(11, 12, 13, 14), - RowVector4::new(21, 22, 23, 24), - RowVector4::new(31, 32, 33, 34), - RowVector4::new(31, 32, 33, 34), - ]; - - let _ = Matrix3x4::from_rows(rows); -} - -#[test] -#[should_panic] -fn from_not_enough_columns() { - let columns = &[Vector3::new(11, 21, 31), Vector3::new(14, 24, 34)]; - - let _ = Matrix3x4::from_columns(columns); -} - -#[test] -#[should_panic] -fn from_rows_with_different_dimensions() { - let columns = &[ - DVector::from_row_slice(&[11, 21, 31]), - DVector::from_row_slice(&[12, 22, 32, 33]), - ]; - - let _ = DMatrix::from_columns(columns); -} - -#[test] -fn copy_from_slice() { - let mut a = Matrix3::zeros(); - let data = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]; - let expected_a = Matrix3::new(1.0, 4.0, 7.0, 2.0, 5.0, 8.0, 3.0, 6.0, 9.0); - - a.copy_from_slice(&data); - - assert_eq!(a, expected_a); -} - -#[should_panic] -#[test] -fn copy_from_slice_too_small() { - let mut a = Matrix3::zeros(); - let data = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]; - a.copy_from_slice(&data); -} - -#[should_panic] -#[test] -fn copy_from_slice_too_large() { - let mut a = Matrix3::zeros(); - let data = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0]; - a.copy_from_slice(&data); -} - -#[test] -fn to_homogeneous() { - let a = Vector3::new(1.0, 2.0, 3.0); - let expected_a = Vector4::new(1.0, 2.0, 3.0, 0.0); - - let b = DVector::from_row_slice(&[1.0, 2.0, 3.0]); - let expected_b = DVector::from_row_slice(&[1.0, 2.0, 3.0, 0.0]); - - let c = Matrix2::new(1.0, 2.0, 3.0, 4.0); - let expected_c = Matrix3::new(1.0, 2.0, 0.0, 3.0, 4.0, 0.0, 0.0, 0.0, 1.0); - - let d = DMatrix::from_row_slice(2, 2, &[1.0, 2.0, 3.0, 4.0]); - let expected_d = DMatrix::from_row_slice(3, 3, &[1.0, 2.0, 0.0, 3.0, 4.0, 0.0, 0.0, 0.0, 1.0]); - - assert_eq!(a.to_homogeneous(), expected_a); - assert_eq!(b.to_homogeneous(), expected_b); - assert_eq!(c.to_homogeneous(), expected_c); - assert_eq!(d.to_homogeneous(), expected_d); -} - -#[test] -fn push() { - let a = Vector3::new(1.0, 2.0, 3.0); - let expected_a = Vector4::new(1.0, 2.0, 3.0, 4.0); - - let b = DVector::from_row_slice(&[1.0, 2.0, 3.0]); - let expected_b = DVector::from_row_slice(&[1.0, 2.0, 3.0, 4.0]); - - assert_eq!(a.push(4.0), expected_a); - assert_eq!(b.push(4.0), expected_b); -} - -#[test] -fn simple_add() { - let a = Matrix2x3::new(1.0, 2.0, 3.0, 4.0, 5.0, 6.0); - - let b = Matrix2x3::new(10.0, 20.0, 30.0, 40.0, 50.0, 60.0); - let c = DMatrix::from_row_slice(2, 3, &[10.0, 20.0, 30.0, 40.0, 50.0, 60.0]); - - let expected = Matrix2x3::new(11.0, 22.0, 33.0, 44.0, 55.0, 66.0); - - assert_eq!(expected, &a + &b); - assert_eq!(expected, &a + b); - assert_eq!(expected, a + &b); - assert_eq!(expected, a + b); - - // Sum of a static matrix with a dynamic one. - assert_eq!(expected, &a + &c); - assert_eq!(expected, a + &c); - assert_eq!(expected, &c + &a); - assert_eq!(expected, &c + a); -} - -#[test] -fn simple_sum() { - type M = Matrix2x3; - - let a = M::new(1.0, 2.0, 3.0, 4.0, 5.0, 6.0); - let b = M::new(10.0, 20.0, 30.0, 40.0, 50.0, 60.0); - let c = M::new(100.0, 200.0, 300.0, 400.0, 500.0, 600.0); - - assert_eq!(M::zero(), Vec::::new().iter().sum()); - assert_eq!(M::zero(), Vec::::new().into_iter().sum()); - assert_eq!(a + b, vec![a, b].iter().sum()); - assert_eq!(a + b, vec![a, b].into_iter().sum()); - assert_eq!(a + b + c, vec![a, b, c].iter().sum()); - assert_eq!(a + b + c, vec![a, b, c].into_iter().sum()); -} - -#[test] -fn simple_scalar_mul() { - let a = Matrix2x3::new(1.0, 2.0, 3.0, 4.0, 5.0, 6.0); - - let expected = Matrix2x3::new(10.0, 20.0, 30.0, 40.0, 50.0, 60.0); - - assert_eq!(expected, a * 10.0); - assert_eq!(expected, &a * 10.0); - assert_eq!(expected, 10.0 * a); - assert_eq!(expected, 10.0 * &a); -} - -#[test] -fn simple_mul() { - let a = Matrix2x3::new(1.0, 2.0, 3.0, 4.0, 5.0, 6.0); - - let b = Matrix3x4::new( - 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 110.0, 120.0, - ); - - let expected = Matrix2x4::new(380.0, 440.0, 500.0, 560.0, 830.0, 980.0, 1130.0, 1280.0); - - assert_eq!(expected, &a * &b); - assert_eq!(expected, a * &b); - assert_eq!(expected, &a * b); - assert_eq!(expected, a * b); -} - -#[test] -fn simple_product() { - type M = Matrix3; - - let a = M::new(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0); - let b = M::new(10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0); - let c = M::new( - 100.0, 200.0, 300.0, 400.0, 500.0, 600.0, 700.0, 800.0, 900.0, - ); - - assert_eq!(M::one(), Vec::::new().iter().product()); - assert_eq!(M::one(), Vec::::new().into_iter().product()); - assert_eq!(a * b, vec![a, b].iter().product()); - assert_eq!(a * b, vec![a, b].into_iter().product()); - assert_eq!(a * b * c, vec![a, b, c].iter().product()); - assert_eq!(a * b * c, vec![a, b, c].into_iter().product()); -} - -#[test] -fn cross_product_vector_and_row_vector() { - let v1 = Vector3::new(1.0, 2.0, 3.0); - let v2 = Vector3::new(1.0, 5.0, 7.0); - let column_cross = v1.cross(&v2); - assert_eq!(column_cross, Vector3::new(-1.0, -4.0, 3.0)); - - let v1 = RowVector3::new(1.0, 2.0, 3.0); - let v2 = RowVector3::new(1.0, 5.0, 7.0); - let row_cross = v1.cross(&v2); - assert_eq!(row_cross, RowVector3::new(-1.0, -4.0, 3.0)); - - assert_eq!( - Vector3::new(1.0, 1.0, 0.0) - .cross(&Vector3::new(-0.5, 17.0, 0.0)) - .transpose(), - RowVector3::new(1.0, 1.0, 0.0).cross(&RowVector3::new(-0.5, 17.0, 0.0)) - ); -} - -#[test] -fn simple_scalar_conversion() { - let a = Matrix2x3::new(1.0, 2.0, 3.0, 4.0, 5.0, 6.0); - let expected = Matrix2x3::new(1, 2, 3, 4, 5, 6); - - let a_u32: Matrix2x3 = na::try_convert(a).unwrap(); // f32 -> u32 - let a_f32: Matrix2x3 = na::convert(a_u32); // u32 -> f32 - - assert_eq!(a, a_f32); - assert_eq!(expected, a_u32); -} - -#[test] -fn apply() { - let mut a = Matrix4::new( - 1.1f32, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9, 8.8, 7.7, 6.6, 5.5, 4.4, 3.3, 2.2, - ); - - let expected = Matrix4::new( - 1.0, 2.0, 3.0, 4.0, 6.0, 7.0, 8.0, 9.0, 10.0, 9.0, 8.0, 7.0, 6.0, 4.0, 3.0, 2.0, - ); - - a.apply(|e| *e = e.round()); - - assert_eq!(a, expected); -} - -#[test] -fn map() { - let a = Matrix4::new( - 1.1f64, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9, 8.8, 7.7, 6.6, 5.5, 4.4, 3.3, 2.2, - ); - - let expected = Matrix4::new(1, 2, 3, 4, 6, 7, 8, 9, 10, 9, 8, 7, 6, 4, 3, 2); - - let computed = a.map(|e| e.round() as i64); - - assert_eq!(computed, expected); -} - -#[test] -fn map_with_location() { - let a = Matrix4::new(1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4); - - let expected = Matrix4::new(1, 2, 3, 4, 3, 4, 5, 6, 5, 6, 7, 8, 7, 8, 9, 10); - - let computed = a.map_with_location(|i, j, e| e + i + j); - - assert_eq!(computed, expected); -} - -#[test] -fn zip_map() { - let a = Matrix3::new(11i32, 12, 13, 21, 22, 23, 31, 32, 33); - - let b = Matrix3::new(11u32, 12, 13, 21, 22, 23, 31, 32, 33); - - let expected = Matrix3::new(22.0f32, 24.0, 26.0, 42.0, 44.0, 46.0, 62.0, 64.0, 66.0); - - let computed = a.zip_map(&b, |ea, eb| ea as f32 + eb as f32); - - assert_eq!(computed, expected); -} - -#[test] -#[should_panic] -fn trace_panic() { - let m = DMatrix::::new_random(2, 3); - let _ = m.trace(); -} - -#[test] -fn trace() { - let m = Matrix2::new(1.0, 20.0, 30.0, 4.0); - assert_eq!(m.trace(), 5.0); -} - -#[test] -fn simple_transpose() { - let a = Matrix2x3::new(1.0, 2.0, 3.0, 4.0, 5.0, 6.0); - let expected = Matrix3x2::new(1.0, 4.0, 2.0, 5.0, 3.0, 6.0); - - assert_eq!(a.transpose(), expected); -} - -#[test] -fn simple_transpose_mut() { - let mut a = Matrix3::new(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0); - let expected = Matrix3::new(1.0, 4.0, 7.0, 2.0, 5.0, 8.0, 3.0, 6.0, 9.0); - - a.transpose_mut(); - assert_eq!(a, expected); -} - -#[test] -fn vector_index_mut() { - let mut v = Vector3::new(1, 2, 3); - - assert_eq!(v[0], 1); - assert_eq!(v[1], 2); - assert_eq!(v[2], 3); - - v[0] = 10; - v[1] = 20; - v[2] = 30; - - assert_eq!(v, Vector3::new(10, 20, 30)); -} - -#[test] -fn components_mut() { - let mut m2 = Matrix2::from_element(1.0); - let mut m3 = Matrix3::from_element(1.0); - let mut m4 = Matrix4::from_element(1.0); - let mut m5 = Matrix5::from_element(1.0); - let mut m6 = Matrix6::from_element(1.0); - - m2.m11 = 0.0; - m2.m12 = 0.0; - m2.m21 = 0.0; - m2.m22 = 0.0; - - m3.m11 = 0.0; - m3.m12 = 0.0; - m3.m13 = 0.0; - m3.m21 = 0.0; - m3.m22 = 0.0; - m3.m23 = 0.0; - m3.m31 = 0.0; - m3.m32 = 0.0; - m3.m33 = 0.0; - - m4.m11 = 0.0; - m4.m12 = 0.0; - m4.m13 = 0.0; - m4.m14 = 0.0; - m4.m21 = 0.0; - m4.m22 = 0.0; - m4.m23 = 0.0; - m4.m24 = 0.0; - m4.m31 = 0.0; - m4.m32 = 0.0; - m4.m33 = 0.0; - m4.m34 = 0.0; - m4.m41 = 0.0; - m4.m42 = 0.0; - m4.m43 = 0.0; - m4.m44 = 0.0; - - m5.m11 = 0.0; - m5.m12 = 0.0; - m5.m13 = 0.0; - m5.m14 = 0.0; - m5.m15 = 0.0; - m5.m21 = 0.0; - m5.m22 = 0.0; - m5.m23 = 0.0; - m5.m24 = 0.0; - m5.m25 = 0.0; - m5.m31 = 0.0; - m5.m32 = 0.0; - m5.m33 = 0.0; - m5.m34 = 0.0; - m5.m35 = 0.0; - m5.m41 = 0.0; - m5.m42 = 0.0; - m5.m43 = 0.0; - m5.m44 = 0.0; - m5.m45 = 0.0; - m5.m51 = 0.0; - m5.m52 = 0.0; - m5.m53 = 0.0; - m5.m54 = 0.0; - m5.m55 = 0.0; - - m6.m11 = 0.0; - m6.m12 = 0.0; - m6.m13 = 0.0; - m6.m14 = 0.0; - m6.m15 = 0.0; - m6.m16 = 0.0; - m6.m21 = 0.0; - m6.m22 = 0.0; - m6.m23 = 0.0; - m6.m24 = 0.0; - m6.m25 = 0.0; - m6.m26 = 0.0; - m6.m31 = 0.0; - m6.m32 = 0.0; - m6.m33 = 0.0; - m6.m34 = 0.0; - m6.m35 = 0.0; - m6.m36 = 0.0; - m6.m41 = 0.0; - m6.m42 = 0.0; - m6.m43 = 0.0; - m6.m44 = 0.0; - m6.m45 = 0.0; - m6.m46 = 0.0; - m6.m51 = 0.0; - m6.m52 = 0.0; - m6.m53 = 0.0; - m6.m54 = 0.0; - m6.m55 = 0.0; - m6.m56 = 0.0; - m6.m61 = 0.0; - m6.m62 = 0.0; - m6.m63 = 0.0; - m6.m64 = 0.0; - m6.m65 = 0.0; - m6.m66 = 0.0; - - assert!(m2.is_zero()); - assert!(m3.is_zero()); - assert!(m4.is_zero()); - assert!(m5.is_zero()); - assert!(m6.is_zero()); - - let mut v1 = Vector1::from_element(1.0); - let mut v2 = Vector2::from_element(1.0); - let mut v3 = Vector3::from_element(1.0); - let mut v4 = Vector4::from_element(1.0); - let mut v5 = Vector5::from_element(1.0); - let mut v6 = Vector6::from_element(1.0); - - v1.x = 0.0; - v2.x = 0.0; - v2.y = 0.0; - v3.x = 0.0; - v3.y = 0.0; - v3.z = 0.0; - v4.x = 0.0; - v4.y = 0.0; - v4.z = 0.0; - v4.w = 0.0; - v5.x = 0.0; - v5.y = 0.0; - v5.z = 0.0; - v5.w = 0.0; - v5.a = 0.0; - v6.x = 0.0; - v6.y = 0.0; - v6.z = 0.0; - v6.w = 0.0; - v6.a = 0.0; - v6.b = 0.0; - - assert!(v1.is_zero()); - assert!(v2.is_zero()); - assert!(v3.is_zero()); - assert!(v4.is_zero()); - assert!(v5.is_zero()); - assert!(v6.is_zero()); - - // Check that the components order is correct. - m3.m11 = 11.0; - m3.m12 = 12.0; - m3.m13 = 13.0; - m3.m21 = 21.0; - m3.m22 = 22.0; - m3.m23 = 23.0; - m3.m31 = 31.0; - m3.m32 = 32.0; - m3.m33 = 33.0; - - let expected_m3 = Matrix3::new(11.0, 12.0, 13.0, 21.0, 22.0, 23.0, 31.0, 32.0, 33.0); - assert_eq!(expected_m3, m3); -} - -#[test] -fn kronecker() { - let a = Matrix2x3::new(11, 12, 13, 21, 22, 23); - - let b = Matrix4x5::new( - 110, 120, 130, 140, 150, 210, 220, 230, 240, 250, 310, 320, 330, 340, 350, 410, 420, 430, - 440, 450, - ); - - let expected = OMatrix::<_, U8, U15>::from_row_slice(&[ - 1210, 1320, 1430, 1540, 1650, 1320, 1440, 1560, 1680, 1800, 1430, 1560, 1690, 1820, 1950, - 2310, 2420, 2530, 2640, 2750, 2520, 2640, 2760, 2880, 3000, 2730, 2860, 2990, 3120, 3250, - 3410, 3520, 3630, 3740, 3850, 3720, 3840, 3960, 4080, 4200, 4030, 4160, 4290, 4420, 4550, - 4510, 4620, 4730, 4840, 4950, 4920, 5040, 5160, 5280, 5400, 5330, 5460, 5590, 5720, 5850, - 2310, 2520, 2730, 2940, 3150, 2420, 2640, 2860, 3080, 3300, 2530, 2760, 2990, 3220, 3450, - 4410, 4620, 4830, 5040, 5250, 4620, 4840, 5060, 5280, 5500, 4830, 5060, 5290, 5520, 5750, - 6510, 6720, 6930, 7140, 7350, 6820, 7040, 7260, 7480, 7700, 7130, 7360, 7590, 7820, 8050, - 8610, 8820, 9030, 9240, 9450, 9020, 9240, 9460, 9680, 9900, 9430, 9660, 9890, 10120, 10350, - ]); - - let computed = a.kronecker(&b); - - assert_eq!(computed, expected); - - let a = Vector2::new(1, 2); - let b = Vector3::new(10, 20, 30); - let expected = Vector6::new(10, 20, 30, 20, 40, 60); - - assert_eq!(a.kronecker(&b), expected); - - let a = Vector2::new(1, 2); - let b = RowVector4::new(10, 20, 30, 40); - let expected = Matrix2x4::new(10, 20, 30, 40, 20, 40, 60, 80); - - assert_eq!(a.kronecker(&b), expected); -} - -#[test] -fn set_row_column() { - let a = Matrix4x5::new( - 11, 12, 13, 14, 15, 21, 22, 23, 24, 25, 31, 32, 33, 34, 35, 41, 42, 43, 44, 45, - ); - - let expected1 = Matrix4x5::new( - 11, 12, 13, 14, 15, 42, 43, 44, 45, 46, 31, 32, 33, 34, 35, 41, 42, 43, 44, 45, - ); - - let expected2 = Matrix4x5::new( - 11, 12, 100, 14, 15, 42, 43, 101, 45, 46, 31, 32, 102, 34, 35, 41, 42, 103, 44, 45, - ); - - let row = RowVector5::new(42, 43, 44, 45, 46); - let col = Vector4::new(100, 101, 102, 103); - - let mut computed = a; - - computed.set_row(1, &row); - assert_eq!(expected1, computed); - - computed.set_column(2, &col); - assert_eq!(expected2, computed); -} - -#[test] -fn partial_clamp() { - // NOTE: from #401. - let n = Vector2::new(1.5, 0.0); - let min = Vector2::new(-75.0, -0.0); - let max = Vector2::new(75.0, 0.0); - let inter = na::partial_clamp(&n, &min, &max); - assert_eq!(*inter.unwrap(), n); -} - -#[test] -fn partial_cmp() { - let a = Vector2::new(1.0, 6.0); - let b = Vector2::new(1.0, 3.0); - let c = Vector2::new(2.0, 7.0); - let d = Vector2::new(0.0, 7.0); - assert_eq!(a.partial_cmp(&a), Some(Ordering::Equal)); - assert_eq!(a.partial_cmp(&b), Some(Ordering::Greater)); - assert_eq!(a.partial_cmp(&c), Some(Ordering::Less)); - assert_eq!(a.partial_cmp(&d), None); -} - -#[test] -fn swizzle() { - let a = Vector2::new(1.0f32, 2.0); - let b = Vector3::new(1.0f32, 2.0, 3.0); - let c = Vector4::new(1.0f32, 2.0, 3.0, 4.0); - - assert_eq!(a.xy(), Vector2::new(1.0, 2.0)); - assert_eq!(a.yx(), Vector2::new(2.0, 1.0)); - assert_eq!(a.xx(), Vector2::new(1.0, 1.0)); - assert_eq!(a.yy(), Vector2::new(2.0, 2.0)); - - assert_eq!(a.xxx(), Vector3::new(1.0, 1.0, 1.0)); - assert_eq!(a.yyy(), Vector3::new(2.0, 2.0, 2.0)); - assert_eq!(a.xyx(), Vector3::new(1.0, 2.0, 1.0)); - assert_eq!(a.yxy(), Vector3::new(2.0, 1.0, 2.0)); - - assert_eq!(b.xy(), Vector2::new(1.0, 2.0)); - assert_eq!(b.yx(), Vector2::new(2.0, 1.0)); - assert_eq!(b.xx(), Vector2::new(1.0, 1.0)); - assert_eq!(b.yy(), Vector2::new(2.0, 2.0)); - - assert_eq!(b.xz(), Vector2::new(1.0, 3.0)); - assert_eq!(b.zx(), Vector2::new(3.0, 1.0)); - assert_eq!(b.yz(), Vector2::new(2.0, 3.0)); - assert_eq!(b.zy(), Vector2::new(3.0, 2.0)); - assert_eq!(b.zz(), Vector2::new(3.0, 3.0)); - - assert_eq!(b.xyz(), Vector3::new(1.0, 2.0, 3.0)); - assert_eq!(b.xxx(), Vector3::new(1.0, 1.0, 1.0)); - assert_eq!(b.yyy(), Vector3::new(2.0, 2.0, 2.0)); - assert_eq!(b.zzz(), Vector3::new(3.0, 3.0, 3.0)); - assert_eq!(b.zxy(), Vector3::new(3.0, 1.0, 2.0)); - assert_eq!(b.zxz(), Vector3::new(3.0, 1.0, 3.0)); - assert_eq!(b.zyz(), Vector3::new(3.0, 2.0, 3.0)); - - assert_eq!(c.xy(), Vector2::new(1.0, 2.0)); - assert_eq!(c.yx(), Vector2::new(2.0, 1.0)); - assert_eq!(c.xx(), Vector2::new(1.0, 1.0)); - assert_eq!(c.yy(), Vector2::new(2.0, 2.0)); - - assert_eq!(c.xz(), Vector2::new(1.0, 3.0)); - assert_eq!(c.zx(), Vector2::new(3.0, 1.0)); - assert_eq!(c.yz(), Vector2::new(2.0, 3.0)); - assert_eq!(c.zy(), Vector2::new(3.0, 2.0)); - assert_eq!(c.zz(), Vector2::new(3.0, 3.0)); - - assert_eq!(c.xyz(), Vector3::new(1.0, 2.0, 3.0)); - assert_eq!(c.xxx(), Vector3::new(1.0, 1.0, 1.0)); - assert_eq!(c.yyy(), Vector3::new(2.0, 2.0, 2.0)); - assert_eq!(c.zzz(), Vector3::new(3.0, 3.0, 3.0)); - assert_eq!(c.zxy(), Vector3::new(3.0, 1.0, 2.0)); - assert_eq!(c.zxz(), Vector3::new(3.0, 1.0, 3.0)); - assert_eq!(c.zyz(), Vector3::new(3.0, 2.0, 3.0)); -} - -#[cfg(feature = "proptest-support")] -mod transposition_tests { - use super::*; - use crate::proptest::{dmatrix, matrix, vector4, PROPTEST_F64}; - use proptest::{prop_assert, prop_assert_eq, proptest}; - - proptest! { - #[test] - fn transpose_transpose_is_self(m in matrix(PROPTEST_F64, Const::<2>, Const::<3>)) { - prop_assert_eq!(m.transpose().transpose(), m) - } - - #[test] - fn transpose_mut_transpose_mut_is_self(m in matrix(PROPTEST_F64, Const::<3>, Const::<3>)) { - let mut mm = m; - mm.transpose_mut(); - mm.transpose_mut(); - prop_assert_eq!(m, mm) - } - - #[test] - fn transpose_transpose_is_id_dyn(m in dmatrix()) { - prop_assert_eq!(m.transpose().transpose(), m) - } - - #[test] - fn check_transpose_components_dyn(m in dmatrix()) { - let tr = m.transpose(); - let (nrows, ncols) = m.shape(); - - prop_assert!(nrows == tr.shape().1 && ncols == tr.shape().0); - - for i in 0 .. nrows { - for j in 0 .. ncols { - prop_assert_eq!(m[(i, j)], tr[(j, i)]); - } - } - } - - #[test] - fn tr_mul_is_transpose_then_mul(m in matrix(PROPTEST_F64, Const::<4>, Const::<6>), v in vector4()) { - prop_assert!(relative_eq!(m.transpose() * v, m.tr_mul(&v), epsilon = 1.0e-7)) - } - } -} - -#[cfg(feature = "proptest-support")] -mod inversion_tests { - use super::*; - use crate::proptest::*; - use na::Matrix1; - use proptest::{prop_assert, proptest}; - - proptest! { - #[test] - fn self_mul_inv_is_id_dim1(m in matrix1()) { - if let Some(im) = m.try_inverse() { - let id = Matrix1::one(); - prop_assert!(relative_eq!(im * m, id, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(m * im, id, epsilon = 1.0e-7)); - } - } - - #[test] - fn self_mul_inv_is_id_dim2(m in matrix2()) { - if let Some(im) = m.try_inverse() { - let id = Matrix2::one(); - prop_assert!(relative_eq!(im * m, id, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(m * im, id, epsilon = 1.0e-7)); - } - } - - #[test] - fn self_mul_inv_is_id_dim3(m in matrix3()) { - if let Some(im) = m.try_inverse() { - let id = Matrix3::one(); - prop_assert!(relative_eq!(im * m, id, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(m * im, id, epsilon = 1.0e-7)); - } - } - - #[test] - fn self_mul_inv_is_id_dim4(m in matrix4()) { - if let Some(im) = m.try_inverse() { - let id = Matrix4::one(); - prop_assert!(relative_eq!(im * m, id, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(m * im, id, epsilon = 1.0e-7)); - } - } - - #[test] - fn self_mul_inv_is_id_dim6(m in matrix6()) { - if let Some(im) = m.try_inverse() { - let id = Matrix6::one(); - prop_assert!(relative_eq!(im * m, id, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(m * im, id, epsilon = 1.0e-7)); - } - } - } -} - -#[cfg(feature = "proptest-support")] -mod normalization_tests { - use crate::proptest::*; - use proptest::{prop_assert, proptest}; - - proptest! { - #[test] - fn normalized_vec_norm_is_one(v in vector3()) { - if let Some(nv) = v.try_normalize(1.0e-10) { - prop_assert!(relative_eq!(nv.norm(), 1.0, epsilon = 1.0e-7)); - } - } - - #[test] - fn normalized_vec_norm_is_one_dyn(v in dvector()) { - if let Some(nv) = v.try_normalize(1.0e-10) { - prop_assert!(relative_eq!(nv.norm(), 1.0, epsilon = 1.0e-7)); - } - } - } -} - -#[cfg(all(feature = "proptest-support", feature = "alga"))] -// TODO: move this to alga ? -mod finite_dim_inner_space_tests { - use super::*; - use crate::proptest::*; - use alga::linear::FiniteDimInnerSpace; - use proptest::collection::vec; - use proptest::{prop_assert, proptest}; - use std::fmt::Display; - - macro_rules! finite_dim_inner_space_test( - ($($Vector: ident, $vstrategy: ident, $orthonormal_subspace: ident, $orthonormalization: ident);* $(;)*) => {$( - proptest! { - #[test] - fn $orthonormal_subspace(vs in vec($vstrategy(), 0..10)) { - let mut given_basis = vs.clone(); - let given_basis_dim = $Vector::orthonormalize(&mut given_basis[..]); - let mut ortho_basis = Vec::new(); - $Vector::orthonormal_subspace_basis( - &given_basis[.. given_basis_dim], - |e| { ortho_basis.push(*e); true } - ); - - prop_assert!(is_subspace_basis(&ortho_basis[..])); - - for v in vs { - for b in &ortho_basis { - prop_assert!(relative_eq!(v.dot(b), 0.0, epsilon = 1.0e-7)); - } - } - } - - #[test] - fn $orthonormalization(vs in vec($vstrategy(), 0..10)) { - let mut basis = vs.clone(); - let subdim = $Vector::orthonormalize(&mut basis[..]); - - prop_assert!(is_subspace_basis(&basis[.. subdim])); - - for mut e in vs { - for b in &basis[.. subdim] { - e -= e.dot(b) * b - } - - // Any element of `e` must be a linear combination of the basis elements. - prop_assert!(relative_eq!(e.norm(), 0.0, epsilon = 1.0e-7)); - } - } - } - )*} - ); - - finite_dim_inner_space_test!( - Vector1, vector1, orthonormal_subspace_basis1, orthonormalize1; - Vector2, vector2, orthonormal_subspace_basis2, orthonormalize2; - Vector3, vector3, orthonormal_subspace_basis3, orthonormalize3; - Vector4, vector4, orthonormal_subspace_basis4, orthonormalize4; - Vector5, vector5, orthonormal_subspace_basis5, orthonormalize5; - Vector6, vector6, orthonormal_subspace_basis6, orthonormalize6; - ); - - /* - * - * Helper functions. - * - */ - fn is_subspace_basis + Display>( - vs: &[T], - ) -> bool { - for i in 0..vs.len() { - // Basis elements must be normalized. - if !relative_eq!(vs[i].norm(), 1.0, epsilon = 1.0e-7) { - println!("Non-zero basis element norm: {}", vs[i].norm()); - return false; - } - - for j in 0..i { - // Basis elements must be orthogonal. - if !relative_eq!(vs[i].dot(&vs[j]), 0.0, epsilon = 1.0e-7) { - println!( - "Non-orthogonal basis elements: {} · {} = {}", - vs[i], - vs[j], - vs[i].dot(&vs[j]) - ); - return false; - } - } - } - - true - } -} - -#[test] -fn partial_eq_shape_mismatch() { - let a = Matrix2::new(1, 2, 3, 4); - let b = Matrix2x3::new(1, 2, 3, 4, 5, 6); - assert_ne!(a, b); - assert_ne!(b, a); -} - -#[test] -fn partial_eq_different_types() { - // Ensure comparability of several types of Matrices - let dynamic_mat = DMatrix::from_row_slice(2, 4, &[1, 2, 3, 4, 5, 6, 7, 8]); - let static_mat = Matrix2x4::new(1, 2, 3, 4, 5, 6, 7, 8); - - let mut typenum_static_mat = OMatrix::, Const<4>>::zeros(); - let mut view = typenum_static_mat.view_mut((0, 0), (2, 4)); - view += static_mat; - - let fview_of_dmat = dynamic_mat.fixed_view::<2, 2>(0, 0); - let dview_of_dmat = dynamic_mat.view((0, 0), (2, 2)); - let fview_of_smat = static_mat.fixed_view::<2, 2>(0, 0); - let dview_of_smat = static_mat.view((0, 0), (2, 2)); - - assert_eq!(dynamic_mat, static_mat); - assert_eq!(static_mat, dynamic_mat); - - assert_eq!(dynamic_mat, view); - assert_eq!(view, dynamic_mat); - - assert_eq!(static_mat, view); - assert_eq!(view, static_mat); - - assert_eq!(fview_of_dmat, dview_of_dmat); - assert_eq!(dview_of_dmat, fview_of_dmat); - - assert_eq!(fview_of_dmat, fview_of_smat); - assert_eq!(fview_of_smat, fview_of_dmat); - - assert_eq!(fview_of_dmat, dview_of_smat); - assert_eq!(dview_of_smat, fview_of_dmat); - - assert_eq!(dview_of_dmat, fview_of_smat); - assert_eq!(fview_of_smat, dview_of_dmat); - - assert_eq!(dview_of_dmat, dview_of_smat); - assert_eq!(dview_of_smat, dview_of_dmat); - - assert_eq!(fview_of_smat, dview_of_smat); - assert_eq!(dview_of_smat, fview_of_smat); - - assert_ne!(dynamic_mat, dview_of_smat); - assert_ne!(dview_of_smat, dynamic_mat); - - // TODO - implement those comparisons - // assert_ne!(static_mat, typenum_static_mat); - //assert_ne!(typenum_static_mat, static_mat); -} - -fn generic_omatrix_to_string( - vector: &nalgebra::OVector, - matrix: &nalgebra::OMatrix, -) -> (String, String) -where - D: nalgebra::Dim, - nalgebra::DefaultAllocator: nalgebra::base::allocator::Allocator, - nalgebra::DefaultAllocator: nalgebra::base::allocator::Allocator, -{ - (vector.to_string(), matrix.to_string()) -} - -#[test] -fn omatrix_to_string() { - let dvec: nalgebra::DVector = nalgebra::dvector![1.0, 2.0]; - let dmatr: nalgebra::DMatrix = nalgebra::dmatrix![1.0, 2.0; 3.0, 4.0]; - let svec: nalgebra::SVector = nalgebra::vector![1.0, 2.0]; - let smatr: nalgebra::SMatrix = nalgebra::matrix![1.0, 2.0; 3.0, 4.0]; - assert_eq!( - generic_omatrix_to_string(&dvec, &dmatr), - (dvec.to_string(), dmatr.to_string()) - ); - assert_eq!( - generic_omatrix_to_string(&svec, &smatr), - (svec.to_string(), smatr.to_string()) - ); -} - -#[test] -fn column_iteration() { - // dynamic matrix - let dmat = nalgebra::dmatrix![ - 13,14,15; - 23,24,25; - 33,34,35; - ]; - let mut col_iter = dmat.column_iter(); - assert_eq!(col_iter.next(), Some(dmat.column(0))); - assert_eq!(col_iter.next(), Some(dmat.column(1))); - assert_eq!(col_iter.next(), Some(dmat.column(2))); - assert_eq!(col_iter.next(), None); - - // statically sized matrix - let smat: nalgebra::SMatrix = nalgebra::matrix![1.0, 2.0; 3.0, 4.0]; - let mut col_iter = smat.column_iter(); - assert_eq!(col_iter.next(), Some(smat.column(0))); - assert_eq!(col_iter.next(), Some(smat.column(1))); - assert_eq!(col_iter.next(), None); -} - -#[test] -fn column_iteration_mut() { - let mut dmat = nalgebra::dmatrix![ - 13,14,15; - 23,24,25; - 33,34,35; - ]; - let mut cloned = dmat.clone(); - let mut col_iter = dmat.column_iter_mut(); - assert_eq!(col_iter.next(), Some(cloned.column_mut(0))); - assert_eq!(col_iter.next(), Some(cloned.column_mut(1))); - assert_eq!(col_iter.next(), Some(cloned.column_mut(2))); - assert_eq!(col_iter.next(), None); - - // statically sized matrix - let mut smat: nalgebra::SMatrix = nalgebra::matrix![1.0, 2.0; 3.0, 4.0]; - let mut cloned = smat.clone(); - let mut col_iter = smat.column_iter_mut(); - assert_eq!(col_iter.next(), Some(cloned.column_mut(0))); - assert_eq!(col_iter.next(), Some(cloned.column_mut(1))); - assert_eq!(col_iter.next(), None); -} - -#[test] -fn column_iteration_double_ended() { - let dmat = nalgebra::dmatrix![ - 13,14,15,16,17; - 23,24,25,26,27; - 33,34,35,36,37; - ]; - let mut col_iter = dmat.column_iter(); - assert_eq!(col_iter.next(), Some(dmat.column(0))); - assert_eq!(col_iter.next(), Some(dmat.column(1))); - assert_eq!(col_iter.next_back(), Some(dmat.column(4))); - assert_eq!(col_iter.next_back(), Some(dmat.column(3))); - assert_eq!(col_iter.next(), Some(dmat.column(2))); - assert_eq!(col_iter.next_back(), None); - assert_eq!(col_iter.next(), None); -} - -#[test] -fn column_iterator_double_ended_mut() { - let mut dmat = nalgebra::dmatrix![ - 13,14,15,16,17; - 23,24,25,26,27; - 33,34,35,36,37; - ]; - let mut cloned = dmat.clone(); - let mut col_iter_mut = dmat.column_iter_mut(); - assert_eq!(col_iter_mut.next(), Some(cloned.column_mut(0))); - assert_eq!(col_iter_mut.next(), Some(cloned.column_mut(1))); - assert_eq!(col_iter_mut.next_back(), Some(cloned.column_mut(4))); - assert_eq!(col_iter_mut.next_back(), Some(cloned.column_mut(3))); - assert_eq!(col_iter_mut.next(), Some(cloned.column_mut(2))); - assert_eq!(col_iter_mut.next_back(), None); - assert_eq!(col_iter_mut.next(), None); -} - -#[test] -fn test_inversion_failure_leaves_matrix4_unchanged() { - let mut mat = na::Matrix4::new( - 1.0, 2.0, 3.0, 4.0, 2.0, 4.0, 6.0, 8.0, 3.0, 6.0, 9.0, 12.0, 4.0, 8.0, 12.0, 16.0, - ); - let expected = mat.clone(); - assert!(!mat.try_inverse_mut()); - assert_eq!(mat, expected); -} - -#[test] -#[cfg(feature = "rayon")] -fn parallel_column_iteration() { - use nalgebra::dmatrix; - use rayon::prelude::*; - let dmat: DMatrix = dmatrix![ - 13.,14.; - 23.,24.; - 33.,34.; - ]; - let cloned = dmat.clone(); - // test that correct columns are iterated over - dmat.par_column_iter().enumerate().for_each(|(idx, col)| { - assert_eq!(col, cloned.column(idx)); - }); - // test that a more complex expression produces the same - // result as the serial equivalent - let par_result: f64 = dmat.par_column_iter().map(|col| col.norm()).sum(); - let ser_result: f64 = dmat.column_iter().map(|col| col.norm()).sum(); - assert_eq!(par_result, ser_result); - - // repeat this test using mutable iterators - let mut dmat = dmat; - dmat.par_column_iter_mut() - .enumerate() - .for_each(|(idx, col)| { - assert_eq!(col, cloned.column(idx)); - }); - - let par_mut_result: f64 = dmat.par_column_iter_mut().map(|col| col.norm()).sum(); - assert_eq!(par_mut_result, ser_result); -} - -#[test] -#[cfg(feature = "rayon")] -fn column_iteration_mut_double_ended() { - let dmat = nalgebra::dmatrix![ - 13,14,15,16,17; - 23,24,25,26,27; - 33,34,35,36,37; - ]; - let cloned = dmat.clone(); - let mut col_iter = dmat.column_iter(); - assert_eq!(col_iter.next(), Some(cloned.column(0))); - assert_eq!(col_iter.next(), Some(cloned.column(1))); - assert_eq!(col_iter.next_back(), Some(cloned.column(4))); - assert_eq!(col_iter.next_back(), Some(cloned.column(3))); - assert_eq!(col_iter.next(), Some(cloned.column(2))); - assert_eq!(col_iter.next_back(), None); - assert_eq!(col_iter.next(), None); -} - -#[test] -#[cfg(feature = "rayon")] -fn parallel_column_iteration_mut() { - use rayon::prelude::*; - let mut first = DMatrix::::zeros(400, 300); - let mut second = DMatrix::::zeros(400, 300); - first - .column_iter_mut() - .enumerate() - .for_each(|(idx, mut col)| col[idx] = 1.); - second - .par_column_iter_mut() - .enumerate() - .for_each(|(idx, mut col)| col[idx] = 1.); - assert_eq!(first, second); - assert_eq!(second, DMatrix::identity(400, 300)); -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/matrix_view.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/matrix_view.rs deleted file mode 100644 index 8e151ee8c..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/matrix_view.rs +++ /dev/null @@ -1,337 +0,0 @@ -#![allow(non_snake_case)] - -use na::{ - DMatrix, DMatrixView, DMatrixViewMut, Matrix2, Matrix2x3, Matrix2x4, Matrix2x6, Matrix3, - Matrix3x2, Matrix3x4, Matrix4x2, Matrix6x2, MatrixView2, MatrixView2x3, MatrixView2xX, - MatrixView3, MatrixView3x2, MatrixViewMut2, MatrixViewMut2x3, MatrixViewMut2xX, MatrixViewMut3, - MatrixViewMut3x2, MatrixViewMutXx3, MatrixViewXx3, RowVector4, Vector3, -}; - -#[test] -#[rustfmt::skip] -fn nested_fixed_views() { - let a = Matrix3x4::new(11.0, 12.0, 13.0, 14.0, - 21.0, 22.0, 23.0, 24.0, - 31.0, 32.0, 33.0, 34.0); - - let s1 = a.fixed_view::<3, 3>(0, 1); // Simple view. - let s2 = s1.fixed_view::<2, 2>(1, 1); // View of view. - let s3 = s1.fixed_view_with_steps::<2, 2>((0, 0), (1, 1)); // View of view with steps. - - let expected_owned_s1 = Matrix3::new(12.0, 13.0, 14.0, - 22.0, 23.0, 24.0, - 32.0, 33.0, 34.0); - - let expected_owned_s2 = Matrix2::new(23.0, 24.0, - 33.0, 34.0); - - let expected_owned_s3 = Matrix2::new(12.0, 14.0, - 32.0, 34.0); - - assert_eq!(expected_owned_s1, s1.clone_owned()); - assert_eq!(expected_owned_s2, s2.clone_owned()); - assert_eq!(expected_owned_s3, s3.clone_owned()); -} - -#[test] -#[rustfmt::skip] -fn nested_views() { - let a = Matrix3x4::new(11.0, 12.0, 13.0, 14.0, - 21.0, 22.0, 23.0, 24.0, - 31.0, 32.0, 33.0, 34.0); - - let s1 = a.view((0, 1), (3, 3)); - let s2 = s1.view((1, 1), (2, 2)); - let s3 = s1.view_with_steps((0, 0), (2, 2), (1, 1)); - - let expected_owned_s1 = DMatrix::from_row_slice(3, 3, &[ 12.0, 13.0, 14.0, - 22.0, 23.0, 24.0, - 32.0, 33.0, 34.0 ]); - - let expected_owned_s2 = DMatrix::from_row_slice(2, 2, &[ 23.0, 24.0, - 33.0, 34.0 ]); - - let expected_owned_s3 = DMatrix::from_row_slice(2, 2, &[ 12.0, 14.0, - 32.0, 34.0 ]); - - assert_eq!(expected_owned_s1, s1.clone_owned()); - assert_eq!(expected_owned_s2, s2.clone_owned()); - assert_eq!(expected_owned_s3, s3.clone_owned()); -} - -#[test] -#[rustfmt::skip] -fn view_mut() { - let mut a = Matrix3x4::new(11.0, 12.0, 13.0, 14.0, - 21.0, 22.0, 23.0, 24.0, - 31.0, 32.0, 33.0, 34.0); - - { - // We modify `a` through the mutable view. - let mut s1 = a.view_with_steps_mut((0, 1), (2, 2), (1, 1)); - s1.fill(0.0); - } - - let expected_a = Matrix3x4::new(11.0, 0.0, 13.0, 0.0, - 21.0, 22.0, 23.0, 24.0, - 31.0, 0.0, 33.0, 0.0); - - assert_eq!(expected_a, a); -} - -#[test] -#[rustfmt::skip] -fn nested_row_views() { - let a = Matrix6x2::new(11.0, 12.0, - 21.0, 22.0, - 31.0, 32.0, - 41.0, 42.0, - 51.0, 52.0, - 61.0, 62.0); - let s1 = a.fixed_rows::<4>(1); - let s2 = s1.fixed_rows_with_step::<2>(1, 1); - - let expected_owned_s1 = Matrix4x2::new(21.0, 22.0, - 31.0, 32.0, - 41.0, 42.0, - 51.0, 52.0); - - let expected_owned_s2 = Matrix2::new(31.0, 32.0, - 51.0, 52.0); - - assert_eq!(expected_owned_s1, s1.clone_owned()); - assert_eq!(expected_owned_s2, s2.clone_owned()); -} - -#[test] -#[rustfmt::skip] -fn row_view_mut() { - let mut a = Matrix6x2::new(11.0, 12.0, - 21.0, 22.0, - 31.0, 32.0, - 41.0, 42.0, - 51.0, 52.0, - 61.0, 62.0); - { - // We modify `a` through the mutable view. - let mut s1 = a.rows_with_step_mut(1, 3, 1); - s1.fill(0.0); - } - - let expected_a = Matrix6x2::new(11.0, 12.0, - 0.0, 0.0, - 31.0, 32.0, - 0.0, 0.0, - 51.0, 52.0, - 0.0, 0.0); - - assert_eq!(expected_a, a); -} - -#[test] -#[rustfmt::skip] -fn nested_col_views() { - let a = Matrix2x6::new(11.0, 12.0, 13.0, 14.0, 15.0, 16.0, - 21.0, 22.0, 23.0, 24.0, 25.0, 26.0); - let s1 = a.fixed_columns::<4>(1); - let s2 = s1.fixed_columns_with_step::<2>(1, 1); - - let expected_owned_s1 = Matrix2x4::new(12.0, 13.0, 14.0, 15.0, - 22.0, 23.0, 24.0, 25.0); - - let expected_owned_s2 = Matrix2::new(13.0, 15.0, - 23.0, 25.0); - - assert_eq!(expected_owned_s1, s1.clone_owned()); - assert_eq!(expected_owned_s2, s2.clone_owned()); -} - -#[test] -#[rustfmt::skip] -fn col_view_mut() { - let mut a = Matrix2x6::new(11.0, 12.0, 13.0, 14.0, 15.0, 16.0, - 21.0, 22.0, 23.0, 24.0, 25.0, 26.0); - - { - // We modify `a` through the mutable view. - let mut s1 = a.columns_with_step_mut(1, 3, 1); - s1.fill(0.0); - } - - let expected_a = Matrix2x6::new(11.0, 0.0, 13.0, 0.0, 15.0, 0.0, - 21.0, 0.0, 23.0, 0.0, 25.0, 0.0); - - assert_eq!(expected_a, a.clone_owned()); -} - -#[test] -#[rustfmt::skip] -fn rows_range_pair() { - let a = Matrix3x4::new(11.0, 12.0, 13.0, 14.0, - 21.0, 22.0, 23.0, 24.0, - 31.0, 32.0, 33.0, 34.0); - - let (l, r) = a.rows_range_pair(.. 3, 3 ..); - assert!(r.len() == 0 && l.eq(&a)); - - let (l, r) = a.rows_range_pair(0, 1 ..); - - let expected_l = RowVector4::new(11.0, 12.0, 13.0, 14.0); - let expected_r = Matrix2x4::new(21.0, 22.0, 23.0, 24.0, - 31.0, 32.0, 33.0, 34.0); - assert!(l.eq(&expected_l) && r.eq(&expected_r)); -} - -#[test] -#[rustfmt::skip] -fn columns_range_pair() { - let a = Matrix3x4::new(11.0, 12.0, 13.0, 14.0, - 21.0, 22.0, 23.0, 24.0, - 31.0, 32.0, 33.0, 34.0); - - let (l, r) = a.columns_range_pair(.. 4, 4 ..); - assert!(r.len() == 0 && l.eq(&a)); - - let (l, r) = a.columns_range_pair(0, 1 ..); - - let expected_l = Vector3::new(11.0, 21.0, 31.0); - let expected_r = Matrix3::new(12.0, 13.0, 14.0, - 22.0, 23.0, 24.0, - 32.0, 33.0, 34.0); - assert!(l.eq(&expected_l) && r.eq(&expected_r)); -} - -#[test] -#[rustfmt::skip] -fn new_from_slice() { - let data = [ 1.0, 2.0, 3.0, 4.0, - 5.0, 6.0, 7.0, 8.0, - 9.0, 10.0, 11.0, 12.0 ]; - - let expected2 = Matrix2::from_column_slice(&data); - let expected3 = Matrix3::from_column_slice(&data); - let expected2x3 = Matrix2x3::from_column_slice(&data); - let expected3x2 = Matrix3x2::from_column_slice(&data); - - { - let m2 = MatrixView2::from_slice(&data); - let m3 = MatrixView3::from_slice(&data); - let m2x3 = MatrixView2x3::from_slice(&data); - let m3x2 = MatrixView3x2::from_slice(&data); - let m2xX = MatrixView2xX::from_slice(&data, 3); - let mXx3 = MatrixViewXx3::from_slice(&data, 2); - let mXxX = DMatrixView::from_slice(&data, 2, 3); - - assert!(m2.eq(&expected2)); - assert!(m3.eq(&expected3)); - assert!(m2x3.eq(&expected2x3)); - assert!(m3x2.eq(&expected3x2)); - assert!(m2xX.eq(&expected2x3)); - assert!(mXx3.eq(&expected2x3)); - assert!(mXxX.eq(&expected2x3)); - } -} - -#[test] -#[rustfmt::skip] -fn new_from_slice_mut() { - let data = [ 1.0, 2.0, 3.0, 4.0, - 5.0, 6.0, 7.0, 8.0, - 9.0, 10.0, 11.0, 12.0 ]; - let expected2 = [ 0.0, 0.0, 0.0, 0.0, - 5.0, 6.0, 7.0, 8.0, - 9.0, 10.0, 11.0, 12.0 ]; - let expected3 = [ 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, - 0.0, 10.0, 11.0, 12.0 ]; - let expected2x3 = [ 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 7.0, 8.0, - 9.0, 10.0, 11.0, 12.0 ]; - let expected3x2 = [ 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 7.0, 8.0, - 9.0, 10.0, 11.0, 12.0 ]; - - let mut data_mut = data.clone(); - MatrixViewMut2::from_slice(&mut data_mut).fill(0.0); - assert!(data_mut == expected2); - - let mut data_mut = data.clone(); - MatrixViewMut3::from_slice(&mut data_mut).fill(0.0); - assert!(data_mut == expected3); - - let mut data_mut = data.clone(); - MatrixViewMut2x3::from_slice(&mut data_mut).fill(0.0); - assert!(data_mut == expected2x3); - - let mut data_mut = data.clone(); - MatrixViewMut3x2::from_slice(&mut data_mut).fill(0.0); - assert!(data_mut == expected3x2); - - let mut data_mut = data.clone(); - MatrixViewMut2xX::from_slice(&mut data_mut, 3).fill(0.0); - assert!(data_mut == expected2x3); - - let mut data_mut = data.clone(); - MatrixViewMutXx3::from_slice(&mut data_mut, 2).fill(0.0); - assert!(data_mut == expected2x3); - - let mut data_mut = data.clone(); - DMatrixViewMut::from_slice(&mut data_mut, 2, 3).fill(0.0); - assert!(data_mut == expected2x3); -} - -#[test] -#[should_panic] -fn row_out_of_bounds() { - let a = Matrix3x4::::zeros(); - a.row(3); -} - -#[test] -#[should_panic] -fn rows_out_of_bounds() { - let a = Matrix3x4::::zeros(); - a.rows(1, 3); -} - -#[test] -#[should_panic] -fn rows_with_step_out_of_bounds() { - let a = Matrix3x4::::zeros(); - a.rows_with_step(1, 2, 1); -} - -#[test] -#[should_panic] -fn column_out_of_bounds() { - let a = Matrix3x4::::zeros(); - a.column(4); -} - -#[test] -#[should_panic] -fn columns_out_of_bounds() { - let a = Matrix3x4::::zeros(); - a.columns(2, 3); -} - -#[test] -#[should_panic] -fn columns_with_step_out_of_bounds() { - let a = Matrix3x4::::zeros(); - a.columns_with_step(2, 2, 1); -} - -#[test] -#[should_panic] -fn view_out_of_bounds() { - let a = Matrix3x4::::zeros(); - a.view((1, 2), (3, 1)); -} - -#[test] -#[should_panic] -fn view_with_steps_out_of_bounds() { - let a = Matrix3x4::::zeros(); - a.view_with_steps((1, 2), (2, 2), (0, 1)); -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/matrixcompare.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/matrixcompare.rs deleted file mode 100644 index afa648865..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/matrixcompare.rs +++ /dev/null @@ -1,89 +0,0 @@ -//! Tests for `matrixcompare` integration. -//! -//! The `matrixcompare` crate itself is responsible for testing the actual comparison. -//! The tests here only check that the necessary trait implementations are correctly implemented, -//! in addition to some sanity checks with example input. - -use matrixcompare::assert_matrix_eq; -use nalgebra::{OMatrix, U4, U5}; - -#[cfg(feature = "proptest-support")] -use { - crate::proptest::*, - matrixcompare::DenseAccess, - nalgebra::DMatrix, - proptest::{prop_assert_eq, proptest}, -}; - -#[cfg(feature = "proptest-support")] -proptest! { - #[test] - fn fetch_single_is_equivalent_to_index_f64(matrix in dmatrix()) { - for i in 0 .. matrix.nrows() { - for j in 0 .. matrix.ncols() { - prop_assert_eq!(matrix.fetch_single(i, j), *matrix.index((i, j))); - } - } - } - - #[test] - fn matrixcompare_shape_agrees_with_matrix(matrix in dmatrix()) { - prop_assert_eq!(matrix.nrows(), as matrixcompare::Matrix>::rows(&matrix)); - prop_assert_eq!(matrix.ncols(), as matrixcompare::Matrix>::cols(&matrix)); - } -} - -#[test] -fn assert_matrix_eq_dense_positive_comparison() { - #[rustfmt::skip] - let a = OMatrix::<_, U4, U5>::from_row_slice(&[ - 1210, 1320, 1430, 1540, 1650, - 2310, 2420, 2530, 2640, 2750, - 3410, 3520, 3630, 3740, 3850, - 4510, 4620, 4730, 4840, 4950, - ]); - - #[rustfmt::skip] - let b = OMatrix::<_, U4, U5>::from_row_slice(&[ - 1210, 1320, 1430, 1540, 1650, - 2310, 2420, 2530, 2640, 2750, - 3410, 3520, 3630, 3740, 3850, - 4510, 4620, 4730, 4840, 4950, - ]); - - // Test matrices of static size - assert_matrix_eq!(a, b); - assert_matrix_eq!(&a, b); - assert_matrix_eq!(a, &b); - assert_matrix_eq!(&a, &b); - - // Test matrices of dynamic size - let a_dyn = a.index((0..4, 0..5)); - let b_dyn = b.index((0..4, 0..5)); - assert_matrix_eq!(a_dyn, b_dyn); - assert_matrix_eq!(a_dyn, &b_dyn); - assert_matrix_eq!(&a_dyn, b_dyn); - assert_matrix_eq!(&a_dyn, &b_dyn); -} - -#[test] -#[should_panic] -fn assert_matrix_eq_dense_negative_comparison() { - #[rustfmt::skip] - let a = OMatrix::<_, U4, U5>::from_row_slice(&[ - 1210, 1320, 1430, 1540, 1650, - 2310, 2420, 2530, 2640, 2750, - 3410, 3520, 3630, 3740, 3850, - 4510, 4620, -4730, 4840, 4950, - ]); - - #[rustfmt::skip] - let b = OMatrix::<_, U4, U5>::from_row_slice(&[ - 1210, 1320, 1430, 1540, 1650, - 2310, 2420, 2530, 2640, 2750, - 3410, 3520, 3630, 3740, 3850, - 4510, 4620, 4730, 4840, 4950, - ]); - - assert_matrix_eq!(a, b); -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/mint.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/mint.rs deleted file mode 100644 index 63819f0f6..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/mint.rs +++ /dev/null @@ -1,70 +0,0 @@ -use mint; -use na::{Matrix2, Matrix2x3, Matrix3, Matrix3x4, Matrix4, Quaternion, Vector2, Vector3, Vector4}; - -macro_rules! mint_vector_conversion( - ($($mint_vector_conversion_i: ident, $Vector: ident, $SZ: expr);* $(;)*) => {$( - #[test] - fn $mint_vector_conversion_i() { - let v = $Vector::from_fn(|i, _| i); - let mv: mint::$Vector = v.into(); - let mv_ref: &mint::$Vector = v.as_ref(); - let v2 = $Vector::from(mv); - let arr: [usize; $SZ] = mv.into(); - - for i in 0 .. $SZ { - assert_eq!(arr[i], i); - } - - assert_eq!(&mv, mv_ref); - assert_eq!(v, v2); - } - )*} -); - -mint_vector_conversion!( - mint_vector_conversion_2, Vector2, 2; - mint_vector_conversion_3, Vector3, 3; - mint_vector_conversion_4, Vector4, 4; -); - -#[test] -fn mint_quaternion_conversions() { - let q = Quaternion::new(0.1f64, 0.2, 0.3, 0.4); - let mq: mint::Quaternion = q.into(); - let q2 = Quaternion::from(mq); - - assert_eq!(mq.v.x, q[0]); - assert_eq!(mq.v.y, q[1]); - assert_eq!(mq.v.z, q[2]); - assert_eq!(mq.s, q[3]); - - assert_eq!(q, q2); -} - -macro_rules! mint_matrix_conversion( - ($($mint_matrix_conversion_i_j: ident, $Matrix: ident, $Mint: ident, ($NRows: expr, $NCols: expr));* $(;)*) => {$( - #[test] - fn $mint_matrix_conversion_i_j() { - let m = $Matrix::from_fn(|i, j| i * 10 + j); - let mm: mint::$Mint = m.into(); - let m2 = $Matrix::from(mm); - let arr: [[usize; $NRows]; $NCols] = mm.into(); - - for i in 0 .. $NRows { - for j in 0 .. $NCols { - assert_eq!(arr[j][i], i * 10 + j); - } - } - - assert_eq!(m, m2); - } - )*} -); - -mint_matrix_conversion!( - mint_matrix_conversion_2_2, Matrix2, ColumnMatrix2, (2, 2); - mint_matrix_conversion_2_3, Matrix2x3, ColumnMatrix2x3, (2, 3); - mint_matrix_conversion_3_3, Matrix3, ColumnMatrix3, (3, 3); - mint_matrix_conversion_3_4, Matrix3x4, ColumnMatrix3x4, (3, 4); - mint_matrix_conversion_4_4, Matrix4, ColumnMatrix4, (4, 4); -); diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/mod.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/mod.rs deleted file mode 100644 index ff03ba8a6..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/mod.rs +++ /dev/null @@ -1,23 +0,0 @@ -mod blas; -mod cg; -mod conversion; -mod edition; -mod empty; -mod matrix; -mod matrix_view; -#[cfg(feature = "mint")] -mod mint; -mod reshape; -#[cfg(feature = "rkyv-serialize-no-std")] -mod rkyv; -mod serde; -mod variance; - -#[cfg(feature = "compare")] -mod matrixcompare; - -#[cfg(feature = "arbitrary")] -pub mod helper; - -#[cfg(feature = "macros")] -mod macros; diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/reshape.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/reshape.rs deleted file mode 100644 index 184d06acf..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/reshape.rs +++ /dev/null @@ -1,80 +0,0 @@ -use na::{ - Const, DMatrix, DMatrixView, DMatrixViewMut, Dyn, Matrix, MatrixView, MatrixViewMut, SMatrix, - SMatrixView, SMatrixViewMut, VecStorage, U3, U4, -}; -use nalgebra_macros::matrix; -use simba::scalar::SupersetOf; - -const MATRIX: SMatrix = matrix![ - 1, 2, 3; - 4, 5, 6; - 7, 8, 9; - 10, 11, 12 -]; - -const RESHAPED_MATRIX: SMatrix = matrix![ - 1, 10, 8, 6; - 4, 2, 11, 9; - 7, 5, 3, 12 -]; - -// Helper alias for making it easier to specify dynamically allocated matrices with -// different dimension types (unlike DMatrix) -type GenericDMatrix = Matrix>; - -#[test] -fn reshape_owned() { - macro_rules! test_reshape { - ($in_matrix:ty => $out_matrix:ty, $rows:expr, $cols:expr) => {{ - // This is a pretty weird way to convert, but Matrix implements SubsetOf - let matrix: $in_matrix = MATRIX.to_subset().unwrap(); - let reshaped: $out_matrix = matrix.reshape_generic($rows, $cols); - assert_eq!(reshaped, RESHAPED_MATRIX); - }}; - } - - test_reshape!(SMatrix<_, 4, 3> => SMatrix<_, 3, 4>, U3, U4); - test_reshape!(GenericDMatrix<_, U4, Dyn> => GenericDMatrix<_, Dyn, Dyn>, Dyn(3), Dyn(4)); - test_reshape!(GenericDMatrix<_, U4, Dyn> => GenericDMatrix<_, U3, Dyn>, U3, Dyn(4)); - test_reshape!(GenericDMatrix<_, U4, Dyn> => GenericDMatrix<_, Dyn, U4>, Dyn(3), U4); - test_reshape!(DMatrix<_> => DMatrix<_>, Dyn(3), Dyn(4)); -} - -#[test] -fn reshape_slice() { - macro_rules! test_reshape { - ($in_slice:ty => $out_slice:ty, $rows:expr, $cols:expr) => { - // We test both that types check out by being explicit about types - // and the actual contents of the matrix - { - // By constructing the slice from a mutable reference we can obtain *either* - // an immutable slice or a mutable slice, which simplifies the testing of both - // types of mutability - let mut source_matrix = MATRIX.clone(); - let slice: $in_slice = Matrix::from(&mut source_matrix); - let reshaped: $out_slice = slice.reshape_generic($rows, $cols); - assert_eq!(reshaped, RESHAPED_MATRIX); - } - }; - } - - // Static "source slice" - test_reshape!(SMatrixView<_, 4, 3> => SMatrixView<_, 3, 4>, U3, U4); - test_reshape!(SMatrixView<_, 4, 3> => DMatrixView<_>, Dyn(3), Dyn(4)); - test_reshape!(SMatrixView<_, 4, 3> => MatrixView<_, Const<3>, Dyn>, U3, Dyn(4)); - test_reshape!(SMatrixView<_, 4, 3> => MatrixView<_, Dyn, Const<4>>, Dyn(3), U4); - test_reshape!(SMatrixViewMut<_, 4, 3> => SMatrixViewMut<_, 3, 4>, U3, U4); - test_reshape!(SMatrixViewMut<_, 4, 3> => DMatrixViewMut<_>, Dyn(3), Dyn(4)); - test_reshape!(SMatrixViewMut<_, 4, 3> => MatrixViewMut<_, Const<3>, Dyn>, U3, Dyn(4)); - test_reshape!(SMatrixViewMut<_, 4, 3> => MatrixViewMut<_, Dyn, Const<4>>, Dyn(3), U4); - - // Dyn "source slice" - test_reshape!(DMatrixView<_> => SMatrixView<_, 3, 4>, U3, U4); - test_reshape!(DMatrixView<_> => DMatrixView<_>, Dyn(3), Dyn(4)); - test_reshape!(DMatrixView<_> => MatrixView<_, Const<3>, Dyn>, U3, Dyn(4)); - test_reshape!(DMatrixView<_> => MatrixView<_, Dyn, Const<4>>, Dyn(3), U4); - test_reshape!(DMatrixViewMut<_> => SMatrixViewMut<_, 3, 4>, U3, U4); - test_reshape!(DMatrixViewMut<_> => DMatrixViewMut<_>, Dyn(3), Dyn(4)); - test_reshape!(DMatrixViewMut<_> => MatrixViewMut<_, Const<3>, Dyn>, U3, Dyn(4)); - test_reshape!(DMatrixViewMut<_> => MatrixViewMut<_, Dyn, Const<4>>, Dyn(3), U4); -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/rkyv.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/rkyv.rs deleted file mode 100644 index 92da4b283..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/rkyv.rs +++ /dev/null @@ -1,62 +0,0 @@ -#![cfg(feature = "rkyv-serialize")] - -use na::{ - Isometry3, IsometryMatrix2, IsometryMatrix3, Matrix3x4, Point2, Point3, Quaternion, Rotation2, - Rotation3, Similarity3, SimilarityMatrix2, SimilarityMatrix3, Translation2, Translation3, -}; -use rand; -use rkyv::{Deserialize, Infallible}; - -macro_rules! test_rkyv_same_type( - ($($test: ident, $ty: ident);* $(;)*) => {$( - #[test] - fn $test() { - let value: $ty = rand::random(); - let bytes = rkyv::to_bytes::<_, 256>(&value).unwrap(); - - let archived = rkyv::check_archived_root::<$ty>(&bytes[..]).unwrap(); - // Compare archived and non-archived - assert_eq!(archived, &value); - - // Make sure Debug implementations are the same for Archived and non-Archived versions. - assert_eq!(format!("{:?}", value), format!("{:?}", archived)); - } - )*} -); -macro_rules! test_rkyv_diff_type( - ($($test: ident, $ty: ident);* $(;)*) => {$( - #[test] - fn $test() { - let value: $ty = Default::default(); - let bytes = rkyv::to_bytes::<_, 256>(&value).unwrap(); - - let archived = rkyv::check_archived_root::<$ty>(&bytes[..]).unwrap(); - let deserialized: $ty = archived.deserialize(&mut Infallible).unwrap(); - assert_eq!(deserialized, value); - } - )*} -); - -// Tests to make sure -test_rkyv_same_type!( - rkyv_same_type_matrix3x4, Matrix3x4; - rkyv_same_type_point3, Point3; - rkyv_same_type_translation3, Translation3; - rkyv_same_type_rotation3, Rotation3; - rkyv_same_type_isometry3, Isometry3; - rkyv_same_type_isometry_matrix3, IsometryMatrix3; - rkyv_same_type_similarity3, Similarity3; - rkyv_same_type_similarity_matrix3, SimilarityMatrix3; - rkyv_same_type_quaternion, Quaternion; - rkyv_same_type_point2, Point2; - rkyv_same_type_translation2, Translation2; - rkyv_same_type_rotation2, Rotation2; - // rkyv_same_type_isometry2, Isometry2; - rkyv_same_type_isometry_matrix2, IsometryMatrix2; - // rkyv_same_type_similarity2, Similarity2; - rkyv_same_type_similarity_matrix2, SimilarityMatrix2; -); - -test_rkyv_diff_type! { - rkyv_diff_type_matrix3x4, Matrix3x4; -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/serde.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/serde.rs deleted file mode 100644 index 081ec5052..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/serde.rs +++ /dev/null @@ -1,96 +0,0 @@ -#![cfg(feature = "serde-serialize")] - -use na::{ - DMatrix, Isometry2, Isometry3, IsometryMatrix2, IsometryMatrix3, Matrix2x3, Matrix3x4, Point2, - Point3, Quaternion, Rotation2, Rotation3, Similarity2, Similarity3, SimilarityMatrix2, - SimilarityMatrix3, Translation2, Translation3, Unit, Vector2, -}; -use rand; -use serde::{Deserialize, Serialize}; -use serde_json; - -macro_rules! test_serde( - ($($test: ident, $ty: ident);* $(;)*) => {$( - #[test] - fn $test() { - let v: $ty = rand::random(); - let serialized = serde_json::to_string(&v).unwrap(); - let deserialized: $ty = serde_json::from_str(&serialized).unwrap(); - assert_eq!(v, deserialized); - } - )*} -); - -#[test] -fn serde_dmatrix() { - let v: DMatrix = DMatrix::new_random(3, 4); - let serialized = serde_json::to_string(&v).unwrap(); - let deserialized: DMatrix = serde_json::from_str(&serialized).unwrap(); - assert_eq!(v, deserialized); - - let m = DMatrix::from_column_slice(2, 3, &[1.0, 2.0, 3.0, 4.0, 5.0, 6.0]); - let mat_str = "[[1.0, 2.0, 3.0, 4.0, 5.0, 6.0],2,3]"; - let deserialized: DMatrix = serde_json::from_str(&mat_str).unwrap(); - assert_eq!(m, deserialized); - - let m = Matrix2x3::from_column_slice(&[1.0, 2.0, 3.0, 4.0, 5.0, 6.0]); - let mat_str = "[1.0, 2.0, 3.0, 4.0, 5.0, 6.0]"; - let deserialized: Matrix2x3 = serde_json::from_str(&mat_str).unwrap(); - assert_eq!(m, deserialized); -} - -#[test] -#[should_panic] -fn serde_dmatrix_invalid_len() { - // This must fail: we attempt to deserialize a 2x3 with only 5 elements. - let mat_str = "[[1.0, 2.0, 3.0, 4.0, 5.0],2,3]"; - let _: DMatrix = serde_json::from_str(&mat_str).unwrap(); -} - -#[test] -#[should_panic] -fn serde_smatrix_invalid_len() { - // This must fail: we attempt to deserialize a 2x3 with only 5 elements. - let mat_str = "[1.0, 2.0, 3.0, 4.0, 5.0]"; - let _: Matrix2x3 = serde_json::from_str(&mat_str).unwrap(); -} - -test_serde!( - serde_matrix3x4, Matrix3x4; - serde_point3, Point3; - serde_translation3, Translation3; - serde_rotation3, Rotation3; - serde_isometry3, Isometry3; - serde_isometry_matrix3, IsometryMatrix3; - serde_similarity3, Similarity3; - serde_similarity_matrix3, SimilarityMatrix3; - serde_quaternion, Quaternion; - serde_point2, Point2; - serde_translation2, Translation2; - serde_rotation2, Rotation2; - serde_isometry2, Isometry2; - serde_isometry_matrix2, IsometryMatrix2; - serde_similarity2, Similarity2; - serde_similarity_matrix2, SimilarityMatrix2; -); - -#[test] -fn serde_flat() { - // The actual storage is hidden behind three layers of wrapper types that shouldn't appear in serialized form. - let v = Unit::new_normalize(Quaternion::new(0., 0., 0., 1.)); - let serialized = serde_json::to_string(&v).unwrap(); - assert_eq!(serialized, "[0.0,0.0,1.0,0.0]"); -} - -#[derive(Serialize, Deserialize, Debug, PartialEq, Copy, Clone)] -enum Stuff { - A(f64), - B(f64), -} - -#[test] -fn deserialize_enum() { - let json = r#"[{"letter":"A", "value":123.4}, {"letter":"B", "value":567.8}]"#; - let parsed: Result, _> = serde_json::from_str(json); - println!("parsed: {:?}", parsed); -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/variance.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/variance.rs deleted file mode 100644 index 0bc9e43ae..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/core/variance.rs +++ /dev/null @@ -1,18 +0,0 @@ -use nalgebra::DVector; - -#[test] -fn test_variance_catastrophic_cancellation() { - let long_repeating_vector = DVector::repeat(10_000, 100000000.0); - assert_eq!(long_repeating_vector.variance(), 0.0); - - let short_vec = DVector::from_vec(vec![1., 2., 3.]); - assert_eq!(short_vec.variance(), 2.0 / 3.0); - - let short_vec = - DVector::::from_vec(vec![1.0e8 + 4.0, 1.0e8 + 7.0, 1.0e8 + 13.0, 1.0e8 + 16.0]); - assert_eq!(short_vec.variance(), 22.5); - - let short_vec = - DVector::::from_vec(vec![1.0e9 + 4.0, 1.0e9 + 7.0, 1.0e9 + 13.0, 1.0e9 + 16.0]); - assert_eq!(short_vec.variance(), 22.5); -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/geometry/dual_quaternion.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/geometry/dual_quaternion.rs deleted file mode 100644 index 669eb7041..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/geometry/dual_quaternion.rs +++ /dev/null @@ -1,302 +0,0 @@ -#![cfg(feature = "proptest-support")] -#![allow(non_snake_case)] - -use na::{DualQuaternion, Point3, Unit, UnitDualQuaternion, UnitQuaternion, Vector3}; - -use crate::proptest::*; -use proptest::{prop_assert, proptest}; - -proptest!( - #[test] - fn isometry_equivalence(iso in isometry3(), p in point3(), v in vector3()) { - let dq = UnitDualQuaternion::from_isometry(&iso); - - prop_assert!(relative_eq!(iso * p, dq * p, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(iso * v, dq * v, epsilon = 1.0e-7)); - } - - #[test] - fn inverse_is_identity(i in unit_dual_quaternion(), p in point3(), v in vector3()) { - let ii = i.inverse(); - - prop_assert!(relative_eq!(i * ii, UnitDualQuaternion::identity(), epsilon = 1.0e-7) - && relative_eq!(ii * i, UnitDualQuaternion::identity(), epsilon = 1.0e-7) - && relative_eq!((i * ii) * p, p, epsilon = 1.0e-7) - && relative_eq!((ii * i) * p, p, epsilon = 1.0e-7) - && relative_eq!((i * ii) * v, v, epsilon = 1.0e-7) - && relative_eq!((ii * i) * v, v, epsilon = 1.0e-7)); - } - - #[cfg_attr(rustfmt, rustfmt_skip)] - #[test] - fn multiply_equals_alga_transform( - dq in unit_dual_quaternion(), - v in vector3(), - p in point3() - ) { - prop_assert!(dq * v == dq.transform_vector(&v) - && dq * p == dq.transform_point(&p) - && relative_eq!( - dq.inverse() * v, - dq.inverse_transform_vector(&v), - epsilon = 1.0e-7 - ) - && relative_eq!( - dq.inverse() * p, - dq.inverse_transform_point(&p), - epsilon = 1.0e-7 - )); - } - - #[cfg_attr(rustfmt, rustfmt_skip)] - #[test] - fn composition( - dq in unit_dual_quaternion(), - uq in unit_quaternion(), - t in translation3(), - v in vector3(), - p in point3() - ) { - // (rotation × dual quaternion) * point = rotation × (dual quaternion * point) - prop_assert!(relative_eq!((uq * dq) * v, uq * (dq * v), epsilon = 1.0e-7)); - prop_assert!(relative_eq!((uq * dq) * p, uq * (dq * p), epsilon = 1.0e-7)); - - // (dual quaternion × rotation) * point = dual quaternion × (rotation * point) - prop_assert!(relative_eq!((dq * uq) * v, dq * (uq * v), epsilon = 1.0e-7)); - prop_assert!(relative_eq!((dq * uq) * p, dq * (uq * p), epsilon = 1.0e-7)); - - // (translation × dual quaternion) * point = translation × (dual quaternion * point) - prop_assert!(relative_eq!((t * dq) * v, (dq * v), epsilon = 1.0e-7)); - prop_assert!(relative_eq!((t * dq) * p, t * (dq * p), epsilon = 1.0e-7)); - - // (dual quaternion × translation) * point = dual quaternion × (translation * point) - prop_assert!(relative_eq!((dq * t) * v, dq * v, epsilon = 1.0e-7)); - prop_assert!(relative_eq!((dq * t) * p, dq * (t * p), epsilon = 1.0e-7)); - } - - #[cfg_attr(rustfmt, rustfmt_skip)] - #[test] - fn sclerp_is_defined_for_identical_orientations( - dq in unit_dual_quaternion(), - s in -1.0f64..2.0f64, - t in translation3(), - ) { - // Should not panic. - prop_assert!(relative_eq!(dq.sclerp(&dq, 0.0), dq, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(dq.sclerp(&dq, 0.5), dq, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(dq.sclerp(&dq, 1.0), dq, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(dq.sclerp(&dq, s), dq, epsilon = 1.0e-7)); - - let unit = UnitDualQuaternion::identity(); - prop_assert!(relative_eq!(unit.sclerp(&unit, 0.0), unit, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(unit.sclerp(&unit, 0.5), unit, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(unit.sclerp(&unit, 1.0), unit, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(unit.sclerp(&unit, s), unit, epsilon = 1.0e-7)); - - // ScLERPing two unit dual quaternions with nearly equal rotation - // components should result in a unit dual quaternion with a rotation - // component nearly equal to either input. - let dq2 = t * dq; - prop_assert!(relative_eq!(dq.sclerp(&dq2, 0.0).real, dq.real, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(dq.sclerp(&dq2, 0.5).real, dq.real, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(dq.sclerp(&dq2, 1.0).real, dq.real, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(dq.sclerp(&dq2, s).real, dq.real, epsilon = 1.0e-7)); - - // ScLERPing two unit dual quaternions with nearly equal rotation - // components should result in a unit dual quaternion with a translation - // component which is nearly equal to linearly interpolating the - // translation components of the inputs. - prop_assert!(relative_eq!( - dq.sclerp(&dq2, s).translation().vector, - dq.translation().vector.lerp(&dq2.translation().vector, s), - epsilon = 1.0e-7 - )); - - let unit2 = t * unit; - prop_assert!(relative_eq!(unit.sclerp(&unit2, 0.0).real, unit.real, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(unit.sclerp(&unit2, 0.5).real, unit.real, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(unit.sclerp(&unit2, 1.0).real, unit.real, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(unit.sclerp(&unit2, s).real, unit.real, epsilon = 1.0e-7)); - - prop_assert!(relative_eq!( - unit.sclerp(&unit2, s).translation().vector, - unit.translation().vector.lerp(&unit2.translation().vector, s), - epsilon = 1.0e-7 - )); - } - - #[cfg_attr(rustfmt, rustfmt_skip)] - #[test] - fn sclerp_is_not_defined_for_opposite_orientations( - dq in unit_dual_quaternion(), - s in 0.1f64..0.9f64, - t in translation3(), - t2 in translation3(), - v in vector3(), - ) { - let iso = dq.to_isometry(); - let rot = iso.rotation; - if let Some((axis, angle)) = rot.axis_angle() { - let flipped = UnitQuaternion::from_axis_angle(&axis, angle + std::f64::consts::PI); - let dqf = flipped * rot.inverse() * dq.clone(); - prop_assert!(dq.try_sclerp(&dqf, 0.5, 1.0e-7).is_none()); - prop_assert!(dq.try_sclerp(&dqf, s, 1.0e-7).is_none()); - } - - let dq2 = t * dq; - let iso2 = dq2.to_isometry(); - let rot2 = iso2.rotation; - if let Some((axis, angle)) = rot2.axis_angle() { - let flipped = UnitQuaternion::from_axis_angle(&axis, angle + std::f64::consts::PI); - let dq3f = t2 * flipped * rot.inverse() * dq.clone(); - prop_assert!(dq2.try_sclerp(&dq3f, 0.5, 1.0e-7).is_none()); - prop_assert!(dq2.try_sclerp(&dq3f, s, 1.0e-7).is_none()); - } - - if let Some(axis) = Unit::try_new(v, 1.0e-7) { - let unit = UnitDualQuaternion::identity(); - let flip = UnitQuaternion::from_axis_angle(&axis, std::f64::consts::PI); - let unitf = flip * unit; - prop_assert!(unit.try_sclerp(&unitf, 0.5, 1.0e-7).is_none()); - prop_assert!(unit.try_sclerp(&unitf, s, 1.0e-7).is_none()); - - let unit2f = t * unit * flip; - prop_assert!(unit.try_sclerp(&unit2f, 0.5, 1.0e-7).is_none()); - prop_assert!(unit.try_sclerp(&unit2f, s, 1.0e-7).is_none()); - } - } - - #[cfg_attr(rustfmt, rustfmt_skip)] - #[test] - fn all_op_exist( - dq in dual_quaternion(), - udq in unit_dual_quaternion(), - uq in unit_quaternion(), - s in PROPTEST_F64, - t in translation3(), - v in vector3(), - p in point3() - ) { - let dqMs: DualQuaternion<_> = dq * s; - - let dqMdq: DualQuaternion<_> = dq * dq; - let dqMudq: DualQuaternion<_> = dq * udq; - let udqMdq: DualQuaternion<_> = udq * dq; - - let iMi: UnitDualQuaternion<_> = udq * udq; - let iMuq: UnitDualQuaternion<_> = udq * uq; - let iDi: UnitDualQuaternion<_> = udq / udq; - let iDuq: UnitDualQuaternion<_> = udq / uq; - - let iMp: Point3<_> = udq * p; - let iMv: Vector3<_> = udq * v; - - let iMt: UnitDualQuaternion<_> = udq * t; - let tMi: UnitDualQuaternion<_> = t * udq; - - let uqMi: UnitDualQuaternion<_> = uq * udq; - let uqDi: UnitDualQuaternion<_> = uq / udq; - - let mut dqMs1 = dq; - - let mut dqMdq1 = dq; - let mut dqMdq2 = dq; - - let mut dqMudq1 = dq; - let mut dqMudq2 = dq; - - let mut iMt1 = udq; - let mut iMt2 = udq; - - let mut iMi1 = udq; - let mut iMi2 = udq; - - let mut iMuq1 = udq; - let mut iMuq2 = udq; - - let mut iDi1 = udq; - let mut iDi2 = udq; - - let mut iDuq1 = udq; - let mut iDuq2 = udq; - - dqMs1 *= s; - - dqMdq1 *= dq; - dqMdq2 *= &dq; - - dqMudq1 *= udq; - dqMudq2 *= &udq; - - iMt1 *= t; - iMt2 *= &t; - - iMi1 *= udq; - iMi2 *= &udq; - - iMuq1 *= uq; - iMuq2 *= &uq; - - iDi1 /= udq; - iDi2 /= &udq; - - iDuq1 /= uq; - iDuq2 /= &uq; - - prop_assert!(dqMs == dqMs1 - && dqMdq == dqMdq1 - && dqMdq == dqMdq2 - && dqMudq == dqMudq1 - && dqMudq == dqMudq2 - && iMt == iMt1 - && iMt == iMt2 - && iMi == iMi1 - && iMi == iMi2 - && iMuq == iMuq1 - && iMuq == iMuq2 - && iDi == iDi1 - && iDi == iDi2 - && iDuq == iDuq1 - && iDuq == iDuq2 - && dqMs == &dq * s - && dqMdq == &dq * &dq - && dqMdq == dq * &dq - && dqMdq == &dq * dq - && dqMudq == &dq * &udq - && dqMudq == dq * &udq - && dqMudq == &dq * udq - && udqMdq == &udq * &dq - && udqMdq == udq * &dq - && udqMdq == &udq * dq - && iMi == &udq * &udq - && iMi == udq * &udq - && iMi == &udq * udq - && iMuq == &udq * &uq - && iMuq == udq * &uq - && iMuq == &udq * uq - && iDi == &udq / &udq - && iDi == udq / &udq - && iDi == &udq / udq - && iDuq == &udq / &uq - && iDuq == udq / &uq - && iDuq == &udq / uq - && iMp == &udq * &p - && iMp == udq * &p - && iMp == &udq * p - && iMv == &udq * &v - && iMv == udq * &v - && iMv == &udq * v - && iMt == &udq * &t - && iMt == udq * &t - && iMt == &udq * t - && tMi == &t * &udq - && tMi == t * &udq - && tMi == &t * udq - && uqMi == &uq * &udq - && uqMi == uq * &udq - && uqMi == &uq * udq - && uqDi == &uq / &udq - && uqDi == uq / &udq - && uqDi == &uq / udq) - } -); diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/geometry/isometry.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/geometry/isometry.rs deleted file mode 100644 index 8da257dbe..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/geometry/isometry.rs +++ /dev/null @@ -1,276 +0,0 @@ -#![cfg(feature = "proptest-support")] -#![allow(non_snake_case)] - -use na::{Isometry3, Point3, Vector3}; - -use crate::proptest::*; -use proptest::{prop_assert, prop_assert_eq, proptest}; - -proptest!( - #[test] - fn append_rotation_wrt_point_to_id(r in unit_quaternion(), p in point3()) { - let mut iso = Isometry3::identity(); - iso.append_rotation_wrt_point_mut(&r, &p); - - prop_assert_eq!(iso, Isometry3::rotation_wrt_point(r, p)) - } - - #[test] - fn rotation_wrt_point_invariance(r in unit_quaternion(), p in point3()) { - let iso = Isometry3::rotation_wrt_point(r, p); - - prop_assert!(relative_eq!(iso * p, p, epsilon = 1.0e-7)) - } - - #[test] - fn look_at_rh_3(eye in point3(), target in point3(), up in vector3()) { - let viewmatrix = Isometry3::look_at_rh(&eye, &target, &up); - let origin = Point3::origin(); - - prop_assert!(relative_eq!(viewmatrix * eye, origin, epsilon = 1.0e-7) - && relative_eq!( - (viewmatrix * (target - eye)).normalize(), - -Vector3::z(), - epsilon = 1.0e-7 - )) - } - - #[test] - fn observer_frame_3(eye in point3(), target in point3(), up in vector3()) { - let observer = Isometry3::face_towards(&eye, &target, &up); - let origin = Point3::origin(); - - prop_assert!(relative_eq!(observer * origin, eye, epsilon = 1.0e-7) - && relative_eq!( - observer * Vector3::z(), - (target - eye).normalize(), - epsilon = 1.0e-7 - )) - } - - #[test] - fn inverse_is_identity(i in isometry3(), p in point3(), v in vector3()) { - let ii = i.inverse(); - - prop_assert!(relative_eq!(i * ii, Isometry3::identity(), epsilon = 1.0e-7) - && relative_eq!(ii * i, Isometry3::identity(), epsilon = 1.0e-7) - && relative_eq!((i * ii) * p, p, epsilon = 1.0e-7) - && relative_eq!((ii * i) * p, p, epsilon = 1.0e-7) - && relative_eq!((i * ii) * v, v, epsilon = 1.0e-7) - && relative_eq!((ii * i) * v, v, epsilon = 1.0e-7)) - } - - #[test] - fn inverse_is_parts_inversion(t in translation3(), r in unit_quaternion()) { - let i = t * r; - prop_assert!(i.inverse() == r.inverse() * t.inverse()) - } - - #[test] - fn multiply_equals_alga_transform(i in isometry3(), v in vector3(), p in point3()) { - prop_assert!(i * v == i.transform_vector(&v) - && i * p == i.transform_point(&p) - && relative_eq!( - i.inverse() * v, - i.inverse_transform_vector(&v), - epsilon = 1.0e-7 - ) - && relative_eq!( - i.inverse() * p, - i.inverse_transform_point(&p), - epsilon = 1.0e-7 - )) - } - - #[test] - #[cfg_attr(rustfmt, rustfmt_skip)] - fn composition2( - i in isometry2(), - uc in unit_complex(), - r in rotation2(), - t in translation2(), - v in vector2(), - p in point2() - ) { - // (rotation × translation) * point = rotation × (translation * point) - prop_assert!(relative_eq!((uc * t) * v, uc * v, epsilon = 1.0e-7)); - prop_assert!(relative_eq!((r * t) * v, r * v, epsilon = 1.0e-7)); - prop_assert!(relative_eq!((uc * t) * p, uc * (t * p), epsilon = 1.0e-7)); - prop_assert!(relative_eq!((r * t) * p, r * (t * p), epsilon = 1.0e-7)); - - // (translation × rotation) * point = translation × (rotation * point) - prop_assert_eq!((t * uc) * v, uc * v); - prop_assert_eq!((t * r) * v, r * v); - prop_assert_eq!((t * uc) * p, t * (uc * p)); - prop_assert_eq!((t * r) * p, t * (r * p)); - - // (rotation × isometry) * point = rotation × (isometry * point) - prop_assert!(relative_eq!((uc * i) * v, uc * (i * v), epsilon = 1.0e-7)); - prop_assert!(relative_eq!((uc * i) * p, uc * (i * p), epsilon = 1.0e-7)); - - // (isometry × rotation) * point = isometry × (rotation * point) - prop_assert!(relative_eq!((i * uc) * v, i * (uc * v), epsilon = 1.0e-7)); - prop_assert!(relative_eq!((i * uc) * p, i * (uc * p), epsilon = 1.0e-7)); - - // (translation × isometry) * point = translation × (isometry * point) - prop_assert!(relative_eq!((t * i) * v, (i * v), epsilon = 1.0e-7)); - prop_assert!(relative_eq!((t * i) * p, t * (i * p), epsilon = 1.0e-7)); - - // (isometry × translation) * point = isometry × (translation * point) - prop_assert!(relative_eq!((i * t) * v, i * v, epsilon = 1.0e-7)); - prop_assert!(relative_eq!((i * t) * p, i * (t * p), epsilon = 1.0e-7)); - } - - #[test] - #[cfg_attr(rustfmt, rustfmt_skip)] - fn composition3( - i in isometry3(), - uq in unit_quaternion(), - r in rotation3(), - t in translation3(), - v in vector3(), - p in point3() - ) { - // (rotation × translation) * point = rotation × (translation * point) - prop_assert!(relative_eq!((uq * t) * v, uq * v, epsilon = 1.0e-7)); - prop_assert!(relative_eq!((r * t) * v, r * v, epsilon = 1.0e-7)); - prop_assert!(relative_eq!((uq * t) * p, uq * (t * p), epsilon = 1.0e-7)); - prop_assert!(relative_eq!((r * t) * p, r * (t * p), epsilon = 1.0e-7)); - - // (translation × rotation) * point = translation × (rotation * point) - prop_assert_eq!((t * uq) * v, uq * v); - prop_assert_eq!((t * r) * v, r * v); - prop_assert_eq!((t * uq) * p, t * (uq * p)); - prop_assert_eq!((t * r) * p, t * (r * p)); - - // (rotation × isometry) * point = rotation × (isometry * point) - prop_assert!(relative_eq!((uq * i) * v, uq * (i * v), epsilon = 1.0e-7)); - prop_assert!(relative_eq!((uq * i) * p, uq * (i * p), epsilon = 1.0e-7)); - - // (isometry × rotation) * point = isometry × (rotation * point) - prop_assert!(relative_eq!((i * uq) * v, i * (uq * v), epsilon = 1.0e-7)); - prop_assert!(relative_eq!((i * uq) * p, i * (uq * p), epsilon = 1.0e-7)); - - // (translation × isometry) * point = translation × (isometry * point) - prop_assert!(relative_eq!((t * i) * v, (i * v), epsilon = 1.0e-7)); - prop_assert!(relative_eq!((t * i) * p, t * (i * p), epsilon = 1.0e-7)); - - // (isometry × translation) * point = isometry × (translation * point) - prop_assert!(relative_eq!((i * t) * v, i * v, epsilon = 1.0e-7)); - prop_assert!(relative_eq!((i * t) * p, i * (t * p), epsilon = 1.0e-7)); - } - - #[test] - #[cfg_attr(rustfmt, rustfmt_skip)] - fn all_op_exist( - i in isometry3(), - uq in unit_quaternion(), - t in translation3(), - v in vector3(), - p in point3(), - r in rotation3() - ) { - let iMi = i * i; - let iMuq = i * uq; - let iDi = i / i; - let iDuq = i / uq; - - let iMp = i * p; - let iMv = i * v; - - let iMt = i * t; - let tMi = t * i; - - let tMr = t * r; - let tMuq = t * uq; - - let uqMi = uq * i; - let uqDi = uq / i; - - let rMt = r * t; - let uqMt = uq * t; - - let mut iMt1 = i; - let mut iMt2 = i; - - let mut iMi1 = i; - let mut iMi2 = i; - - let mut iMuq1 = i; - let mut iMuq2 = i; - - let mut iDi1 = i; - let mut iDi2 = i; - - let mut iDuq1 = i; - let mut iDuq2 = i; - - iMt1 *= t; - iMt2 *= &t; - - iMi1 *= i; - iMi2 *= &i; - - iMuq1 *= uq; - iMuq2 *= &uq; - - iDi1 /= i; - iDi2 /= &i; - - iDuq1 /= uq; - iDuq2 /= &uq; - - prop_assert!(iMt == iMt1 - && iMt == iMt2 - && iMi == iMi1 - && iMi == iMi2 - && iMuq == iMuq1 - && iMuq == iMuq2 - && iDi == iDi1 - && iDi == iDi2 - && iDuq == iDuq1 - && iDuq == iDuq2 - && iMi == &i * &i - && iMi == i * &i - && iMi == &i * i - && iMuq == &i * &uq - && iMuq == i * &uq - && iMuq == &i * uq - && iDi == &i / &i - && iDi == i / &i - && iDi == &i / i - && iDuq == &i / &uq - && iDuq == i / &uq - && iDuq == &i / uq - && iMp == &i * &p - && iMp == i * &p - && iMp == &i * p - && iMv == &i * &v - && iMv == i * &v - && iMv == &i * v - && iMt == &i * &t - && iMt == i * &t - && iMt == &i * t - && tMi == &t * &i - && tMi == t * &i - && tMi == &t * i - && tMr == &t * &r - && tMr == t * &r - && tMr == &t * r - && tMuq == &t * &uq - && tMuq == t * &uq - && tMuq == &t * uq - && uqMi == &uq * &i - && uqMi == uq * &i - && uqMi == &uq * i - && uqDi == &uq / &i - && uqDi == uq / &i - && uqDi == &uq / i - && rMt == &r * &t - && rMt == r * &t - && rMt == &r * t - && uqMt == &uq * &t - && uqMt == uq * &t - && uqMt == &uq * t) - } -); diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/geometry/mod.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/geometry/mod.rs deleted file mode 100644 index 135e0d2b5..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/geometry/mod.rs +++ /dev/null @@ -1,8 +0,0 @@ -mod dual_quaternion; -mod isometry; -mod point; -mod projection; -mod quaternion; -mod rotation; -mod similarity; -mod unit_complex; diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/geometry/point.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/geometry/point.rs deleted file mode 100644 index 8867e2b44..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/geometry/point.rs +++ /dev/null @@ -1,102 +0,0 @@ -use na::{Point3, Vector3, Vector4}; -use num::Zero; - -#[test] -fn point_clone() { - let p = Point3::new(1.0, 2.0, 3.0); - let p2 = p.clone(); - assert_eq!(p, p2); -} - -#[test] -fn point_ops() { - let a = Point3::new(1.0, 2.0, 3.0); - let b = Point3::new(1.0, 2.0, 3.0); - let c = Vector3::new(1.0, 2.0, 3.0); - - assert_eq!(a - b, Vector3::zero()); - assert_eq!(&a - &b, Vector3::zero()); - assert_eq!(a - &b, Vector3::zero()); - assert_eq!(&a - b, Vector3::zero()); - - assert_eq!(b - c, Point3::origin()); - assert_eq!(&b - &c, Point3::origin()); - assert_eq!(b - &c, Point3::origin()); - assert_eq!(&b - c, Point3::origin()); - - assert_eq!(b + c, 2.0 * a); - assert_eq!(&b + &c, 2.0 * a); - assert_eq!(b + &c, 2.0 * a); - assert_eq!(&b + c, 2.0 * a); - - let mut a1 = a; - let mut a2 = a; - let mut a3 = a; - let mut a4 = a; - - a1 -= c; - a2 -= &c; - a3 += c; - a4 += &c; - - assert_eq!(a1, Point3::origin()); - assert_eq!(a2, Point3::origin()); - assert_eq!(a3, 2.0 * a); - assert_eq!(a4, 2.0 * a); -} - -#[test] -fn point_coordinates() { - let mut pt = Point3::origin(); - - assert_eq!(pt.x, 0); - assert_eq!(pt.y, 0); - assert_eq!(pt.z, 0); - - pt.x = 1; - pt.y = 2; - pt.z = 3; - - assert_eq!(pt.x, 1); - assert_eq!(pt.y, 2); - assert_eq!(pt.z, 3); -} - -#[test] -fn point_scale() { - let pt = Point3::new(1, 2, 3); - let expected = Point3::new(10, 20, 30); - - assert_eq!(pt * 10, expected); - assert_eq!(&pt * 10, expected); - assert_eq!(10 * pt, expected); - assert_eq!(10 * &pt, expected); -} - -#[test] -fn point_vector_sum() { - let pt = Point3::new(1, 2, 3); - let vec = Vector3::new(10, 20, 30); - let expected = Point3::new(11, 22, 33); - - assert_eq!(&pt + &vec, expected); - assert_eq!(pt + &vec, expected); - assert_eq!(&pt + vec, expected); - assert_eq!(pt + vec, expected); -} - -#[test] -fn to_homogeneous() { - let a = Point3::new(1.0, 2.0, 3.0); - let expected = Vector4::new(1.0, 2.0, 3.0, 1.0); - - assert_eq!(a.to_homogeneous(), expected); -} - -#[test] -fn display_fmt_respects_modifiers() { - let p = Point3::new(1.23, 3.45, 5.67); - assert_eq!(&format!("{p}"), "{1.23, 3.45, 5.67}"); - assert_eq!(&format!("{p:.1}"), "{1.2, 3.5, 5.7}"); - assert_eq!(&format!("{p:.0}"), "{1, 3, 6}"); -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/geometry/projection.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/geometry/projection.rs deleted file mode 100644 index 0fb7090cf..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/geometry/projection.rs +++ /dev/null @@ -1,64 +0,0 @@ -use na::{Orthographic3, Perspective3, Point3}; - -#[test] -fn perspective_inverse() { - let proj = Perspective3::new(800.0 / 600.0, 3.14 / 2.0, 1.0, 1000.0); - let inv = proj.inverse(); - - let id = inv * proj.into_inner(); - - assert!(id.is_identity(1.0e-7)); -} - -#[test] -fn orthographic_inverse() { - let proj = Orthographic3::new(1.0, 2.0, -3.0, -2.5, 10.0, 900.0); - let inv = proj.inverse(); - - let id = inv * proj.into_inner(); - - assert!(id.is_identity(1.0e-7)); -} - -#[test] -fn perspective_matrix_point_transformation() { - // https://github.com/dimforge/nalgebra/issues/640 - let proj = Perspective3::new(4.0 / 3.0, 90.0, 0.1, 100.0); - let perspective_inv = proj.as_matrix().try_inverse().unwrap(); - let some_point = Point3::new(1.0, 2.0, 0.0); - - assert_eq!( - perspective_inv.transform_point(&some_point), - Point3::from_homogeneous(perspective_inv * some_point.coords.push(1.0)).unwrap() - ); -} - -#[cfg(feature = "proptest-support")] -mod proptest_tests { - use na::{Orthographic3, Perspective3}; - - use crate::proptest::*; - use proptest::{prop_assert, proptest}; - - proptest! { - #[test] - fn perspective_project_unproject(pt in point3()) { - let proj = Perspective3::new(800.0 / 600.0, 3.14 / 2.0, 1.0, 1000.0); - - let projected = proj.project_point(&pt); - let unprojected = proj.unproject_point(&projected); - - prop_assert!(relative_eq!(pt, unprojected, epsilon = 1.0e-7)) - } - - #[test] - fn orthographic_project_unproject(pt in point3()) { - let proj = Orthographic3::new(1.0, 2.0, -3.0, -2.5, 10.0, 900.0); - - let projected = proj.project_point(&pt); - let unprojected = proj.unproject_point(&projected); - - prop_assert!(relative_eq!(pt, unprojected, epsilon = 1.0e-7)) - } - } -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/geometry/quaternion.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/geometry/quaternion.rs deleted file mode 100644 index 38b86ce38..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/geometry/quaternion.rs +++ /dev/null @@ -1,266 +0,0 @@ -#![cfg(feature = "proptest-support")] -#![allow(non_snake_case)] - -use na::{Unit, UnitQuaternion}; - -use crate::proptest::*; -use proptest::{prop_assert, proptest}; - -proptest!( - /* - * - * Euler angles. - * - */ - #[test] - fn from_euler_angles(r in PROPTEST_F64, p in PROPTEST_F64, y in PROPTEST_F64) { - let roll = UnitQuaternion::from_euler_angles(r, 0.0, 0.0); - let pitch = UnitQuaternion::from_euler_angles(0.0, p, 0.0); - let yaw = UnitQuaternion::from_euler_angles(0.0, 0.0, y); - - let rpy = UnitQuaternion::from_euler_angles(r, p, y); - - let rroll = roll.to_rotation_matrix(); - let rpitch = pitch.to_rotation_matrix(); - let ryaw = yaw.to_rotation_matrix(); - - prop_assert!(relative_eq!(rroll[(0, 0)], 1.0, epsilon = 1.0e-7)); // rotation wrt. x axis. - prop_assert!(relative_eq!(rpitch[(1, 1)], 1.0, epsilon = 1.0e-7)); // rotation wrt. y axis. - prop_assert!(relative_eq!(ryaw[(2, 2)], 1.0, epsilon = 1.0e-7)); // rotation wrt. z axis. - prop_assert!(relative_eq!(yaw * pitch * roll, rpy, epsilon = 1.0e-7)); - } - - #[test] - fn euler_angles(r in PROPTEST_F64, p in PROPTEST_F64, y in PROPTEST_F64) { - let rpy = UnitQuaternion::from_euler_angles(r, p, y); - let (roll, pitch, yaw) = rpy.euler_angles(); - prop_assert!(relative_eq!( - UnitQuaternion::from_euler_angles(roll, pitch, yaw), - rpy, - epsilon = 1.0e-7 - )) - } - - /* - * - * From/to rotation matrix. - * - */ - #[test] - fn unit_quaternion_rotation_conversion(q in unit_quaternion()) { - let r = q.to_rotation_matrix(); - let qq = UnitQuaternion::from_rotation_matrix(&r); - let rr = qq.to_rotation_matrix(); - - prop_assert!(relative_eq!(q, qq, epsilon = 1.0e-7) && relative_eq!(r, rr, epsilon = 1.0e-7)) - } - - /* - * - * Point/Vector transformation. - * - */ - - #[test] - #[cfg_attr(rustfmt, rustfmt_skip)] - fn unit_quaternion_transformation( - q in unit_quaternion(), - v in vector3(), - p in point3() - ) { - let r = q.to_rotation_matrix(); - let rv = r * v; - let rp = r * p; - - prop_assert!(relative_eq!(q * v, rv, epsilon = 1.0e-7) - && relative_eq!(q * &v, rv, epsilon = 1.0e-7) - && relative_eq!(&q * v, rv, epsilon = 1.0e-7) - && relative_eq!(&q * &v, rv, epsilon = 1.0e-7) - && relative_eq!(q * p, rp, epsilon = 1.0e-7) - && relative_eq!(q * &p, rp, epsilon = 1.0e-7) - && relative_eq!(&q * p, rp, epsilon = 1.0e-7) - && relative_eq!(&q * &p, rp, epsilon = 1.0e-7)) - } - - /* - * - * Inversion. - * - */ - #[test] - fn unit_quaternion_inv(q in unit_quaternion()) { - let iq = q.inverse(); - prop_assert!(relative_eq!(&iq * &q, UnitQuaternion::identity(), epsilon = 1.0e-7) - && relative_eq!(iq * &q, UnitQuaternion::identity(), epsilon = 1.0e-7) - && relative_eq!(&iq * q, UnitQuaternion::identity(), epsilon = 1.0e-7) - && relative_eq!(iq * q, UnitQuaternion::identity(), epsilon = 1.0e-7) - && relative_eq!(&q * &iq, UnitQuaternion::identity(), epsilon = 1.0e-7) - && relative_eq!(q * &iq, UnitQuaternion::identity(), epsilon = 1.0e-7) - && relative_eq!(&q * iq, UnitQuaternion::identity(), epsilon = 1.0e-7) - && relative_eq!(q * iq, UnitQuaternion::identity(), epsilon = 1.0e-7)) - } - - /* - * - * Quaterion * Vector == Rotation * Vector - * - */ - #[test] - fn unit_quaternion_mul_vector(q in unit_quaternion(), v in vector3(), p in point3()) { - let r = q.to_rotation_matrix(); - - prop_assert!(relative_eq!(q * v, r * v, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(q * p, r * p, epsilon = 1.0e-7)); - // Equivalence q = -q - prop_assert!(relative_eq!(UnitQuaternion::new_unchecked(-q.into_inner()) * v, r * v, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(UnitQuaternion::new_unchecked(-q.into_inner()) * p, r * p, epsilon = 1.0e-7)); - } - - /* - * - * Unit quaternion double-covering. - * - */ - #[test] - fn unit_quaternion_double_covering(q in unit_quaternion()) { - let mq = UnitQuaternion::new_unchecked(-q.into_inner()); - prop_assert!(mq == q && mq.angle() == q.angle() && mq.axis() == q.axis()) - } - - // Test that all operators (incl. all combinations of references) work. - // See the top comment on `geometry/quaternion_ops.rs` for details on which operations are - // supported. - #[test] - #[cfg_attr(rustfmt, rustfmt_skip)] - fn all_op_exist( - q in quaternion(), - uq in unit_quaternion(), - v in vector3(), - p in point3(), - r in rotation3(), - s in PROPTEST_F64 - ) { - let uv = Unit::new_normalize(v); - - let qpq = q + q; - let qmq = q - q; - let qMq = q * q; - let mq = -q; - let qMs = q * s; - let qDs = q / s; - let sMq = s * q; - - let uqMuq = uq * uq; - let uqMr = uq * r; - let rMuq = r * uq; - let uqDuq = uq / uq; - let uqDr = uq / r; - let rDuq = r / uq; - - let uqMp = uq * p; - let uqMv = uq * v; - let uqMuv = uq * uv; - - let mut qMs1 = q; - - let mut qMq1 = q; - let mut qMq2 = q; - - let mut qpq1 = q; - let mut qpq2 = q; - - let mut qmq1 = q; - let mut qmq2 = q; - - let mut uqMuq1 = uq; - let mut uqMuq2 = uq; - - let mut uqMr1 = uq; - let mut uqMr2 = uq; - - let mut uqDuq1 = uq; - let mut uqDuq2 = uq; - - let mut uqDr1 = uq; - let mut uqDr2 = uq; - - qMs1 *= s; - - qMq1 *= q; - qMq2 *= &q; - - qpq1 += q; - qpq2 += &q; - - qmq1 -= q; - qmq2 -= &q; - - uqMuq1 *= uq; - uqMuq2 *= &uq; - - uqMr1 *= r; - uqMr2 *= &r; - - uqDuq1 /= uq; - uqDuq2 /= &uq; - - uqDr1 /= r; - uqDr2 /= &r; - - prop_assert!(qMs1 == qMs - && qMq1 == qMq - && qMq1 == qMq2 - && qpq1 == qpq - && qpq1 == qpq2 - && qmq1 == qmq - && qmq1 == qmq2 - && uqMuq1 == uqMuq - && uqMuq1 == uqMuq2 - && uqMr1 == uqMr - && uqMr1 == uqMr2 - && uqDuq1 == uqDuq - && uqDuq1 == uqDuq2 - && uqDr1 == uqDr - && uqDr1 == uqDr2 - && qpq == &q + &q - && qpq == q + &q - && qpq == &q + q - && qmq == &q - &q - && qmq == q - &q - && qmq == &q - q - && qMq == &q * &q - && qMq == q * &q - && qMq == &q * q - && mq == -&q - && qMs == &q * s - && qDs == &q / s - && sMq == s * &q - && uqMuq == &uq * &uq - && uqMuq == uq * &uq - && uqMuq == &uq * uq - && uqMr == &uq * &r - && uqMr == uq * &r - && uqMr == &uq * r - && rMuq == &r * &uq - && rMuq == r * &uq - && rMuq == &r * uq - && uqDuq == &uq / &uq - && uqDuq == uq / &uq - && uqDuq == &uq / uq - && uqDr == &uq / &r - && uqDr == uq / &r - && uqDr == &uq / r - && rDuq == &r / &uq - && rDuq == r / &uq - && rDuq == &r / uq - && uqMp == &uq * &p - && uqMp == uq * &p - && uqMp == &uq * p - && uqMv == &uq * &v - && uqMv == uq * &v - && uqMv == &uq * v - && uqMuv == &uq * &uv - && uqMuv == uq * &uv - && uqMuv == &uq * uv) - } -); diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/geometry/rotation.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/geometry/rotation.rs deleted file mode 100644 index b08f25328..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/geometry/rotation.rs +++ /dev/null @@ -1,359 +0,0 @@ -use na::{ - Matrix3, Quaternion, RealField, Rotation3, UnitQuaternion, UnitVector3, Vector2, Vector3, -}; -use std::f64::consts::PI; - -#[test] -fn angle_2() { - let a = Vector2::new(4.0, 0.0); - let b = Vector2::new(9.0, 0.0); - - assert_eq!(a.angle(&b), 0.0); -} - -#[test] -fn angle_3() { - let a = Vector3::new(4.0, 0.0, 0.5); - let b = Vector3::new(8.0, 0.0, 1.0); - - assert_eq!(a.angle(&b), 0.0); -} - -#[test] -fn from_rotation_matrix() { - // Test degenerate case when from_matrix gets stuck in Identity rotation - let identity = - Rotation3::from_matrix(&Matrix3::new(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0)); - assert_relative_eq!(identity, &Rotation3::identity(), epsilon = 0.001); - let rotated_z = - Rotation3::from_matrix(&Matrix3::new(1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0)); - assert_relative_eq!( - rotated_z, - &Rotation3::from_axis_angle(&UnitVector3::new_unchecked(Vector3::new(1.0, 0.0, 0.0)), PI), - epsilon = 0.001 - ); - // Test that issue 627 is fixed - let m_627 = Matrix3::::new(-1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 1.0); - assert_relative_ne!(identity, Rotation3::from_matrix(&m_627), epsilon = 0.01); - assert_relative_eq!( - Rotation3::from_matrix_unchecked(m_627.clone()), - Rotation3::from_matrix(&m_627), - epsilon = 0.001 - ); - // Test that issue 1078 is fixed - let m_1078 = Matrix3::::new(0.0, 0.0, 1.0, 0.0, -1.0, 0.0, 1.0, 0.0, 0.0); - assert_relative_ne!(identity, Rotation3::from_matrix(&m_1078), epsilon = 0.01); - assert_relative_eq!( - Rotation3::from_matrix_unchecked(m_1078.clone()), - Rotation3::from_matrix(&m_1078), - epsilon = 0.001 - ); - // Additional test cases for eps >= 1.0 - assert_relative_ne!( - identity, - Rotation3::from_matrix_eps(&m_627, 1.2, 0, Rotation3::identity()), - epsilon = 0.6 - ); - assert_relative_eq!( - Rotation3::from_matrix_unchecked(m_627.clone()), - Rotation3::from_matrix_eps(&m_627, 1.2, 0, Rotation3::identity()), - epsilon = 0.6 - ); - assert_relative_ne!( - identity, - Rotation3::from_matrix_eps(&m_1078, 1.0, 0, Rotation3::identity()), - epsilon = 0.1 - ); - assert_relative_eq!( - Rotation3::from_matrix_unchecked(m_1078.clone()), - Rotation3::from_matrix_eps(&m_1078, 1.0, 0, Rotation3::identity()), - epsilon = 0.1 - ); -} - -#[test] -fn quaternion_euler_angles_issue_494() { - let quat = UnitQuaternion::from_quaternion(Quaternion::new( - -0.10405792, - -0.6993922f32, - -0.10406871, - 0.69942284, - )); - let angs = quat.euler_angles(); - assert_eq!(angs.0, 2.8461843); - assert_eq!(angs.1, f32::frac_pi_2()); - assert_eq!(angs.2, 0.0); -} - -#[cfg(feature = "proptest-support")] -mod proptest_tests { - use approx::AbsDiffEq; - use na::{self, Rotation2, Rotation3, Unit}; - use na::{UnitComplex, UnitQuaternion}; - use simba::scalar::RealField; - use std::f64; - - use crate::proptest::*; - use proptest::{prop_assert, prop_assert_eq, proptest}; - - proptest! { - /* - * - * Euler angles. - * - */ - #[test] - fn from_euler_angles(r in PROPTEST_F64, p in PROPTEST_F64, y in PROPTEST_F64) { - let roll = Rotation3::from_euler_angles(r, 0.0, 0.0); - let pitch = Rotation3::from_euler_angles(0.0, p, 0.0); - let yaw = Rotation3::from_euler_angles(0.0, 0.0, y); - - let rpy = Rotation3::from_euler_angles(r, p, y); - - prop_assert_eq!(roll[(0, 0)], 1.0); // rotation wrt. x axis. - prop_assert_eq!(pitch[(1, 1)], 1.0); // rotation wrt. y axis. - prop_assert_eq!(yaw[(2, 2)], 1.0); // rotation wrt. z axis. - prop_assert_eq!(yaw * pitch * roll, rpy); - } - - #[test] - fn euler_angles(r in PROPTEST_F64, p in PROPTEST_F64, y in PROPTEST_F64) { - let rpy = Rotation3::from_euler_angles(r, p, y); - let (roll, pitch, yaw) = rpy.euler_angles(); - prop_assert!(relative_eq!(Rotation3::from_euler_angles(roll, pitch, yaw), rpy, epsilon = 1.0e-7)); - } - - #[test] - fn euler_angles_gimble_lock(r in PROPTEST_F64, y in PROPTEST_F64) { - let pos = Rotation3::from_euler_angles(r, f64::frac_pi_2(), y); - let neg = Rotation3::from_euler_angles(r, -f64::frac_pi_2(), y); - let (pos_r, pos_p, pos_y) = pos.euler_angles(); - let (neg_r, neg_p, neg_y) = neg.euler_angles(); - prop_assert!(relative_eq!(Rotation3::from_euler_angles(pos_r, pos_p, pos_y), pos, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(Rotation3::from_euler_angles(neg_r, neg_p, neg_y), neg, epsilon = 1.0e-7)); - } - - /* - * - * Inversion is transposition. - * - */ - #[test] - fn rotation_inv_3(a in rotation3()) { - let ta = a.transpose(); - let ia = a.inverse(); - - prop_assert_eq!(ta, ia); - prop_assert!(relative_eq!(&ta * &a, Rotation3::identity(), epsilon = 1.0e-7)); - prop_assert!(relative_eq!(&ia * a, Rotation3::identity(), epsilon = 1.0e-7)); - prop_assert!(relative_eq!( a * &ta, Rotation3::identity(), epsilon = 1.0e-7)); - prop_assert!(relative_eq!( a * ia, Rotation3::identity(), epsilon = 1.0e-7)); - } - - #[test] - fn rotation_inv_2(a in rotation2()) { - let ta = a.transpose(); - let ia = a.inverse(); - - prop_assert_eq!(ta, ia); - prop_assert!(relative_eq!(&ta * &a, Rotation2::identity(), epsilon = 1.0e-7)); - prop_assert!(relative_eq!(&ia * a, Rotation2::identity(), epsilon = 1.0e-7)); - prop_assert!(relative_eq!( a * &ta, Rotation2::identity(), epsilon = 1.0e-7)); - prop_assert!(relative_eq!( a * ia, Rotation2::identity(), epsilon = 1.0e-7)); - } - - /* - * - * Angle between vectors. - * - */ - #[test] - fn angle_is_commutative_2(a in vector2(), b in vector2()) { - prop_assert_eq!(a.angle(&b), b.angle(&a)) - } - - #[test] - fn angle_is_commutative_3(a in vector3(), b in vector3()) { - prop_assert_eq!(a.angle(&b), b.angle(&a)) - } - - /* - * - * Rotation matrix between vectors. - * - */ - #[test] - fn rotation_between_is_anticommutative_2(a in vector2(), b in vector2()) { - let rab = Rotation2::rotation_between(&a, &b); - let rba = Rotation2::rotation_between(&b, &a); - - prop_assert!(relative_eq!(rab * rba, Rotation2::identity())); - } - - #[test] - fn rotation_between_is_anticommutative_3(a in vector3(), b in vector3()) { - let rots = (Rotation3::rotation_between(&a, &b), Rotation3::rotation_between(&b, &a)); - if let (Some(rab), Some(rba)) = rots { - prop_assert!(relative_eq!(rab * rba, Rotation3::identity(), epsilon = 1.0e-7)); - } - } - - #[test] - fn rotation_between_is_identity(v2 in vector2(), v3 in vector3()) { - let vv2 = 3.42 * v2; - let vv3 = 4.23 * v3; - - prop_assert!(relative_eq!(v2.angle(&vv2), 0.0, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(v3.angle(&vv3), 0.0, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(Rotation2::rotation_between(&v2, &vv2), Rotation2::identity())); - prop_assert_eq!(Rotation3::rotation_between(&v3, &vv3).unwrap(), Rotation3::identity()); - } - - #[test] - fn rotation_between_2(a in vector2(), b in vector2()) { - if !relative_eq!(a.angle(&b), 0.0, epsilon = 1.0e-7) { - let r = Rotation2::rotation_between(&a, &b); - prop_assert!(relative_eq!((r * a).angle(&b), 0.0, epsilon = 1.0e-7)) - } - } - - #[test] - fn rotation_between_3(a in vector3(), b in vector3()) { - if !relative_eq!(a.angle(&b), 0.0, epsilon = 1.0e-7) { - let r = Rotation3::rotation_between(&a, &b).unwrap(); - prop_assert!(relative_eq!((r * a).angle(&b), 0.0, epsilon = 1.0e-7)) - } - } - - - /* - * - * Rotation construction. - * - */ - #[test] - fn new_rotation_2(angle in PROPTEST_F64) { - let r = Rotation2::new(angle); - - let angle = na::wrap(angle, -f64::pi(), f64::pi()); - prop_assert!(relative_eq!(r.angle(), angle, epsilon = 1.0e-7)) - } - - #[test] - fn new_rotation_3(axisangle in vector3()) { - let r = Rotation3::new(axisangle); - - if let Some((axis, angle)) = Unit::try_new_and_get(axisangle, 0.0) { - let angle = na::wrap(angle, -f64::pi(), f64::pi()); - prop_assert!((relative_eq!(r.angle(), angle, epsilon = 1.0e-7) && - relative_eq!(r.axis().unwrap(), axis, epsilon = 1.0e-7)) || - (relative_eq!(r.angle(), -angle, epsilon = 1.0e-7) && - relative_eq!(r.axis().unwrap(), -axis, epsilon = 1.0e-7))) - } - else { - prop_assert_eq!(r, Rotation3::identity()) - } - } - - /* - * - * Rotation pow. - * - */ - #[test] - fn powf_rotation_2(angle in PROPTEST_F64, pow in PROPTEST_F64) { - let r = Rotation2::new(angle).powf(pow); - - let angle = na::wrap(angle, -f64::pi(), f64::pi()); - let pangle = na::wrap(angle * pow, -f64::pi(), f64::pi()); - prop_assert!(relative_eq!(r.angle(), pangle, epsilon = 1.0e-7)); - } - - #[test] - fn powf_rotation_3(axisangle in vector3(), pow in PROPTEST_F64) { - let r = Rotation3::new(axisangle).powf(pow); - - if let Some((axis, angle)) = Unit::try_new_and_get(axisangle, 0.0) { - let angle = na::wrap(angle, -f64::pi(), f64::pi()); - let pangle = na::wrap(angle * pow, -f64::pi(), f64::pi()); - - prop_assert!((relative_eq!(r.angle(), pangle, epsilon = 1.0e-7) && - relative_eq!(r.axis().unwrap(), axis, epsilon = 1.0e-7)) || - (relative_eq!(r.angle(), -pangle, epsilon = 1.0e-7) && - relative_eq!(r.axis().unwrap(), -axis, epsilon = 1.0e-7))); - } - else { - prop_assert_eq!(r, Rotation3::identity()) - } - } - - // - //In general, `slerp(a,b,t)` should equal `(b/a)^t * a` even though in practice, - //we may not use that formula directly for complex numbers or quaternions - // - - #[test] - fn slerp_powf_agree_2(a in unit_complex(), b in unit_complex(), t in PROPTEST_F64) { - let z1 = a.slerp(&b, t); - let z2 = (b/a).powf(t) * a; - prop_assert!(relative_eq!(z1,z2,epsilon=1e-10)); - } - - #[test] - fn slerp_powf_agree_3(a in unit_quaternion(), b in unit_quaternion(), t in PROPTEST_F64) { - if let Some(z1) = a.try_slerp(&b, t, f64::default_epsilon()) { - let z2 = (b/a).powf(t) * a; - prop_assert!(relative_eq!(z1,z2,epsilon=1e-10)); - } - } - - // - //when not antipodal, slerp should always take the shortest path between two orientations - // - - #[test] - fn slerp_takes_shortest_path_2( - z in unit_complex(), dtheta in -f64::pi()..f64::pi(), t in 0.0..1.0f64 - ) { - - //ambiguous when at ends of angle range, so we don't really care here - if dtheta.abs() != f64::pi() { - - //make two complex numbers separated by an angle between -pi and pi - let (z1, z2) = (z, z * UnitComplex::new(dtheta)); - let z3 = z1.slerp(&z2, t); - - //since the angle is no larger than a half-turn, and t is between 0 and 1, - //the shortest path just corresponds to adding the scaled angle - let a1 = z3.angle(); - let a2 = na::wrap(z1.angle() + dtheta*t, -f64::pi(), f64::pi()); - - prop_assert!(relative_eq!(a1, a2, epsilon=1e-10)); - } - - } - - #[test] - fn slerp_takes_shortest_path_3( - q in unit_quaternion(), dtheta in -f64::pi()..f64::pi(), t in 0.0..1.0f64 - ) { - - //ambiguous when at ends of angle range, so we don't really care here - if let Some(axis) = q.axis() { - - //make two quaternions separated by an angle between -pi and pi - let (q1, q2) = (q, q * UnitQuaternion::from_axis_angle(&axis, dtheta)); - let q3 = q1.slerp(&q2, t); - - //since the angle is no larger than a half-turn, and t is between 0 and 1, - //the shortest path just corresponds to adding the scaled angle - let q4 = q1 * UnitQuaternion::from_axis_angle(&axis, dtheta*t); - prop_assert!(relative_eq!(q3, q4, epsilon=1e-10)); - - } - - } - - - } -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/geometry/similarity.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/geometry/similarity.rs deleted file mode 100644 index 7fac33813..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/geometry/similarity.rs +++ /dev/null @@ -1,280 +0,0 @@ -#![cfg(feature = "proptest-support")] -#![allow(non_snake_case)] - -use na::Similarity3; - -use crate::proptest::*; -use proptest::{prop_assert, prop_assert_eq, proptest}; - -proptest!( - #[test] - fn inverse_is_identity(i in similarity3(), p in point3(), v in vector3()) { - let ii = i.inverse(); - - prop_assert!(relative_eq!(i * ii, Similarity3::identity(), epsilon = 1.0e-7) - && relative_eq!(ii * i, Similarity3::identity(), epsilon = 1.0e-7) - && relative_eq!((i * ii) * p, p, epsilon = 1.0e-7) - && relative_eq!((ii * i) * p, p, epsilon = 1.0e-7) - && relative_eq!((i * ii) * v, v, epsilon = 1.0e-7) - && relative_eq!((ii * i) * v, v, epsilon = 1.0e-7)) - } - - #[test] - #[cfg_attr(rustfmt, rustfmt_skip)] - fn inverse_is_parts_inversion( - t in translation3(), - r in unit_quaternion(), - scaling in PROPTEST_F64 - ) { - if !relative_eq!(scaling, 0.0) { - let s = Similarity3::from_isometry(t * r, scaling); - prop_assert_eq!(s.inverse(), Similarity3::from_scaling(1.0 / scaling) * r.inverse() * t.inverse()) - } - } - - #[test] - #[cfg_attr(rustfmt, rustfmt_skip)] - fn multiply_equals_alga_transform( - s in similarity3(), - v in vector3(), - p in point3() - ) { - prop_assert!(s * v == s.transform_vector(&v) - && s * p == s.transform_point(&p) - && relative_eq!( - s.inverse() * v, - s.inverse_transform_vector(&v), - epsilon = 1.0e-7 - ) - && relative_eq!( - s.inverse() * p, - s.inverse_transform_point(&p), - epsilon = 1.0e-7 - )) - } - - #[test] - #[cfg_attr(rustfmt, rustfmt_skip)] - fn composition( - i in isometry3(), - uq in unit_quaternion(), - t in translation3(), - v in vector3(), - p in point3(), - scaling in PROPTEST_F64 - ) { - if !relative_eq!(scaling, 0.0) { - let s = Similarity3::from_scaling(scaling); - - // (rotation × translation × scaling) × point = rotation × (translation × (scaling × point)) - prop_assert!(relative_eq!((uq * t * s) * v, uq * (scaling * v), epsilon = 1.0e-7)); - prop_assert!(relative_eq!((uq * t * s) * p, uq * (t * (scaling * p)), epsilon = 1.0e-7)); - - // (translation × rotation × scaling) × point = translation × (rotation × (scaling × point)) - prop_assert!(relative_eq!((t * uq * s) * v, uq * (scaling * v), epsilon = 1.0e-7)); - prop_assert!(relative_eq!((t * uq * s) * p, t * (uq * (scaling * p)), epsilon = 1.0e-7)); - - // (rotation × isometry × scaling) × point = rotation × (isometry × (scaling × point)) - prop_assert!(relative_eq!((uq * i * s) * v, uq * (i * (scaling * v)), epsilon = 1.0e-7)); - prop_assert!(relative_eq!((uq * i * s) * p, uq * (i * (scaling * p)), epsilon = 1.0e-7)); - - // (isometry × rotation × scaling) × point = isometry × (rotation × (scaling × point)) - prop_assert!(relative_eq!((i * uq * s) * v, i * (uq * (scaling * v)), epsilon = 1.0e-7)); - prop_assert!(relative_eq!((i * uq * s) * p, i * (uq * (scaling * p)), epsilon = 1.0e-7)); - - // (translation × isometry × scaling) × point = translation × (isometry × (scaling × point)) - prop_assert!(relative_eq!((t * i * s) * v, (i * (scaling * v)), epsilon = 1.0e-7)); - prop_assert!(relative_eq!((t * i * s) * p, t * (i * (scaling * p)), epsilon = 1.0e-7)); - - // (isometry × translation × scaling) × point = isometry × (translation × (scaling × point)) - prop_assert!(relative_eq!((i * t * s) * v, i * (scaling * v), epsilon = 1.0e-7)); - prop_assert!(relative_eq!((i * t * s) * p, i * (t * (scaling * p)), epsilon = 1.0e-7)); - - - /* - * Same as before but with scaling on the middle. - */ - // (rotation × scaling × translation) × point = rotation × (scaling × (translation × point)) - prop_assert!(relative_eq!((uq * s * t) * v, uq * (scaling * v), epsilon = 1.0e-7)); - prop_assert!(relative_eq!((uq * s * t) * p, uq * (scaling * (t * p)), epsilon = 1.0e-7)); - - // (translation × scaling × rotation) × point = translation × (scaling × (rotation × point)) - prop_assert!(relative_eq!((t * s * uq) * v, scaling * (uq * v), epsilon = 1.0e-7)); - prop_assert!(relative_eq!((t * s * uq) * p, t * (scaling * (uq * p)), epsilon = 1.0e-7)); - - // (rotation × scaling × isometry) × point = rotation × (scaling × (isometry × point)) - prop_assert!(relative_eq!((uq * s * i) * v, uq * (scaling * (i * v)), epsilon = 1.0e-7)); - prop_assert!(relative_eq!((uq * s * i) * p, uq * (scaling * (i * p)), epsilon = 1.0e-7)); - - // (isometry × scaling × rotation) × point = isometry × (scaling × (rotation × point)) - prop_assert!(relative_eq!((i * s * uq) * v, i * (scaling * (uq * v)), epsilon = 1.0e-7)); - prop_assert!(relative_eq!((i * s * uq) * p, i * (scaling * (uq * p)), epsilon = 1.0e-7)); - - // (translation × scaling × isometry) × point = translation × (scaling × (isometry × point)) - prop_assert!(relative_eq!((t * s * i) * v, (scaling * (i * v)), epsilon = 1.0e-7)); - prop_assert!(relative_eq!((t * s * i) * p, t * (scaling * (i * p)), epsilon = 1.0e-7)); - - // (isometry × scaling × translation) × point = isometry × (scaling × (translation × point)) - prop_assert!(relative_eq!((i * s * t) * v, i * (scaling * v), epsilon = 1.0e-7)); - prop_assert!(relative_eq!((i * s * t) * p, i * (scaling * (t * p)), epsilon = 1.0e-7)); - - - /* - * Same as before but with scaling on the left. - */ - // (scaling × rotation × translation) × point = scaling × (rotation × (translation × point)) - prop_assert!(relative_eq!((s * uq * t) * v, scaling * (uq * v), epsilon = 1.0e-7)); - prop_assert!(relative_eq!((s * uq * t) * p, scaling * (uq * (t * p)), epsilon = 1.0e-7)); - - // (scaling × translation × rotation) × point = scaling × (translation × (rotation × point)) - prop_assert!(relative_eq!((s * t * uq) * v, scaling * (uq * v), epsilon = 1.0e-7)); - prop_assert!(relative_eq!((s * t * uq) * p, scaling * (t * (uq * p)), epsilon = 1.0e-7)); - - // (scaling × rotation × isometry) × point = scaling × (rotation × (isometry × point)) - prop_assert!(relative_eq!((s * uq * i) * v, scaling * (uq * (i * v)), epsilon = 1.0e-7)); - prop_assert!(relative_eq!((s * uq * i) * p, scaling * (uq * (i * p)), epsilon = 1.0e-7)); - - // (scaling × isometry × rotation) × point = scaling × (isometry × (rotation × point)) - prop_assert!(relative_eq!((s * i * uq) * v, scaling * (i * (uq * v)), epsilon = 1.0e-7)); - prop_assert!(relative_eq!((s * i * uq) * p, scaling * (i * (uq * p)), epsilon = 1.0e-7)); - - // (scaling × translation × isometry) × point = scaling × (translation × (isometry × point)) - prop_assert!(relative_eq!((s * t * i) * v, (scaling * (i * v)), epsilon = 1.0e-7)); - prop_assert!(relative_eq!((s * t * i) * p, scaling * (t * (i * p)), epsilon = 1.0e-7)); - - // (scaling × isometry × translation) × point = scaling × (isometry × (translation × point)) - prop_assert!(relative_eq!((s * i * t) * v, scaling * (i * v), epsilon = 1.0e-7)); - prop_assert!(relative_eq!((s * i * t) * p, scaling * (i * (t * p)), epsilon = 1.0e-7)); - } - } - - #[test] - #[cfg_attr(rustfmt, rustfmt_skip)] - fn all_op_exist( - s in similarity3(), - i in isometry3(), - uq in unit_quaternion(), - t in translation3(), - v in vector3(), - p in point3() - ) { - let sMs = s * s; - let sMuq = s * uq; - let sDs = s / s; - let sDuq = s / uq; - - let sMp = s * p; - let sMv = s * v; - - let sMt = s * t; - let tMs = t * s; - - let uqMs = uq * s; - let uqDs = uq / s; - - let sMi = s * i; - let sDi = s / i; - - let iMs = i * s; - let iDs = i / s; - - let mut sMt1 = s; - let mut sMt2 = s; - - let mut sMs1 = s; - let mut sMs2 = s; - - let mut sMuq1 = s; - let mut sMuq2 = s; - - let mut sMi1 = s; - let mut sMi2 = s; - - let mut sDs1 = s; - let mut sDs2 = s; - - let mut sDuq1 = s; - let mut sDuq2 = s; - - let mut sDi1 = s; - let mut sDi2 = s; - - sMt1 *= t; - sMt2 *= &t; - - sMs1 *= s; - sMs2 *= &s; - - sMuq1 *= uq; - sMuq2 *= &uq; - - sMi1 *= i; - sMi2 *= &i; - - sDs1 /= s; - sDs2 /= &s; - - sDuq1 /= uq; - sDuq2 /= &uq; - - sDi1 /= i; - sDi2 /= &i; - - prop_assert!(sMt == sMt1 - && sMt == sMt2 - && sMs == sMs1 - && sMs == sMs2 - && sMuq == sMuq1 - && sMuq == sMuq2 - && sMi == sMi1 - && sMi == sMi2 - && sDs == sDs1 - && sDs == sDs2 - && sDuq == sDuq1 - && sDuq == sDuq2 - && sDi == sDi1 - && sDi == sDi2 - && sMs == &s * &s - && sMs == s * &s - && sMs == &s * s - && sMuq == &s * &uq - && sMuq == s * &uq - && sMuq == &s * uq - && sDs == &s / &s - && sDs == s / &s - && sDs == &s / s - && sDuq == &s / &uq - && sDuq == s / &uq - && sDuq == &s / uq - && sMp == &s * &p - && sMp == s * &p - && sMp == &s * p - && sMv == &s * &v - && sMv == s * &v - && sMv == &s * v - && sMt == &s * &t - && sMt == s * &t - && sMt == &s * t - && tMs == &t * &s - && tMs == t * &s - && tMs == &t * s - && uqMs == &uq * &s - && uqMs == uq * &s - && uqMs == &uq * s - && uqDs == &uq / &s - && uqDs == uq / &s - && uqDs == &uq / s - && sMi == &s * &i - && sMi == s * &i - && sMi == &s * i - && sDi == &s / &i - && sDi == s / &i - && sDi == &s / i - && iMs == &i * &s - && iMs == i * &s - && iMs == &i * s - && iDs == &i / &s - && iDs == i / &s - && iDs == &i / s) - } -); diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/geometry/unit_complex.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/geometry/unit_complex.rs deleted file mode 100644 index 85dd1419c..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/geometry/unit_complex.rs +++ /dev/null @@ -1,161 +0,0 @@ -#![cfg(feature = "proptest-support")] -#![allow(non_snake_case)] - -use na::{Unit, UnitComplex}; - -use crate::proptest::*; -use proptest::{prop_assert, proptest}; - -proptest!( - /* - * - * From/to rotation matrix. - * - */ - #[test] - fn unit_complex_rotation_conversion(c in unit_complex()) { - let r = c.to_rotation_matrix(); - let cc = UnitComplex::from_rotation_matrix(&r); - let rr = cc.to_rotation_matrix(); - - prop_assert!(relative_eq!(c, cc, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(r, rr, epsilon = 1.0e-7)); - } - - /* - * - * Point/Vector transformation. - * - */ - #[test] - fn unit_complex_transformation(c in unit_complex(), v in vector2(), p in point2()) { - let r = c.to_rotation_matrix(); - let rv = r * v; - let rp = r * p; - - prop_assert!(relative_eq!(c * v, rv, epsilon = 1.0e-7) - && relative_eq!(c * &v, rv, epsilon = 1.0e-7) - && relative_eq!(&c * v, rv, epsilon = 1.0e-7) - && relative_eq!(&c * &v, rv, epsilon = 1.0e-7) - && relative_eq!(c * p, rp, epsilon = 1.0e-7) - && relative_eq!(c * &p, rp, epsilon = 1.0e-7) - && relative_eq!(&c * p, rp, epsilon = 1.0e-7) - && relative_eq!(&c * &p, rp, epsilon = 1.0e-7)) - } - - /* - * - * Inversion. - * - */ - #[test] - fn unit_complex_inv(c in unit_complex()) { - let iq = c.inverse(); - prop_assert!(relative_eq!(&iq * &c, UnitComplex::identity(), epsilon = 1.0e-7) - && relative_eq!(iq * &c, UnitComplex::identity(), epsilon = 1.0e-7) - && relative_eq!(&iq * c, UnitComplex::identity(), epsilon = 1.0e-7) - && relative_eq!(iq * c, UnitComplex::identity(), epsilon = 1.0e-7) - && relative_eq!(&c * &iq, UnitComplex::identity(), epsilon = 1.0e-7) - && relative_eq!(c * &iq, UnitComplex::identity(), epsilon = 1.0e-7) - && relative_eq!(&c * iq, UnitComplex::identity(), epsilon = 1.0e-7) - && relative_eq!(c * iq, UnitComplex::identity(), epsilon = 1.0e-7)) - } - - /* - * - * Quaternion * Vector == Rotation * Vector - * - */ - #[test] - fn unit_complex_mul_vector(c in unit_complex(), v in vector2(), p in point2()) { - let r = c.to_rotation_matrix(); - - prop_assert!(relative_eq!(c * v, r * v, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(c * p, r * p, epsilon = 1.0e-7)); - } - - // Test that all operators (incl. all combinations of references) work. - // See the top comment on `geometry/quaternion_ops.rs` for details on which operations are - // supported. - #[test] - #[cfg_attr(rustfmt, rustfmt_skip)] - fn all_op_exist( - uc in unit_complex(), - v in vector2(), - p in point2(), - r in rotation2() - ) { - let uv = Unit::new_normalize(v); - - let ucMuc = uc * uc; - let ucMr = uc * r; - let rMuc = r * uc; - let ucDuc = uc / uc; - let ucDr = uc / r; - let rDuc = r / uc; - - let ucMp = uc * p; - let ucMv = uc * v; - let ucMuv = uc * uv; - - let mut ucMuc1 = uc; - let mut ucMuc2 = uc; - - let mut ucMr1 = uc; - let mut ucMr2 = uc; - - let mut ucDuc1 = uc; - let mut ucDuc2 = uc; - - let mut ucDr1 = uc; - let mut ucDr2 = uc; - - ucMuc1 *= uc; - ucMuc2 *= &uc; - - ucMr1 *= r; - ucMr2 *= &r; - - ucDuc1 /= uc; - ucDuc2 /= &uc; - - ucDr1 /= r; - ucDr2 /= &r; - - prop_assert!(ucMuc1 == ucMuc - && ucMuc1 == ucMuc2 - && ucMr1 == ucMr - && ucMr1 == ucMr2 - && ucDuc1 == ucDuc - && ucDuc1 == ucDuc2 - && ucDr1 == ucDr - && ucDr1 == ucDr2 - && ucMuc == &uc * &uc - && ucMuc == uc * &uc - && ucMuc == &uc * uc - && ucMr == &uc * &r - && ucMr == uc * &r - && ucMr == &uc * r - && rMuc == &r * &uc - && rMuc == r * &uc - && rMuc == &r * uc - && ucDuc == &uc / &uc - && ucDuc == uc / &uc - && ucDuc == &uc / uc - && ucDr == &uc / &r - && ucDr == uc / &r - && ucDr == &uc / r - && rDuc == &r / &uc - && rDuc == r / &uc - && rDuc == &r / uc - && ucMp == &uc * &p - && ucMp == uc * &p - && ucMp == &uc * p - && ucMv == &uc * &v - && ucMv == uc * &v - && ucMv == &uc * v - && ucMuv == &uc * &uv - && ucMuv == uc * &uv - && ucMuv == &uc * uv) - } -); diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/lib.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/lib.rs deleted file mode 100644 index 3461907a2..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/lib.rs +++ /dev/null @@ -1,43 +0,0 @@ -#[cfg(not(all( - feature = "debug", - feature = "compare", - feature = "rand", - feature = "macros" -)))] -compile_error!( - "Please enable the `debug`, `compare`, `rand` and `macros` features in order to compile and run the tests. - Example: `cargo test --features debug,compare,rand,macros`" -); - -#[cfg(all(feature = "debug", feature = "compare", feature = "rand"))] -#[macro_use] -extern crate approx; -extern crate nalgebra as na; -extern crate num_traits as num; -#[cfg(feature = "rand")] -extern crate rand_package as rand; - -#[cfg(all(feature = "debug", feature = "compare", feature = "rand"))] -mod core; -#[cfg(all(feature = "debug", feature = "compare", feature = "rand"))] -mod geometry; -#[cfg(all(feature = "debug", feature = "compare", feature = "rand"))] -mod linalg; - -#[cfg(all(feature = "debug", feature = "compare", feature = "rand"))] -#[cfg(feature = "proptest-support")] -mod proptest; - -#[cfg(feature = "macros")] -mod macros; - -//#[cfg(all(feature = "debug", feature = "compare", feature = "rand"))] -//#[cfg(feature = "sparse")] -//mod sparse; - -mod utils { - /// Checks if a slice is sorted in descending order. - pub fn is_sorted_descending(slice: &[T]) -> bool { - slice.windows(2).all(|elts| elts[0] >= elts[1]) - } -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/balancing.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/balancing.rs deleted file mode 100644 index 5e3b781e7..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/balancing.rs +++ /dev/null @@ -1,28 +0,0 @@ -#![cfg(feature = "proptest-support")] - -use na::balancing; -use na::DMatrix; - -use crate::proptest::*; -use proptest::{prop_assert_eq, proptest}; - -proptest! { - #[test] - fn balancing_parlett_reinsch(n in PROPTEST_MATRIX_DIM) { - let m = DMatrix::::new_random(n, n); - let mut balanced = m.clone(); - let d = balancing::balance_parlett_reinsch(&mut balanced); - balancing::unbalance(&mut balanced, &d); - - prop_assert_eq!(balanced, m); - } - - #[test] - fn balancing_parlett_reinsch_static(m in matrix4()) { - let mut balanced = m; - let d = balancing::balance_parlett_reinsch(&mut balanced); - balancing::unbalance(&mut balanced, &d); - - prop_assert_eq!(balanced, m); - } -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/bidiagonal.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/bidiagonal.rs deleted file mode 100644 index 254abee89..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/bidiagonal.rs +++ /dev/null @@ -1,105 +0,0 @@ -#[cfg(feature = "proptest-support")] -mod proptest_tests { - macro_rules! gen_tests( - ($module: ident, $scalar: expr) => { - mod $module { - #[allow(unused_imports)] - use crate::core::helper::{RandScalar, RandComplex}; - - use crate::proptest::*; - use proptest::{prop_assert, proptest}; - - proptest! { - #[test] - fn bidiagonal(m in dmatrix_($scalar)) { - let bidiagonal = m.clone().bidiagonalize(); - let (u, d, v_t) = bidiagonal.unpack(); - - prop_assert!(relative_eq!(m, &u * d * &v_t, epsilon = 1.0e-7)) - } - - #[test] - fn bidiagonal_static_5_3(m in matrix5x3_($scalar)) { - let bidiagonal = m.bidiagonalize(); - let (u, d, v_t) = bidiagonal.unpack(); - - prop_assert!(relative_eq!(m, &u * d * &v_t, epsilon = 1.0e-7)) - } - - #[test] - fn bidiagonal_static_3_5(m in matrix3x5_($scalar)) { - let bidiagonal = m.bidiagonalize(); - let (u, d, v_t) = bidiagonal.unpack(); - - prop_assert!(relative_eq!(m, &u * d * &v_t, epsilon = 1.0e-7)) - } - - #[test] - fn bidiagonal_static_square(m in matrix4_($scalar)) { - let bidiagonal = m.bidiagonalize(); - let (u, d, v_t) = bidiagonal.unpack(); - - prop_assert!(relative_eq!(m, &u * d * &v_t, epsilon = 1.0e-7)) - } - - #[test] - fn bidiagonal_static_square_2x2(m in matrix2_($scalar)) { - let bidiagonal = m.bidiagonalize(); - let (u, d, v_t) = bidiagonal.unpack(); - - prop_assert!(relative_eq!(m, &u * d * &v_t, epsilon = 1.0e-7)) - } - } - } - } -); - - gen_tests!(complex, complex_f64()); - gen_tests!(f64, PROPTEST_F64); -} - -#[test] -fn bidiagonal_identity() { - let m = na::DMatrix::::identity(10, 10); - let bidiagonal = m.clone().bidiagonalize(); - let (u, d, v_t) = bidiagonal.unpack(); - assert_eq!(m, &u * d * &v_t); - - let m = na::DMatrix::::identity(10, 15); - let bidiagonal = m.clone().bidiagonalize(); - let (u, d, v_t) = bidiagonal.unpack(); - assert_eq!(m, &u * d * &v_t); - - let m = na::DMatrix::::identity(15, 10); - let bidiagonal = m.clone().bidiagonalize(); - let (u, d, v_t) = bidiagonal.unpack(); - assert_eq!(m, &u * d * &v_t); -} - -#[test] -fn bidiagonal_regression_issue_1313() { - let s = 6.123234e-16_f32; - let mut m = nalgebra::dmatrix![ - 10.0, 0.0, 0.0, 0.0, -10.0, 0.0, 0.0, 0.0; - s, 10.0, 0.0, 10.0, s, 0.0, 0.0, 0.0; - 20.0, -20.0, 0.0, 20.0, 20.0, 0.0, 0.0, 0.0; - ]; - m.unscale_mut(m.camax()); - let bidiagonal = m.clone().bidiagonalize(); - let (u, d, v_t) = bidiagonal.unpack(); - let m2 = &u * d * &v_t; - assert_relative_eq!(m, m2, epsilon = 1e-6); -} - -#[test] -fn bidiagonal_regression_issue_1313_minimal() { - let s = 6.123234e-17_f32; - let m = nalgebra::dmatrix![ - 1.0, 0.0, -1.0; - s, 1.0, s; - ]; - let bidiagonal = m.clone().bidiagonalize(); - let (u, d, v_t) = bidiagonal.unpack(); - let m2 = &u * &d * &v_t; - assert_relative_eq!(m, m2, epsilon = 1e-6); -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/cholesky.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/cholesky.rs deleted file mode 100644 index 746b0d52b..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/cholesky.rs +++ /dev/null @@ -1,174 +0,0 @@ -#![cfg(all(feature = "proptest-support", feature = "debug"))] - -#[test] -// #[rustfmt::skip] -fn cholesky_with_substitute() { - // Make a tiny covariance matrix with a small covariance value. - let m = na::Matrix2::new(1.0, f64::NAN, 1.0, 1e-32); - // Show that the cholesky fails for our matrix. We then try again with a substitute. - assert!(na::Cholesky::new(m).is_none()); - // ...and show that we get some result this time around. - assert!(na::Cholesky::new_with_substitute(m, 1e-8).is_some()); -} - -macro_rules! gen_tests( - ($module: ident, $scalar: ty) => { - mod $module { - use na::debug::RandomSDP; - use na::dimension::{Const, Dyn}; - use na::{DMatrix, DVector, Matrix4x3, Vector4}; - use rand::random; - use simba::scalar::ComplexField; - #[allow(unused_imports)] - use crate::core::helper::{RandScalar, RandComplex}; - - use crate::proptest::*; - use proptest::{prop_assert, proptest}; - - proptest! { - #[test] - fn cholesky(n in PROPTEST_MATRIX_DIM) { - let m = RandomSDP::new(Dyn(n), || random::<$scalar>().0).unwrap(); - let l = m.clone().cholesky().unwrap().unpack(); - prop_assert!(relative_eq!(m, &l * l.adjoint(), epsilon = 1.0e-7)); - } - - #[test] - fn cholesky_static(_n in PROPTEST_MATRIX_DIM) { - let m = RandomSDP::new(Const::<4>, || random::<$scalar>().0).unwrap(); - let chol = m.cholesky().unwrap(); - let l = chol.unpack(); - - prop_assert!(relative_eq!(m, &l * l.adjoint(), epsilon = 1.0e-7)); - } - - #[test] - fn cholesky_solve(n in PROPTEST_MATRIX_DIM, nb in PROPTEST_MATRIX_DIM) { - let m = RandomSDP::new(Dyn(n), || random::<$scalar>().0).unwrap(); - - let chol = m.clone().cholesky().unwrap(); - let b1 = DVector::<$scalar>::new_random(n).map(|e| e.0); - let b2 = DMatrix::<$scalar>::new_random(n, nb).map(|e| e.0); - - let sol1 = chol.solve(&b1); - let sol2 = chol.solve(&b2); - - prop_assert!(relative_eq!(&m * &sol1, b1, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(&m * &sol2, b2, epsilon = 1.0e-7)); - } - - #[test] - fn cholesky_solve_static(_n in PROPTEST_MATRIX_DIM) { - let m = RandomSDP::new(Const::<4>, || random::<$scalar>().0).unwrap(); - let chol = m.clone().cholesky().unwrap(); - let b1 = Vector4::<$scalar>::new_random().map(|e| e.0); - let b2 = Matrix4x3::<$scalar>::new_random().map(|e| e.0); - - let sol1 = chol.solve(&b1); - let sol2 = chol.solve(&b2); - - prop_assert!(relative_eq!(m * sol1, b1, epsilon = 1.0e-7)); - prop_assert!(relative_eq!(m * sol2, b2, epsilon = 1.0e-7)); - } - - #[test] - fn cholesky_inverse(n in PROPTEST_MATRIX_DIM) { - let m = RandomSDP::new(Dyn(n), || random::<$scalar>().0).unwrap(); - let m1 = m.clone().cholesky().unwrap().inverse(); - let id1 = &m * &m1; - let id2 = &m1 * &m; - - prop_assert!(id1.is_identity(1.0e-7) && id2.is_identity(1.0e-7)); - } - - #[test] - fn cholesky_inverse_static(_n in PROPTEST_MATRIX_DIM) { - let m = RandomSDP::new(Const::<4>, || random::<$scalar>().0).unwrap(); - let m1 = m.clone().cholesky().unwrap().inverse(); - let id1 = &m * &m1; - let id2 = &m1 * &m; - - prop_assert!(id1.is_identity(1.0e-7) && id2.is_identity(1.0e-7)); - } - - #[test] - fn cholesky_determinant(n in PROPTEST_MATRIX_DIM) { - let m = RandomSDP::new(Dyn(n), || random::<$scalar>().0).unwrap(); - let lu_det = m.clone().lu().determinant(); - assert_relative_eq!(lu_det.imaginary(), 0., epsilon = 1.0e-7); - let chol_det = m.cholesky().unwrap().determinant(); - - prop_assert!(relative_eq!(lu_det.real(), chol_det, epsilon = 1.0e-7)); - } - - #[test] - fn cholesky_determinant_static(_n in PROPTEST_MATRIX_DIM) { - let m = RandomSDP::new(Const::<4>, || random::<$scalar>().0).unwrap(); - let lu_det = m.clone().lu().determinant(); - assert_relative_eq!(lu_det.imaginary(), 0., epsilon = 1.0e-7); - let chol_det = m.cholesky().unwrap().determinant(); - - prop_assert!(relative_eq!(lu_det.real(), chol_det, epsilon = 1.0e-7)); - } - - #[test] - fn cholesky_rank_one_update(_n in PROPTEST_MATRIX_DIM) { - let mut m = RandomSDP::new(Const::<4>, || random::<$scalar>().0).unwrap(); - let x = Vector4::<$scalar>::new_random().map(|e| e.0); - - // this is dirty but $scalar is not a scalar type (its a Rand) in this file - let zero = random::<$scalar>().0 * 0.; - let one = zero + 1.; - let sigma = random::(); // needs to be a real - let sigma_scalar = zero + sigma; - - // updates cholesky decomposition and reconstructs m updated - let mut chol = m.clone().cholesky().unwrap(); - chol.rank_one_update(&x, sigma); - let m_chol_updated = chol.l() * chol.l().adjoint(); - - // updates m manually - m.gerc(sigma_scalar, &x, &x, one); // m += sigma * x * x.adjoint() - - prop_assert!(relative_eq!(m, m_chol_updated, epsilon = 1.0e-7)); - } - - #[test] - fn cholesky_insert_column(n in PROPTEST_MATRIX_DIM) { - let n = n.max(1).min(10); - let j = random::() % n; - let m_updated = RandomSDP::new(Dyn(n), || random::<$scalar>().0).unwrap(); - - // build m and col from m_updated - let col = m_updated.column(j); - let m = m_updated.clone().remove_column(j).remove_row(j); - - // remove column from cholesky decomposition and rebuild m - let chol = m.clone().cholesky().unwrap().insert_column(j, col); - let m_chol_updated = chol.l() * chol.l().adjoint(); - - prop_assert!(relative_eq!(m_updated, m_chol_updated, epsilon = 1.0e-7)); - } - - #[test] - fn cholesky_remove_column(n in PROPTEST_MATRIX_DIM) { - let n = n.max(1).min(10); - let j = random::() % n; - let m = RandomSDP::new(Dyn(n), || random::<$scalar>().0).unwrap(); - - // remove column from cholesky decomposition and rebuild m - let chol = m.clone().cholesky().unwrap().remove_column(j); - let m_chol_updated = chol.l() * chol.l().adjoint(); - - // remove column from m - let m_updated = m.remove_column(j).remove_row(j); - - prop_assert!(relative_eq!(m_updated, m_chol_updated, epsilon = 1.0e-7)); - } - } - } - } -); - -gen_tests!(complex, RandComplex); -gen_tests!(f64, RandScalar); diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/col_piv_qr.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/col_piv_qr.rs deleted file mode 100644 index 95de0c428..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/col_piv_qr.rs +++ /dev/null @@ -1,152 +0,0 @@ -#[cfg_attr(rustfmt, rustfmt_skip)] - -use na::Matrix4; - -#[test] -fn col_piv_qr() { - let m = Matrix4::new( - 1.0, -1.0, 2.0, 1.0, -1.0, 3.0, -1.0, -1.0, 3.0, -5.0, 5.0, 3.0, 1.0, 2.0, 1.0, -2.0, - ); - let col_piv_qr = m.col_piv_qr(); - assert!(relative_eq!( - col_piv_qr.determinant(), - 0.0, - epsilon = 1.0e-7 - )); - - let (q, r, p) = col_piv_qr.unpack(); - - let mut qr = q * r; - p.inv_permute_columns(&mut qr); - - assert!(relative_eq!(m, qr, epsilon = 1.0e-7)); -} - -#[cfg(feature = "proptest-support")] -mod proptest_tests { - macro_rules! gen_tests( - ($module: ident, $scalar: expr ,$scalar_type: ty) => { - mod $module { - use na::{DMatrix, DVector, Matrix4x3, Vector4}; - use std::cmp; - - #[allow(unused_imports)] - use crate::core::helper::{RandComplex, RandScalar}; - use crate::proptest::*; - use proptest::{prop_assert, proptest}; - - proptest! { - #[test] - fn col_piv_qr(m in dmatrix_($scalar)) { - let col_piv_qr = m.clone().col_piv_qr(); - let (q, r, p) = col_piv_qr.unpack(); - let mut qr = &q * &r; - p.inv_permute_columns(&mut qr); - - prop_assert!(relative_eq!(m, &qr, epsilon = 1.0e-7)); - prop_assert!(q.is_orthogonal(1.0e-7)); - } - - #[test] - fn col_piv_qr_static_5_3(m in matrix5x3_($scalar)) { - let col_piv_qr = m.col_piv_qr(); - let (q, r, p) = col_piv_qr.unpack(); - let mut qr = q * r; - p.inv_permute_columns(&mut qr); - - prop_assert!(relative_eq!(m, qr, epsilon = 1.0e-7)); - prop_assert!(q.is_orthogonal(1.0e-7)); - } - - #[test] - fn col_piv_qr_static_3_5(m in matrix3x5_($scalar)) { - let col_piv_qr = m.col_piv_qr(); - let (q, r, p) = col_piv_qr.unpack(); - let mut qr = q * r; - p.inv_permute_columns(&mut qr); - - prop_assert!(relative_eq!(m, qr, epsilon = 1.0e-7)); - prop_assert!(q.is_orthogonal(1.0e-7)); - } - - #[test] - fn col_piv_qr_static_square(m in matrix4_($scalar)) { - let col_piv_qr = m.col_piv_qr(); - let (q, r, p) = col_piv_qr.unpack(); - let mut qr = q * r; - p.inv_permute_columns(&mut qr); - - prop_assert!(relative_eq!(m, qr, epsilon = 1.0e-7)); - prop_assert!(q.is_orthogonal(1.0e-7)); - } - - #[test] - fn col_piv_qr_solve(n in PROPTEST_MATRIX_DIM, nb in PROPTEST_MATRIX_DIM) { - if n != 0 && nb != 0 { - let n = cmp::min(n, 50); // To avoid slowing down the test too much. - let nb = cmp::min(nb, 50); // To avoid slowing down the test too much. - let m = DMatrix::<$scalar_type>::new_random(n, n).map(|e| e.0); - - let col_piv_qr = m.clone().col_piv_qr(); - let b1 = DVector::<$scalar_type>::new_random(n).map(|e| e.0); - let b2 = DMatrix::<$scalar_type>::new_random(n, nb).map(|e| e.0); - - if col_piv_qr.is_invertible() { - let sol1 = col_piv_qr.solve(&b1).unwrap(); - let sol2 = col_piv_qr.solve(&b2).unwrap(); - - prop_assert!(relative_eq!(&m * sol1, b1, epsilon = 1.0e-6)); - prop_assert!(relative_eq!(&m * sol2, b2, epsilon = 1.0e-6)); - } - } - } - - #[test] - fn col_piv_qr_solve_static(m in matrix4_($scalar)) { - let col_piv_qr = m.col_piv_qr(); - let b1 = Vector4::<$scalar_type>::new_random().map(|e| e.0); - let b2 = Matrix4x3::<$scalar_type>::new_random().map(|e| e.0); - - if col_piv_qr.is_invertible() { - let sol1 = col_piv_qr.solve(&b1).unwrap(); - let sol2 = col_piv_qr.solve(&b2).unwrap(); - - prop_assert!(relative_eq!(m * sol1, b1, epsilon = 1.0e-6)); - prop_assert!(relative_eq!(m * sol2, b2, epsilon = 1.0e-6)); - } - } - - #[test] - fn col_piv_qr_inverse(n in PROPTEST_MATRIX_DIM) { - let n = cmp::max(1, cmp::min(n, 15)); // To avoid slowing down the test too much. - let m = DMatrix::<$scalar_type>::new_random(n, n).map(|e| e.0); - - if let Some(m1) = m.clone().col_piv_qr().try_inverse() { - let id1 = &m * &m1; - let id2 = &m1 * &m; - - prop_assert!(id1.is_identity(1.0e-5)); - prop_assert!(id2.is_identity(1.0e-5)); - } - } - - #[test] - fn col_piv_qr_inverse_static(m in matrix4_($scalar)) { - let col_piv_qr = m.col_piv_qr(); - - if let Some(m1) = col_piv_qr.try_inverse() { - let id1 = &m * &m1; - let id2 = &m1 * &m; - - prop_assert!(id1.is_identity(1.0e-5)); - prop_assert!(id2.is_identity(1.0e-5)); - } - } - } - } - } - ); - - gen_tests!(complex, complex_f64(), RandComplex); - gen_tests!(f64, PROPTEST_F64, RandScalar); -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/convolution.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/convolution.rs deleted file mode 100644 index a92a89bb6..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/convolution.rs +++ /dev/null @@ -1,119 +0,0 @@ -use na::{DVector, Vector2, Vector3, Vector4, Vector5}; -use std::panic; - -// -// Should mimic calculations in Python's scipy library -// >>>from scipy.signal import convolve -// - -// >>> convolve([1,2,3,4],[1,2],"same") -// array([ 1, 4, 7, 10]) -#[test] -fn convolve_same_check() { - // Static Tests - let actual_s = Vector4::new(1.0, 4.0, 7.0, 10.0); - let expected_s = Vector4::new(1.0, 2.0, 3.0, 4.0).convolve_same(Vector2::new(1.0, 2.0)); - - assert!(relative_eq!(actual_s, expected_s, epsilon = 1.0e-7)); - - // Dyn Tests - let actual_d = DVector::from_vec(vec![1.0, 4.0, 7.0, 10.0]); - let expected_d = DVector::from_vec(vec![1.0, 2.0, 3.0, 4.0]) - .convolve_same(DVector::from_vec(vec![1.0, 2.0])); - - assert!(relative_eq!(actual_d, expected_d, epsilon = 1.0e-7)); - - // Panic Tests - // These really only apply to dynamic sized vectors - assert!(panic::catch_unwind(|| { - let _ = DVector::from_vec(vec![1.0, 2.0]) - .convolve_same(DVector::from_vec(vec![1.0, 2.0, 3.0, 4.0])); - }) - .is_err()); - - assert!(panic::catch_unwind(|| { - let _ = DVector::::from_vec(vec![]) - .convolve_same(DVector::from_vec(vec![1.0, 2.0, 3.0, 4.0])); - }) - .is_err()); - - assert!(panic::catch_unwind(|| { - let _ = DVector::from_vec(vec![1.0, 2.0, 3.0, 4.0]) - .convolve_same(DVector::::from_vec(vec![])); - }) - .is_err()); -} - -// >>> convolve([1,2,3,4],[1,2],"full") -// array([ 1, 4, 7, 10, 8]) -#[test] -fn convolve_full_check() { - // Static Tests - let actual_s = Vector5::new(1.0, 4.0, 7.0, 10.0, 8.0); - let expected_s = Vector4::new(1.0, 2.0, 3.0, 4.0).convolve_full(Vector2::new(1.0, 2.0)); - - assert!(relative_eq!(actual_s, expected_s, epsilon = 1.0e-7)); - - // Dyn Tests - let actual_d = DVector::from_vec(vec![1.0, 4.0, 7.0, 10.0, 8.0]); - let expected_d = DVector::from_vec(vec![1.0, 2.0, 3.0, 4.0]) - .convolve_full(DVector::from_vec(vec![1.0, 2.0])); - - assert!(relative_eq!(actual_d, expected_d, epsilon = 1.0e-7)); - - // Panic Tests - // These really only apply to dynamic sized vectors - assert!(panic::catch_unwind(|| { - DVector::from_vec(vec![1.0, 2.0]) - .convolve_full(DVector::from_vec(vec![1.0, 2.0, 3.0, 4.0])); - }) - .is_err()); - - assert!(panic::catch_unwind(|| { - DVector::::from_vec(vec![]).convolve_full(DVector::from_vec(vec![1.0, 2.0, 3.0, 4.0])); - }) - .is_err()); - - assert!(panic::catch_unwind(|| { - DVector::from_vec(vec![1.0, 2.0, 3.0, 4.0]).convolve_full(DVector::::from_vec(vec![])); - }) - .is_err()); -} - -// >>> convolve([1, 2, 3, 4],[1, 2],"valid") -// array([4, 7, 10]) -#[test] -fn convolve_valid_check() { - // Static Tests - let actual_s = Vector3::from_vec(vec![4.0, 7.0, 10.0]); - let expected_s = Vector4::new(1.0, 2.0, 3.0, 4.0).convolve_valid(Vector2::new(1.0, 2.0)); - - assert!(relative_eq!(actual_s, expected_s, epsilon = 1.0e-7)); - - // Dyn Tests - let actual_d = DVector::from_vec(vec![4.0, 7.0, 10.0]); - let expected_d = DVector::from_vec(vec![1.0, 2.0, 3.0, 4.0]) - .convolve_valid(DVector::from_vec(vec![1.0, 2.0])); - - assert!(relative_eq!(actual_d, expected_d, epsilon = 1.0e-7)); - - // Panic Tests - // These really only apply to dynamic sized vectors - assert!(panic::catch_unwind(|| { - DVector::from_vec(vec![1.0, 2.0]) - .convolve_valid(DVector::from_vec(vec![1.0, 2.0, 3.0, 4.0])); - }) - .is_err()); - - assert!(panic::catch_unwind(|| { - DVector::::from_vec(vec![]) - .convolve_valid(DVector::from_vec(vec![1.0, 2.0, 3.0, 4.0])); - }) - .is_err()); - - assert!(panic::catch_unwind(|| { - DVector::from_vec(vec![1.0, 2.0, 3.0, 4.0]) - .convolve_valid(DVector::::from_vec(vec![])); - }) - .is_err()); -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/eigen.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/eigen.rs deleted file mode 100644 index a5c0848a0..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/eigen.rs +++ /dev/null @@ -1,228 +0,0 @@ -use na::{DMatrix, Matrix3}; - -#[cfg(feature = "proptest-support")] -mod proptest_tests { - macro_rules! gen_tests( - ($module: ident, $scalar: expr, $scalar_type: ty) => { - mod $module { - use na::DMatrix; - #[allow(unused_imports)] - use crate::core::helper::{RandScalar, RandComplex}; - use std::cmp; - - use crate::proptest::*; - use proptest::{prop_assert, proptest}; - - proptest! { - #[test] - fn symmetric_eigen(n in PROPTEST_MATRIX_DIM) { - let n = cmp::max(1, cmp::min(n, 10)); - let m = DMatrix::<$scalar_type>::new_random(n, n).map(|e| e.0).hermitian_part(); - let eig = m.clone().symmetric_eigen(); - let recomp = eig.recompose(); - - prop_assert!(relative_eq!(m.lower_triangle(), recomp.lower_triangle(), epsilon = 1.0e-5)) - } - - #[test] - fn symmetric_eigen_singular(n in PROPTEST_MATRIX_DIM) { - let n = cmp::max(1, cmp::min(n, 10)); - let mut m = DMatrix::<$scalar_type>::new_random(n, n).map(|e| e.0).hermitian_part(); - m.row_mut(n / 2).fill(na::zero()); - m.column_mut(n / 2).fill(na::zero()); - let eig = m.clone().symmetric_eigen(); - let recomp = eig.recompose(); - - prop_assert!(relative_eq!(m.lower_triangle(), recomp.lower_triangle(), epsilon = 1.0e-5)) - } - - #[test] - fn symmetric_eigen_static_square_4x4(m in matrix4_($scalar)) { - let m = m.hermitian_part(); - let eig = m.symmetric_eigen(); - let recomp = eig.recompose(); - - prop_assert!(relative_eq!(m.lower_triangle(), recomp.lower_triangle(), epsilon = 1.0e-5)) - } - - #[test] - fn symmetric_eigen_static_square_3x3(m in matrix3_($scalar)) { - let m = m.hermitian_part(); - let eig = m.symmetric_eigen(); - let recomp = eig.recompose(); - - prop_assert!(relative_eq!(m.lower_triangle(), recomp.lower_triangle(), epsilon = 1.0e-5)) - } - - #[test] - fn symmetric_eigen_static_square_2x2(m in matrix2_($scalar)) { - let m = m.hermitian_part(); - let eig = m.symmetric_eigen(); - let recomp = eig.recompose(); - - prop_assert!(relative_eq!(m.lower_triangle(), recomp.lower_triangle(), epsilon = 1.0e-5)) - } - } - } - } - ); - - gen_tests!(complex, complex_f64(), RandComplex); - gen_tests!(f64, PROPTEST_F64, RandScalar); -} - -// Test proposed on the issue #176 of rulinalg. -#[test] -#[rustfmt::skip] -fn symmetric_eigen_singular_24x24() { - let m = DMatrix::from_row_slice( - 24, - 24, - &[ - 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - -1.0, -1.0, -1.0, -1.0, -1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, -1.0, -1.0, -1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, -1.0, -1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, 0.0, 1.0, 1.0, 1.0, - 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 4.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 4.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0 - ], - ); - - let eig = m.clone().symmetric_eigen(); - let recomp = eig.recompose(); - - assert_relative_eq!( - m.lower_triangle(), - recomp.lower_triangle(), - epsilon = 1.0e-5 - ); -} - -// Regression test for #1368 -#[test] -fn very_small_deviation_from_identity_issue_1368() { - let m = Matrix3::::new( - 1.0, - 3.1575704e-23, - 8.1146196e-23, - 3.1575704e-23, - 1.0, - 1.7471054e-22, - 8.1146196e-23, - 1.7471054e-22, - 1.0, - ); - - for v in m - .try_symmetric_eigen(f32::EPSILON, 0) - .unwrap() - .eigenvalues - .into_iter() - { - assert_relative_eq!(*v, 1.); - } -} - -// #[cfg(feature = "arbitrary")] -// quickcheck! { -// TODO: full eigendecomposition is not implemented yet because of its complexity when some -// eigenvalues have multiplicity > 1. -// -// /* -// * NOTE: for the following tests, we use only upper-triangular matrices. -// * This ensures the schur decomposition will work, and allows use to test the eigenvector -// * computation. -// */ -// fn eigen(n: usize) -> bool { -// let n = cmp::max(1, cmp::min(n, 10)); -// let m = DMatrix::::new_random(n, n).upper_triangle(); -// -// let eig = RealEigen::new(m.clone()).unwrap(); -// verify_eigenvectors(m, eig) -// } -// -// fn eigen_with_adjacent_duplicate_diagonals(n: usize) -> bool { -// let n = cmp::max(1, cmp::min(n, 10)); -// let mut m = DMatrix::::new_random(n, n).upper_triangle(); -// -// // Suplicate some adjacent diagonal elements. -// for i in 0 .. n / 2 { -// m[(i * 2 + 1, i * 2 + 1)] = m[(i * 2, i * 2)]; -// } -// -// let eig = RealEigen::new(m.clone()).unwrap(); -// verify_eigenvectors(m, eig) -// } -// -// fn eigen_with_nonadjacent_duplicate_diagonals(n: usize) -> bool { -// let n = cmp::max(3, cmp::min(n, 10)); -// let mut m = DMatrix::::new_random(n, n).upper_triangle(); -// -// // Suplicate some diagonal elements. -// for i in n / 2 .. n { -// m[(i, i)] = m[(i - n / 2, i - n / 2)]; -// } -// -// let eig = RealEigen::new(m.clone()).unwrap(); -// verify_eigenvectors(m, eig) -// } -// -// fn eigen_static_square_4x4(m: Matrix4) -> bool { -// let m = m.upper_triangle(); -// let eig = RealEigen::new(m.clone()).unwrap(); -// verify_eigenvectors(m, eig) -// } -// -// fn eigen_static_square_3x3(m: Matrix3) -> bool { -// let m = m.upper_triangle(); -// let eig = RealEigen::new(m.clone()).unwrap(); -// verify_eigenvectors(m, eig) -// } -// -// fn eigen_static_square_2x2(m: Matrix2) -> bool { -// let m = m.upper_triangle(); -// println!("{}", m); -// let eig = RealEigen::new(m.clone()).unwrap(); -// verify_eigenvectors(m, eig) -// } -// } -// -// fn verify_eigenvectors(m: OMatrix, mut eig: RealEigen) -> bool -// where DefaultAllocator: Allocator + -// Allocator + -// Allocator + -// Allocator, -// OMatrix: Display, -// OVector: Display { -// let mv = &m * &eig.eigenvectors; -// -// println!("eigenvalues: {}eigenvectors: {}", eig.eigenvalues, eig.eigenvectors); -// -// let dim = m.nrows(); -// for i in 0 .. dim { -// let mut col = eig.eigenvectors.column_mut(i); -// col *= eig.eigenvalues[i]; -// } -// -// println!("{}{:.5}{:.5}", m, mv, eig.eigenvectors); -// -// relative_eq!(eig.eigenvectors, mv, epsilon = 1.0e-5) -// } diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/exp.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/exp.rs deleted file mode 100644 index 32ce57e3f..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/exp.rs +++ /dev/null @@ -1,175 +0,0 @@ -#[cfg(test)] -mod tests { - //https://github.com/scipy/scipy/blob/c1372d8aa90a73d8a52f135529293ff4edb98fc8/scipy/sparse/linalg/tests/test_matfuncs.py - #[test] - fn exp_static() { - use nalgebra::{Matrix1, Matrix2, Matrix3}; - - { - let m = Matrix1::new(1.0); - - let f = m.exp(); - - assert!(relative_eq!(f, Matrix1::new(1_f64.exp()), epsilon = 1.0e-7)); - } - - { - let m = Matrix2::new(0.0, 1.0, 0.0, 0.0); - - assert!(relative_eq!( - m.exp(), - Matrix2::new(1.0, 1.0, 0.0, 1.0), - epsilon = 1.0e-7 - )); - } - - { - let a: f64 = 1.0; - let b: f64 = 2.0; - let c: f64 = 3.0; - let d: f64 = 4.0; - let m = Matrix2::new(a, b, c, d); - - let delta = ((a - d).powf(2.0) + 4.0 * b * c).sqrt(); - let delta_2 = delta / 2.0; - let ad_2 = (a + d) / 2.0; - let m11 = ad_2.exp() * (delta * delta_2.cosh() + (a - d) * delta_2.sinh()); - let m12 = 2.0 * b * ad_2.exp() * delta_2.sinh(); - let m21 = 2.0 * c * ad_2.exp() * delta_2.sinh(); - let m22 = ad_2.exp() * (delta * delta_2.cosh() + (d - a) * delta_2.sinh()); - - let f = Matrix2::new(m11, m12, m21, m22) / delta; - assert!(relative_eq!(f, m.exp(), epsilon = 1.0e-7)); - } - - { - // https://mathworld.wolfram.com/MatrixExponential.html - use rand::{ - distributions::{Distribution, Uniform}, - thread_rng, - }; - let mut rng = thread_rng(); - let dist = Uniform::new(-10.0, 10.0); - loop { - let a: f64 = dist.sample(&mut rng); - let b: f64 = dist.sample(&mut rng); - let c: f64 = dist.sample(&mut rng); - let d: f64 = dist.sample(&mut rng); - let m = Matrix2::new(a, b, c, d); - - let delta_sq = (a - d).powf(2.0) + 4.0 * b * c; - if delta_sq < 0.0 { - continue; - } - - let delta = delta_sq.sqrt(); - let delta_2 = delta / 2.0; - let ad_2 = (a + d) / 2.0; - let m11 = ad_2.exp() * (delta * delta_2.cosh() + (a - d) * delta_2.sinh()); - let m12 = 2.0 * b * ad_2.exp() * delta_2.sinh(); - let m21 = 2.0 * c * ad_2.exp() * delta_2.sinh(); - let m22 = ad_2.exp() * (delta * delta_2.cosh() + (d - a) * delta_2.sinh()); - - let f = Matrix2::new(m11, m12, m21, m22) / delta; - assert!(relative_eq!(f, m.exp(), epsilon = 1.0e-7)); - break; - } - } - - { - let m = Matrix3::new(1.0, 3.0, 0.0, 0.0, 1.0, 5.0, 0.0, 0.0, 2.0); - - let e1 = 1.0_f64.exp(); - let e2 = 2.0_f64.exp(); - - let f = Matrix3::new( - e1, - 3.0 * e1, - 15.0 * (e2 - 2.0 * e1), - 0.0, - e1, - 5.0 * (e2 - e1), - 0.0, - 0.0, - e2, - ); - - assert!(relative_eq!(f, m.exp(), epsilon = 1.0e-7)); - } - } - - #[test] - fn exp_dynamic() { - use nalgebra::DMatrix; - - let m = DMatrix::from_row_slice(3, 3, &[1.0, 3.0, 0.0, 0.0, 1.0, 5.0, 0.0, 0.0, 2.0]); - - let e1 = 1.0_f64.exp(); - let e2 = 2.0_f64.exp(); - - let f = DMatrix::from_row_slice( - 3, - 3, - &[ - e1, - 3.0 * e1, - 15.0 * (e2 - 2.0 * e1), - 0.0, - e1, - 5.0 * (e2 - e1), - 0.0, - 0.0, - e2, - ], - ); - - assert!(relative_eq!(f, m.exp(), epsilon = 1.0e-7)); - } - - #[test] - fn exp_complex() { - use nalgebra::{Complex, DMatrix, DVector, Matrix2, RealField}; - - { - let z = Matrix2::>::zeros(); - - let identity = Matrix2::>::identity(); - - assert!((z.exp() - identity).norm() < 1e-7); - } - - { - let a = Matrix2::>::new( - Complex::::new(0.0, 1.0), - Complex::::new(0.0, 2.0), - Complex::::new(0.0, -1.0), - Complex::::new(0.0, 3.0), - ); - - let b = Matrix2::>::new( - Complex::::new(0.42645929666726, 1.89217550966333), - Complex::::new(-2.13721484276556, -0.97811251808259), - Complex::::new(1.06860742138278, 0.48905625904129), - Complex::::new(-1.7107555460983, 0.91406299158075), - ); - - assert!((a.exp() - b).norm() < 1.0e-07); - } - - { - let d1 = Complex::::new(0.0, ::pi()); - let d2 = Complex::::new(0.0, ::frac_pi_2()); - let d3 = Complex::::new(0.0, ::frac_pi_4()); - - let m = DMatrix::>::from_diagonal(&DVector::from_row_slice(&[d1, d2, d3])); - - let res = DMatrix::>::from_diagonal(&DVector::from_row_slice(&[ - d1.exp(), - d2.exp(), - d3.exp(), - ])); - - assert!((m.exp() - res).norm() < 1e-07); - } - } -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/full_piv_lu.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/full_piv_lu.rs deleted file mode 100644 index c78214fd4..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/full_piv_lu.rs +++ /dev/null @@ -1,472 +0,0 @@ -use na::Matrix3; - -#[test] -#[rustfmt::skip] -fn full_piv_lu_simple() { - let m = Matrix3::new( - 2.0, -1.0, 0.0, - -1.0, 2.0, -1.0, - 0.0, -1.0, 2.0); - - let lu = m.full_piv_lu(); - assert_eq!(lu.determinant(), 4.0); - - let (p, l, u, q) = lu.unpack(); - - let mut lu = l * u; - p.inv_permute_rows(&mut lu); - q.inv_permute_columns(&mut lu); - - assert!(relative_eq!(m, lu, epsilon = 1.0e-7)); -} - -#[test] -#[rustfmt::skip] -fn full_piv_lu_simple_with_pivot() { - let m = Matrix3::new(0.0, -1.0, 2.0, - -1.0, 2.0, -1.0, - 2.0, -1.0, 0.0); - - let lu = m.full_piv_lu(); - assert_eq!(lu.determinant(), -4.0); - - let (p, l, u, q) = lu.unpack(); - - let mut lu = l * u; - p.inv_permute_rows(&mut lu); - q.inv_permute_columns(&mut lu); - - assert!(relative_eq!(m, lu, epsilon = 1.0e-7)); -} - -#[cfg(feature = "arbitrary")] -mod proptest_tests { - macro_rules! gen_tests( - ($module: ident, $scalar: expr, $scalar_type: ty) => { - mod $module { - use std::cmp; - use num::One; - use na::{DMatrix, Matrix4x3, DVector, Vector4}; - #[allow(unused_imports)] - use crate::core::helper::{RandScalar, RandComplex}; - - use crate::proptest::*; - use proptest::{prop_assert, proptest}; - - proptest! { - #[test] - fn full_piv_lu(m in dmatrix_($scalar)) { - let lu = m.clone().full_piv_lu(); - let (p, l, u, q) = lu.unpack(); - let mut lu = l * u; - p.inv_permute_rows(&mut lu); - q.inv_permute_columns(&mut lu); - - prop_assert!(relative_eq!(m, lu, epsilon = 1.0e-7)) - } - - #[test] - fn full_piv_lu_static_3_5(m in matrix3x5_($scalar)) { - let lu = m.full_piv_lu(); - let (p, l, u, q) = lu.unpack(); - let mut lu = l * u; - p.inv_permute_rows(&mut lu); - q.inv_permute_columns(&mut lu); - - prop_assert!(relative_eq!(m, lu, epsilon = 1.0e-7)) - } - - #[test] - fn full_piv_lu_static_5_3(m in matrix5x3_($scalar)) { - let lu = m.full_piv_lu(); - let (p, l, u, q) = lu.unpack(); - let mut lu = l * u; - p.inv_permute_rows(&mut lu); - q.inv_permute_columns(&mut lu); - - prop_assert!(relative_eq!(m, lu, epsilon = 1.0e-7)) - } - - #[test] - fn full_piv_lu_static_square(m in matrix4_($scalar)) { - let lu = m.full_piv_lu(); - let (p, l, u, q) = lu.unpack(); - let mut lu = l * u; - p.inv_permute_rows(&mut lu); - q.inv_permute_columns(&mut lu); - - prop_assert!(relative_eq!(m, lu, epsilon = 1.0e-7)) - } - - #[test] - fn full_piv_lu_solve(n in PROPTEST_MATRIX_DIM, nb in PROPTEST_MATRIX_DIM) { - let m = DMatrix::<$scalar_type>::new_random(n, n).map(|e| e.0); - - let lu = m.clone().full_piv_lu(); - let b1 = DVector::<$scalar_type>::new_random(n).map(|e| e.0); - let b2 = DMatrix::<$scalar_type>::new_random(n, nb).map(|e| e.0); - - let sol1 = lu.solve(&b1); - let sol2 = lu.solve(&b2); - - prop_assert!(sol1.is_none() || relative_eq!(&m * sol1.unwrap(), b1, epsilon = 1.0e-6)); - prop_assert!(sol2.is_none() || relative_eq!(&m * sol2.unwrap(), b2, epsilon = 1.0e-6)); - } - - #[test] - fn full_piv_lu_solve_static(m in matrix4_($scalar)) { - let lu = m.full_piv_lu(); - let b1 = Vector4::<$scalar_type>::new_random().map(|e| e.0); - let b2 = Matrix4x3::<$scalar_type>::new_random().map(|e| e.0); - - let sol1 = lu.solve(&b1); - let sol2 = lu.solve(&b2); - - prop_assert!(sol1.is_none() || relative_eq!(&m * sol1.unwrap(), b1, epsilon = 1.0e-6)); - prop_assert!(sol2.is_none() || relative_eq!(&m * sol2.unwrap(), b2, epsilon = 1.0e-6)); - } - - #[test] - fn full_piv_lu_inverse(n in PROPTEST_MATRIX_DIM) { - let n = cmp::max(1, cmp::min(n, 15)); // To avoid slowing down the test too much. - let m = DMatrix::<$scalar_type>::new_random(n, n).map(|e| e.0); - - let mut l = m.lower_triangle(); - let mut u = m.upper_triangle(); - - // Ensure the matrix is well conditioned for inversion. - l.fill_diagonal(One::one()); - u.fill_diagonal(One::one()); - let m = l * u; - - let m1 = m.clone().full_piv_lu().try_inverse().unwrap(); - let id1 = &m * &m1; - let id2 = &m1 * &m; - - prop_assert!(id1.is_identity(1.0e-5)); - prop_assert!(id2.is_identity(1.0e-5)); - } - - #[test] - fn full_piv_lu_inverse_static(m in matrix4_($scalar)) { - let lu = m.full_piv_lu(); - - if let Some(m1) = lu.try_inverse() { - let id1 = &m * &m1; - let id2 = &m1 * &m; - - prop_assert!(id1.is_identity(1.0e-5)); - prop_assert!(id2.is_identity(1.0e-5)); - } - } - } - } - } - ); - - gen_tests!(complex, complex_f64(), RandComplex); - gen_tests!(f64, PROPTEST_F64, RandScalar); -} - -/* -#[test] -fn swap_rows() { - let mut m = Matrix5x3::new( - 11.0, 12.0, 13.0, - 21.0, 22.0, 23.0, - 31.0, 32.0, 33.0, - 41.0, 42.0, 43.0, - 51.0, 52.0, 53.0); - - let expected = Matrix5x3::new( - 11.0, 12.0, 13.0, - 41.0, 42.0, 43.0, - 31.0, 32.0, 33.0, - 21.0, 22.0, 23.0, - 51.0, 52.0, 53.0); - - m.swap_rows(1, 3); - - assert_eq!(m, expected); -} - -#[test] -fn swap_columns() { - let mut m = Matrix3x5::new( - 11.0, 12.0, 13.0, 14.0, 15.0, - 21.0, 22.0, 23.0, 24.0, 25.0, - 31.0, 32.0, 33.0, 34.0, 35.0); - - let expected = Matrix3x5::new( - 11.0, 14.0, 13.0, 12.0, 15.0, - 21.0, 24.0, 23.0, 22.0, 25.0, - 31.0, 34.0, 33.0, 32.0, 35.0); - - m.swap_columns(1, 3); - - assert_eq!(m, expected); -} - -#[test] -fn remove_columns() { - let m = Matrix3x5::new( - 11, 12, 13, 14, 15, - 21, 22, 23, 24, 25, - 31, 32, 33, 34, 35); - - let expected1 = Matrix3x4::new( - 12, 13, 14, 15, - 22, 23, 24, 25, - 32, 33, 34, 35); - - let expected2 = Matrix3x4::new( - 11, 12, 13, 14, - 21, 22, 23, 24, - 31, 32, 33, 34); - - let expected3 = Matrix3x4::new( - 11, 12, 14, 15, - 21, 22, 24, 25, - 31, 32, 34, 35); - - assert_eq!(m.remove_column(0), expected1); - assert_eq!(m.remove_column(4), expected2); - assert_eq!(m.remove_column(2), expected3); - - let expected1 = Matrix3::new( - 13, 14, 15, - 23, 24, 25, - 33, 34, 35); - - let expected2 = Matrix3::new( - 11, 12, 13, - 21, 22, 23, - 31, 32, 33); - - let expected3 = Matrix3::new( - 11, 12, 15, - 21, 22, 25, - 31, 32, 35); - - assert_eq!(m.remove_fixed_columns::(0), expected1); - assert_eq!(m.remove_fixed_columns::(3), expected2); - assert_eq!(m.remove_fixed_columns::(2), expected3); - - // The following is just to verify that the return type dimensions is correctly inferred. - let computed: Matrix<_, U3, Dyn, _> = m.remove_columns(3, 2); - assert!(computed.eq(&expected2)); -} - - -#[test] -fn remove_rows() { - let m = Matrix5x3::new( - 11, 12, 13, - 21, 22, 23, - 31, 32, 33, - 41, 42, 43, - 51, 52, 53); - - let expected1 = Matrix4x3::new( - 21, 22, 23, - 31, 32, 33, - 41, 42, 43, - 51, 52, 53); - - let expected2 = Matrix4x3::new( - 11, 12, 13, - 21, 22, 23, - 31, 32, 33, - 41, 42, 43); - - let expected3 = Matrix4x3::new( - 11, 12, 13, - 21, 22, 23, - 41, 42, 43, - 51, 52, 53); - - assert_eq!(m.remove_row(0), expected1); - assert_eq!(m.remove_row(4), expected2); - assert_eq!(m.remove_row(2), expected3); - - let expected1 = Matrix3::new( - 31, 32, 33, - 41, 42, 43, - 51, 52, 53); - - let expected2 = Matrix3::new( - 11, 12, 13, - 21, 22, 23, - 31, 32, 33); - - let expected3 = Matrix3::new( - 11, 12, 13, - 21, 22, 23, - 51, 52, 53); - - assert_eq!(m.remove_fixed_rows::(0), expected1); - assert_eq!(m.remove_fixed_rows::(3), expected2); - assert_eq!(m.remove_fixed_rows::(2), expected3); - - // The following is just to verify that the return type dimensions is correctly inferred. - let computed: Matrix<_, Dyn, U3, _> = m.remove_rows(3, 2); - assert!(computed.eq(&expected2)); -} - - -#[test] -fn insert_columns() { - let m = Matrix5x3::new( - 11, 12, 13, - 21, 22, 23, - 31, 32, 33, - 41, 42, 43, - 51, 52, 53); - - let expected1 = Matrix5x4::new( - 0, 11, 12, 13, - 0, 21, 22, 23, - 0, 31, 32, 33, - 0, 41, 42, 43, - 0, 51, 52, 53); - - let expected2 = Matrix5x4::new( - 11, 12, 13, 0, - 21, 22, 23, 0, - 31, 32, 33, 0, - 41, 42, 43, 0, - 51, 52, 53, 0); - - let expected3 = Matrix5x4::new( - 11, 12, 0, 13, - 21, 22, 0, 23, - 31, 32, 0, 33, - 41, 42, 0, 43, - 51, 52, 0, 53); - - assert_eq!(m.insert_column(0, 0), expected1); - assert_eq!(m.insert_column(3, 0), expected2); - assert_eq!(m.insert_column(2, 0), expected3); - - let expected1 = Matrix5::new( - 0, 0, 11, 12, 13, - 0, 0, 21, 22, 23, - 0, 0, 31, 32, 33, - 0, 0, 41, 42, 43, - 0, 0, 51, 52, 53); - - let expected2 = Matrix5::new( - 11, 12, 13, 0, 0, - 21, 22, 23, 0, 0, - 31, 32, 33, 0, 0, - 41, 42, 43, 0, 0, - 51, 52, 53, 0, 0); - - let expected3 = Matrix5::new( - 11, 12, 0, 0, 13, - 21, 22, 0, 0, 23, - 31, 32, 0, 0, 33, - 41, 42, 0, 0, 43, - 51, 52, 0, 0, 53); - - assert_eq!(m.insert_fixed_columns::(0, 0), expected1); - assert_eq!(m.insert_fixed_columns::(3, 0), expected2); - assert_eq!(m.insert_fixed_columns::(2, 0), expected3); - - // The following is just to verify that the return type dimensions is correctly inferred. - let computed: Matrix<_, U5, Dyn, _> = m.insert_columns(3, 2, 0); - assert!(computed.eq(&expected2)); -} - - -#[test] -fn insert_rows() { - let m = Matrix3x5::new( - 11, 12, 13, 14, 15, - 21, 22, 23, 24, 25, - 31, 32, 33, 34, 35); - - let expected1 = Matrix4x5::new( - 0, 0, 0, 0, 0, - 11, 12, 13, 14, 15, - 21, 22, 23, 24, 25, - 31, 32, 33, 34, 35); - - let expected2 = Matrix4x5::new( - 11, 12, 13, 14, 15, - 21, 22, 23, 24, 25, - 31, 32, 33, 34, 35, - 0, 0, 0, 0, 0); - - let expected3 = Matrix4x5::new( - 11, 12, 13, 14, 15, - 21, 22, 23, 24, 25, - 0, 0, 0, 0, 0, - 31, 32, 33, 34, 35); - - assert_eq!(m.insert_row(0, 0), expected1); - assert_eq!(m.insert_row(3, 0), expected2); - assert_eq!(m.insert_row(2, 0), expected3); - - let expected1 = Matrix5::new( - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 11, 12, 13, 14, 15, - 21, 22, 23, 24, 25, - 31, 32, 33, 34, 35); - - let expected2 = Matrix5::new( - 11, 12, 13, 14, 15, - 21, 22, 23, 24, 25, - 31, 32, 33, 34, 35, - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0); - - let expected3 = Matrix5::new( - 11, 12, 13, 14, 15, - 21, 22, 23, 24, 25, - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 31, 32, 33, 34, 35); - - assert_eq!(m.insert_fixed_rows::<2>(0, 0), expected1); - assert_eq!(m.insert_fixed_rows::<2>(3, 0), expected2); - assert_eq!(m.insert_fixed_rows::<2>(2, 0), expected3); - - // The following is just to verify that the return type dimensions is correctly inferred. - let computed: Matrix<_, Dyn, U5, _> = m.insert_rows(3, 2, 0); - assert!(computed.eq(&expected2)); -} - -#[test] -fn resize() { - let m = Matrix3x5::new( - 11, 12, 13, 14, 15, - 21, 22, 23, 24, 25, - 31, 32, 33, 34, 35); - - let add_add = DMatrix::from_row_slice(5, 6, &[ - 11, 12, 13, 14, 15, 42, - 21, 22, 23, 24, 25, 42, - 31, 32, 33, 34, 35, 42, - 42, 42, 42, 42, 42, 42, - 42, 42, 42, 42, 42, 42]); - - let del_del = DMatrix::from_row_slice(1, 2, &[11, 12]); - - let add_del = DMatrix::from_row_slice(5, 2, &[ - 11, 12, - 21, 22, - 31, 32, - 42, 42, - 42, 42]); - - let del_add = DMatrix::from_row_slice(1, 8, &[ - 11, 12, 13, 14, 15, 42, 42, 42]); - - assert_eq!(del_del, m.resize(1, 2, 42)); - assert_eq!(add_add, m.resize(5, 6, 42)); - assert_eq!(add_del, m.resize(5, 2, 42)); - assert_eq!(del_add, m.resize(1, 8, 42)); -} -*/ diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/hessenberg.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/hessenberg.rs deleted file mode 100644 index 6236fe8e5..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/hessenberg.rs +++ /dev/null @@ -1,51 +0,0 @@ -#![cfg(feature = "proptest-support")] - -use na::Matrix2; - -#[test] -fn hessenberg_simple() { - let m = Matrix2::new(1.0, 0.0, 1.0, 3.0); - let hess = m.hessenberg(); - let (p, h) = hess.unpack(); - assert!(relative_eq!(m, p * h * p.transpose(), epsilon = 1.0e-7)) -} - -macro_rules! gen_tests( - ($module: ident, $scalar: expr, $scalar_type: ty) => { - mod $module { - use na::DMatrix; - #[allow(unused_imports)] - use crate::core::helper::{RandScalar, RandComplex}; - - use crate::proptest::*; - use proptest::{prop_assert, proptest}; - - proptest! { - #[test] - fn hessenberg(n in PROPTEST_MATRIX_DIM) { - let m = DMatrix::<$scalar_type>::new_random(n, n).map(|e| e.0); - let hess = m.clone().hessenberg(); - let (p, h) = hess.unpack(); - prop_assert!(relative_eq!(m, &p * h * p.adjoint(), epsilon = 1.0e-7)) - } - - #[test] - fn hessenberg_static_mat2(m in matrix2_($scalar)) { - let hess = m.hessenberg(); - let (p, h) = hess.unpack(); - prop_assert!(relative_eq!(m, p * h * p.adjoint(), epsilon = 1.0e-7)) - } - - #[test] - fn hessenberg_static(m in matrix4_($scalar)) { - let hess = m.hessenberg(); - let (p, h) = hess.unpack(); - prop_assert!(relative_eq!(m, p * h * p.adjoint(), epsilon = 1.0e-7)) - } - } - } - } -); - -gen_tests!(complex, complex_f64(), RandComplex); -gen_tests!(f64, PROPTEST_F64, RandScalar); diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/inverse.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/inverse.rs deleted file mode 100644 index 46f15a375..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/inverse.rs +++ /dev/null @@ -1,142 +0,0 @@ -use na::{Matrix1, Matrix2, Matrix3, Matrix4, Matrix5}; - -#[test] -fn matrix1_try_inverse() { - let a = Matrix1::new(3.0); - let a_inv = a.try_inverse().expect("Matrix is invertible"); - - assert_relative_eq!(a_inv, Matrix1::new(1.0 / 3.0)); -} - -#[test] -#[rustfmt::skip] -fn matrix2_try_inverse() { - let a = Matrix2::new( 5.0, -2.0, - -10.0, 1.0); - let expected_inverse = Matrix2::new(-0.2 / 3.0, -2.0 / 15.0, - -2.0 / 3.0, -1.0 / 3.0); - let a_inv = a.try_inverse() - .expect("Matrix is invertible"); - - assert_relative_eq!(a_inv, expected_inverse); -} - -#[test] -#[rustfmt::skip] -fn matrix3_try_inverse() { - let a = Matrix3::new(-3.0, 2.0, 0.0, - -6.0, 9.0, -2.0, - 9.0, -6.0, 4.0); - let expected_inverse = Matrix3::new(-0.40, 0.4 / 3.0, 0.2 / 3.00, - -0.10, 0.2, 0.10, - 0.75, 0.0, 0.25); - let a_inv = a.try_inverse() - .expect("Matrix is invertible"); - - assert_relative_eq!(a_inv, expected_inverse); -} - -#[test] -#[rustfmt::skip] -fn matrix4_try_inverse_issue_214() { - let m1 = Matrix4::new( - -0.34727043, 0.00000005397217, -0.000000000000003822135, -0.000000000000003821371, - 0.0, -0.000000026986084, -1.0001999, -1.0, - 0.000000030359345, 0.61736965, -0.000000043720128, -0.00000004371139, - -0.0000000029144975, -0.05926739, 3.8007796, 4.0); - - - let m2 = Matrix4::new( - -0.34727043, 0.00000005397217, -0.000000000000003822135, -0.000000000000003821371, - 0.0, -0.000000026986084, -1.0001999, -1.0, - 0.000000030359345, 0.61736965, -0.000000043720128, -0.00000004371139, - -0.0000000029448568, -0.05988476, 3.8007796, 4.0); - - assert!(m1.try_inverse().is_some()); - assert!(m2.try_inverse().is_some()); - assert!(m1.transpose().try_inverse().is_some()); - assert!(m2.transpose().try_inverse().is_some()); -} - -#[test] -#[rustfmt::skip] -fn matrix5_try_inverse() { - // Dimension 5 is chosen so that the inversion happens by Gaussian elimination. - // (at the time of writing dimensions <= 3 are implemented as analytic formulas, but we choose - // 5 in the case that 4 also gets an analytic implementation) - let a = Matrix5::new(-2.0, 0.0, 2.0, 5.0, -5.0, - -6.0, 4.0, 4.0, 13.0, -15.0, - 4.0, 16.0, -14.0, -19.0, 12.0, - 12.0, 12.0, -22.0, -35.0, 34.0, - -8.0, 4.0, 12.0, 27.0, -31.0); - let expected_inverse = Matrix5::new( - 3.9333e+00, -1.5667e+00, 2.6667e-01, 6.6667e-02, 3.0000e-01, - -1.2033e+01, 3.9667e+00, -1.1167e+00, 2.8333e-01, -1.0000e-01, - -1.8233e+01, 5.7667e+00, -1.5667e+00, 2.3333e-01, -2.0000e-01, - -4.3333e+00, 1.6667e+00, -6.6667e-01, 3.3333e-01, -4.6950e-19, - -1.3400e+01, 4.6000e+00, -1.4000e+00, 4.0000e-01, -2.0000e-01); - let a_inv = a.try_inverse().expect("Matrix is not invertible"); - - assert_relative_eq!(a_inv, expected_inverse, max_relative=1e-4); -} - -#[test] -fn matrix1_try_inverse_scaled_identity() { - // A perfectly invertible matrix with - // very small coefficients - let a = Matrix1::new(1.0e-20); - let expected_inverse = Matrix1::new(1.0e20); - let a_inv = a.try_inverse().expect("Matrix should be invertible"); - - assert_relative_eq!(a_inv, expected_inverse); -} - -#[test] -#[rustfmt::skip] -fn matrix2_try_inverse_scaled_identity() { - // A perfectly invertible matrix with - // very small coefficients - let a = Matrix2::new(1.0e-20, 0.0, - 0.0, 1.0e-20); - let expected_inverse = Matrix2::new(1.0e20, 0.0, - 0.0, 1.0e20); - let a_inv = a.try_inverse().expect("Matrix should be invertible"); - - assert_relative_eq!(a_inv, expected_inverse); -} - -#[test] -#[rustfmt::skip] -fn matrix3_try_inverse_scaled_identity() { - // A perfectly invertible matrix with - // very small coefficients - let a = Matrix3::new(1.0e-20, 0.0, 0.0, - 0.0, 1.0e-20, 0.0, - 0.0, 0.0, 1.0e-20); - let expected_inverse = Matrix3::new(1.0e20, 0.0, 0.0, - 0.0, 1.0e20, 0.0, - 0.0, 0.0, 1.0e20); - let a_inv = a.try_inverse().expect("Matrix should be invertible"); - - assert_relative_eq!(a_inv, expected_inverse); -} - -#[test] -#[rustfmt::skip] -fn matrix5_try_inverse_scaled_identity() { - // A perfectly invertible matrix with - // very small coefficients - let a = Matrix5::new(1.0e-20, 0.0, 0.0, 0.0, 0.0, - 0.0, 1.0e-20, 0.0, 0.0, 0.0, - 0.0, 0.0, 1.0e-20, 0.0, 0.0, - 0.0, 0.0, 0.0, 1.0e-20, 0.0, - 0.0, 0.0, 0.0, 0.0, 1.0e-20); - let expected_inverse = Matrix5::new(1.0e+20, 0.0, 0.0, 0.0, 0.0, - 0.0, 1.0e+20, 0.0, 0.0, 0.0, - 0.0, 0.0, 1.0e+20, 0.0, 0.0, - 0.0, 0.0, 0.0, 1.0e+20, 0.0, - 0.0, 0.0, 0.0, 0.0, 1.0e+20); - let a_inv = a.try_inverse().expect("Matrix should be invertible"); - - assert_relative_eq!(a_inv, expected_inverse); -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/lu.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/lu.rs deleted file mode 100644 index 1ebd31787..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/lu.rs +++ /dev/null @@ -1,158 +0,0 @@ -use na::Matrix3; - -#[test] -#[rustfmt::skip] -fn lu_simple() { - let m = Matrix3::new( - 2.0, -1.0, 0.0, - -1.0, 2.0, -1.0, - 0.0, -1.0, 2.0); - - let lu = m.lu(); - assert_eq!(lu.determinant(), 4.0); - - let (p, l, u) = lu.unpack(); - - let mut lu = l * u; - p.inv_permute_rows(&mut lu); - - assert!(relative_eq!(m, lu, epsilon = 1.0e-7)); -} - -#[test] -#[rustfmt::skip] -fn lu_simple_with_pivot() { - let m = Matrix3::new( - 0.0, -1.0, 2.0, - -1.0, 2.0, -1.0, - 2.0, -1.0, 0.0); - - let lu = m.lu(); - assert_eq!(lu.determinant(), -4.0); - - let (p, l, u) = lu.unpack(); - - let mut lu = l * u; - p.inv_permute_rows(&mut lu); - - assert!(relative_eq!(m, lu, epsilon = 1.0e-7)); -} - -#[cfg(feature = "proptest-support")] -mod proptest_tests { - macro_rules! gen_tests( - ($module: ident, $scalar: expr, $scalar_type: ty) => { - mod $module { - use na::{DMatrix, Matrix4x3, DVector, Vector4}; - #[allow(unused_imports)] - use crate::core::helper::{RandScalar, RandComplex}; - use crate::proptest::*; - use proptest::{prop_assert, proptest}; - - proptest! { - #[test] - fn lu(m in dmatrix_($scalar)) { - let lu = m.clone().lu(); - let (p, l, u) = lu.unpack(); - let mut lu = l * u; - p.inv_permute_rows(&mut lu); - - prop_assert!(relative_eq!(m, lu, epsilon = 1.0e-7)) - } - - #[test] - fn lu_static_3_5(m in matrix3x5_($scalar)) { - let lu = m.lu(); - let (p, l, u) = lu.unpack(); - let mut lu = l * u; - p.inv_permute_rows(&mut lu); - - prop_assert!(relative_eq!(m, lu, epsilon = 1.0e-7)) - } - - fn lu_static_5_3(m in matrix5x3_($scalar)) { - let lu = m.lu(); - let (p, l, u) = lu.unpack(); - let mut lu = l * u; - p.inv_permute_rows(&mut lu); - - prop_assert!(relative_eq!(m, lu, epsilon = 1.0e-7)); - } - - #[test] - fn lu_static_square(m in matrix4_($scalar)) { - let lu = m.lu(); - let (p, l, u) = lu.unpack(); - let mut lu = l * u; - p.inv_permute_rows(&mut lu); - - prop_assert!(relative_eq!(m, lu, epsilon = 1.0e-7)); - } - - #[test] - fn lu_solve(n in PROPTEST_MATRIX_DIM, nb in PROPTEST_MATRIX_DIM) { - let m = DMatrix::<$scalar_type>::new_random(n, n).map(|e| e.0); - - let lu = m.clone().lu(); - let b1 = DVector::<$scalar_type>::new_random(n).map(|e| e.0); - let b2 = DMatrix::<$scalar_type>::new_random(n, nb).map(|e| e.0); - - let sol1 = lu.solve(&b1); - let sol2 = lu.solve(&b2); - - prop_assert!(sol1.is_none() || relative_eq!(&m * sol1.unwrap(), b1, epsilon = 1.0e-6)); - prop_assert!(sol2.is_none() || relative_eq!(&m * sol2.unwrap(), b2, epsilon = 1.0e-6)); - } - - #[test] - fn lu_solve_static(m in matrix4_($scalar)) { - let lu = m.lu(); - let b1 = Vector4::<$scalar_type>::new_random().map(|e| e.0); - let b2 = Matrix4x3::<$scalar_type>::new_random().map(|e| e.0); - - let sol1 = lu.solve(&b1); - let sol2 = lu.solve(&b2); - - prop_assert!(sol1.is_none() || relative_eq!(&m * sol1.unwrap(), b1, epsilon = 1.0e-6)); - prop_assert!(sol2.is_none() || relative_eq!(&m * sol2.unwrap(), b2, epsilon = 1.0e-6)); - } - - #[test] - fn lu_inverse(n in PROPTEST_MATRIX_DIM) { - let m = DMatrix::<$scalar_type>::new_random(n, n).map(|e| e.0); - let mut l = m.lower_triangle(); - let mut u = m.upper_triangle(); - - // Ensure the matrix is well conditioned for inversion. - l.fill_diagonal(na::one()); - u.fill_diagonal(na::one()); - let m = l * u; - - let m1 = m.clone().lu().try_inverse().unwrap(); - let id1 = &m * &m1; - let id2 = &m1 * &m; - - prop_assert!(id1.is_identity(1.0e-5)); - prop_assert!(id2.is_identity(1.0e-5)); - } - - #[test] - fn lu_inverse_static(m in matrix4_($scalar)) { - let lu = m.lu(); - - if let Some(m1) = lu.try_inverse() { - let id1 = &m * &m1; - let id2 = &m1 * &m; - - prop_assert!(id1.is_identity(1.0e-5)); - prop_assert!(id2.is_identity(1.0e-5)); - } - } - } - } - } - ); - - gen_tests!(complex, complex_f64(), RandComplex); - gen_tests!(f64, PROPTEST_F64, RandScalar); -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/mod.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/mod.rs deleted file mode 100644 index 1bc38bcb5..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/mod.rs +++ /dev/null @@ -1,18 +0,0 @@ -mod balancing; -mod bidiagonal; -mod cholesky; -mod col_piv_qr; -mod convolution; -mod eigen; -mod exp; -mod full_piv_lu; -mod hessenberg; -mod inverse; -mod lu; -mod pow; -mod qr; -mod schur; -mod solve; -mod svd; -mod tridiagonal; -mod udu; diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/pow.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/pow.rs deleted file mode 100644 index 3d8eb013d..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/pow.rs +++ /dev/null @@ -1,49 +0,0 @@ -#[cfg(feature = "proptest-support")] -mod proptest_tests { - macro_rules! gen_tests( - ($module: ident, $scalar: expr, $scalar_type: ty) => { - mod $module { - use na::DMatrix; - #[allow(unused_imports)] - use crate::core::helper::{RandScalar, RandComplex}; - use std::cmp; - - use crate::proptest::*; - use proptest::{prop_assert, proptest}; - - proptest! { - #[test] - fn pow(n in PROPTEST_MATRIX_DIM, p in 0u32..=4) { - let n = cmp::max(1, cmp::min(n, 10)); - let m = DMatrix::<$scalar_type>::new_random(n, n).map(|e| e.0); - let m_pow = m.pow(p); - let mut expected = m.clone(); - expected.fill_with_identity(); - - for _ in 0..p { - expected = &m * &expected; - } - - prop_assert!(relative_eq!(m_pow, expected, epsilon = 1.0e-5)) - } - - #[test] - fn pow_static_square_4x4(m in matrix4_($scalar), p in 0u32..=4) { - let mut expected = m.clone(); - let m_pow = m.pow(p); - expected.fill_with_identity(); - - for _ in 0..p { - expected = &m * &expected; - } - - prop_assert!(relative_eq!(m_pow, expected, epsilon = 1.0e-5)) - } - } - } - } - ); - - gen_tests!(complex, complex_f64(), RandComplex); - gen_tests!(f64, PROPTEST_F64, RandScalar); -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/qr.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/qr.rs deleted file mode 100644 index 0a8f46768..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/qr.rs +++ /dev/null @@ -1,118 +0,0 @@ -#![cfg(feature = "proptest-support")] - -macro_rules! gen_tests( - ($module: ident, $scalar: expr, $scalar_type: ty) => { - mod $module { - use na::{DMatrix, DVector, Matrix4x3, Vector4}; - use std::cmp; - #[allow(unused_imports)] - use crate::core::helper::{RandScalar, RandComplex}; - use crate::proptest::*; - use proptest::{prop_assert, proptest}; - - proptest! { - #[test] - fn qr(m in dmatrix_($scalar)) { - let qr = m.clone().qr(); - let q = qr.q(); - let r = qr.r(); - - prop_assert!(relative_eq!(m, &q * r, epsilon = 1.0e-7)); - prop_assert!(q.is_orthogonal(1.0e-7)); - } - - #[test] - fn qr_static_5_3(m in matrix5x3_($scalar)) { - let qr = m.qr(); - let q = qr.q(); - let r = qr.r(); - - prop_assert!(relative_eq!(m, q * r, epsilon = 1.0e-7)); - prop_assert!(q.is_orthogonal(1.0e-7)); - } - - #[test] - fn qr_static_3_5(m in matrix3x5_($scalar)) { - let qr = m.qr(); - let q = qr.q(); - let r = qr.r(); - - prop_assert!(relative_eq!(m, q * r, epsilon = 1.0e-7)); - prop_assert!(q.is_orthogonal(1.0e-7)); - } - - #[test] - fn qr_static_square(m in matrix4_($scalar)) { - let qr = m.qr(); - let q = qr.q(); - let r = qr.r(); - - prop_assert!(relative_eq!(m, q * r, epsilon = 1.0e-7)); - prop_assert!(q.is_orthogonal(1.0e-7)); - } - - #[test] - fn qr_solve(n in PROPTEST_MATRIX_DIM, nb in PROPTEST_MATRIX_DIM) { - let m = DMatrix::<$scalar_type>::new_random(n, n).map(|e| e.0); - - let qr = m.clone().qr(); - let b1 = DVector::<$scalar_type>::new_random(n).map(|e| e.0); - let b2 = DMatrix::<$scalar_type>::new_random(n, nb).map(|e| e.0); - - if qr.is_invertible() { - let sol1 = qr.solve(&b1).unwrap(); - let sol2 = qr.solve(&b2).unwrap(); - - prop_assert!(relative_eq!(&m * sol1, b1, epsilon = 1.0e-6)); - prop_assert!(relative_eq!(&m * sol2, b2, epsilon = 1.0e-6)); - } - } - - #[test] - fn qr_solve_static(m in matrix4_($scalar)) { - let qr = m.qr(); - let b1 = Vector4::<$scalar_type>::new_random().map(|e| e.0); - let b2 = Matrix4x3::<$scalar_type>::new_random().map(|e| e.0); - - if qr.is_invertible() { - let sol1 = qr.solve(&b1).unwrap(); - let sol2 = qr.solve(&b2).unwrap(); - - prop_assert!(relative_eq!(m * sol1, b1, epsilon = 1.0e-6)); - prop_assert!(relative_eq!(m * sol2, b2, epsilon = 1.0e-6)); - } - } - - #[test] - fn qr_inverse(n in PROPTEST_MATRIX_DIM) { - let n = cmp::max(1, cmp::min(n, 15)); // To avoid slowing down the test too much. - let m = DMatrix::<$scalar_type>::new_random(n, n).map(|e| e.0); - - if let Some(m1) = m.clone().qr().try_inverse() { - let id1 = &m * &m1; - let id2 = &m1 * &m; - - prop_assert!(id1.is_identity(1.0e-5)); - prop_assert!(id2.is_identity(1.0e-5)); - } - } - - #[test] - fn qr_inverse_static(m in matrix4_($scalar)) { - let qr = m.qr(); - - if let Some(m1) = qr.try_inverse() { - let id1 = &m * &m1; - let id2 = &m1 * &m; - - prop_assert!(id1.is_identity(1.0e-5)); - prop_assert!(id2.is_identity(1.0e-5)); - } - } - } - } - } -); - -gen_tests!(complex, complex_f64(), RandComplex); -gen_tests!(f64, PROPTEST_F64, RandScalar); diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/schur.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/schur.rs deleted file mode 100644 index 9bf5cd459..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/schur.rs +++ /dev/null @@ -1,131 +0,0 @@ -use na::{DMatrix, Matrix3, Matrix4}; - -#[test] -#[rustfmt::skip] -fn schur_simpl_mat3() { - let m = Matrix3::new(-2.0, -4.0, 2.0, - -2.0, 1.0, 2.0, - 4.0, 2.0, 5.0); - - let schur = m.schur(); - let (vecs, vals) = schur.unpack(); - - assert!(relative_eq!(vecs * vals * vecs.transpose(), m, epsilon = 1.0e-7)); -} - -#[cfg(feature = "proptest-support")] -mod proptest_tests { - macro_rules! gen_tests( - ($module: ident, $scalar: expr, $scalar_type: ty) => { - mod $module { - use na::DMatrix; - #[allow(unused_imports)] - use crate::core::helper::{RandScalar, RandComplex}; - use crate::proptest::*; - use proptest::{prop_assert, proptest}; - - proptest! { - #[test] - fn schur(n in PROPTEST_MATRIX_DIM) { - let m = DMatrix::<$scalar_type>::new_random(n, n).map(|e| e.0); - let (vecs, vals) = m.clone().schur().unpack(); - prop_assert!(relative_eq!(&vecs * vals * vecs.adjoint(), m, epsilon = 1.0e-7)); - } - - #[test] - fn schur_static_mat2(m in matrix2_($scalar)) { - let (vecs, vals) = m.clone().schur().unpack(); - prop_assert!(relative_eq!(vecs * vals * vecs.adjoint(), m, epsilon = 1.0e-7)); - } - - #[test] - fn schur_static_mat3(m in matrix3_($scalar)) { - let (vecs, vals) = m.clone().schur().unpack(); - prop_assert!(relative_eq!(vecs * vals * vecs.adjoint(), m, epsilon = 1.0e-7)); - } - - #[test] - fn schur_static_mat4(m in matrix4_($scalar)) { - let (vecs, vals) = m.clone().schur().unpack(); - prop_assert!(relative_eq!(vecs * vals * vecs.adjoint(), m, epsilon = 1.0e-7)); - } - } - } - } - ); - - gen_tests!(complex, complex_f64(), RandComplex); - gen_tests!(f64, PROPTEST_F64, RandScalar); -} - -#[test] -#[rustfmt::skip] -fn schur_static_mat4_fail() { - let m = Matrix4::new( - 33.32699857679677, 46.794945978960044, -20.792148817005838, 84.73945485997737, - -53.04896234480401, -4.031523330630989, 19.022858300892366, -93.2258351951158, - -94.61793793643038, -18.64216213611094, 88.32376703241675, -99.30169870309795, - 90.62661897246733, 96.74200696130146, 34.7421322611369, 84.86773307198098); - - let (vecs, vals) = m.clone().schur().unpack(); - assert!(relative_eq!(vecs * vals * vecs.transpose(), m, epsilon = 1.0e-7)) -} - -#[test] -#[rustfmt::skip] -fn schur_static_mat4_fail2() { - let m = Matrix4::new( - 14.623586538485966, 7.646156622760756, -52.11923331576265, -97.50030223503413, - 53.829398131426785, -33.40560799661168, 70.31168286972388, -81.25248138434173, - 27.932377940728202, 82.94220150938, -35.5898884705951, 67.56447552434219, - 55.66754906908682, -42.14328890569226, -20.684709585152206, -87.9456949841046); - - let (vecs, vals) = m.clone().schur().unpack(); - assert!(relative_eq!(vecs * vals * vecs.transpose(), m, epsilon = 1.0e-7)) -} - -#[test] -#[rustfmt::skip] -fn schur_static_mat3_fail() { - let m = Matrix3::new( - -21.58457553143394, -67.3881542667948, -14.619829849784338, - -7.525423104386547, -17.827350599642287, 11.297377444555849, - 38.080736654870464, -84.27428302131528, -95.88198590331922); - - let (vecs, vals) = m.clone().schur().unpack(); - assert!(relative_eq!(vecs * vals * vecs.transpose(), m, epsilon = 1.0e-7)) -} - -// Test proposed on the issue #176 of rulinalg. -#[test] -#[rustfmt::skip] -fn schur_singular() { - let m = DMatrix::from_row_slice(24, 24, &[ - 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - -1.0, -1.0, -1.0, -1.0, -1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, -1.0, -1.0, -1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, -1.0, -1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, 0.0, 1.0, 1.0, 1.0, - 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 4.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 4.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0]); - - let (vecs, vals) = m.clone().schur().unpack(); - assert!(relative_eq!(&vecs * vals * vecs.transpose(), m, epsilon = 1.0e-7)) -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/solve.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/solve.rs deleted file mode 100644 index a4c41185b..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/solve.rs +++ /dev/null @@ -1,66 +0,0 @@ -#![cfg(feature = "proptest-support")] - -macro_rules! gen_tests( - ($module: ident, $scalar: expr) => { - mod $module { - use na::{Matrix4, ComplexField}; - #[allow(unused_imports)] - use crate::core::helper::{RandScalar, RandComplex}; - use crate::proptest::*; - use proptest::{prop_assert, proptest}; - - fn unzero_diagonal(a: &mut Matrix4) { - for i in 0..4 { - if a[(i, i)].clone().norm1() < na::convert(1.0e-7) { - a[(i, i)] = T::one(); - } - } - } - - proptest! { - #[test] - fn solve_lower_triangular(a in matrix4_($scalar), b in matrix4x5_($scalar)) { - let mut a = a; - unzero_diagonal(&mut a); - let tri = a.lower_triangle(); - let x = a.solve_lower_triangular(&b).unwrap(); - - prop_assert!(relative_eq!(tri * x, b, epsilon = 1.0e-7)) - } - - #[test] - fn solve_upper_triangular(a in matrix4_($scalar), b in matrix4x5_($scalar)) { - let mut a = a; - unzero_diagonal(&mut a); - let tri = a.upper_triangle(); - let x = a.solve_upper_triangular(&b).unwrap(); - - prop_assert!(relative_eq!(tri * x, b, epsilon = 1.0e-7)) - } - - #[test] - fn tr_solve_lower_triangular(a in matrix4_($scalar), b in matrix4x5_($scalar)) { - let mut a = a; - unzero_diagonal(&mut a); - let tri = a.lower_triangle(); - let x = a.tr_solve_lower_triangular(&b).unwrap(); - - prop_assert!(relative_eq!(tri.transpose() * x, b, epsilon = 1.0e-7)) - } - - #[test] - fn tr_solve_upper_triangular(a in matrix4_($scalar), b in matrix4x5_($scalar)) { - let mut a = a; - unzero_diagonal(&mut a); - let tri = a.upper_triangle(); - let x = a.tr_solve_upper_triangular(&b).unwrap(); - - prop_assert!(relative_eq!(tri.transpose() * x, b, epsilon = 1.0e-7)) - } - } - } - } -); - -gen_tests!(complex, complex_f64()); -gen_tests!(f64, PROPTEST_F64); diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/svd.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/svd.rs deleted file mode 100644 index b146aef3b..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/svd.rs +++ /dev/null @@ -1,515 +0,0 @@ -use crate::utils::is_sorted_descending; -use na::{DMatrix, Matrix6}; - -#[cfg(feature = "proptest-support")] -mod proptest_tests { - macro_rules! gen_tests( - ($module: ident, $scalar: expr, $scalar_type: ty) => { - mod $module { - use na::{ - DMatrix, DVector, Matrix2, Matrix3, Matrix4, - ComplexField - }; - use std::cmp; - #[allow(unused_imports)] - use crate::core::helper::{RandScalar, RandComplex}; - use crate::proptest::*; - use proptest::{prop_assert, proptest}; - use crate::utils::is_sorted_descending; - - proptest! { - #[test] - fn svd(m in dmatrix_($scalar)) { - let svd = m.clone().svd(true, true); - let recomp_m = svd.clone().recompose().unwrap(); - let (u, s, v_t) = (svd.u.unwrap(), svd.singular_values, svd.v_t.unwrap()); - let ds = DMatrix::from_diagonal(&s.map(|e| ComplexField::from_real(e))); - - prop_assert!(s.iter().all(|e| *e >= 0.0)); - prop_assert!(relative_eq!(&u * ds * &v_t, recomp_m, epsilon = 1.0e-5)); - prop_assert!(relative_eq!(m, recomp_m, epsilon = 1.0e-5)); - prop_assert!(is_sorted_descending(s.as_slice())); - } - - #[test] - fn svd_static_5_3(m in matrix5x3_($scalar)) { - let svd = m.svd(true, true); - let (u, s, v_t) = (svd.u.unwrap(), svd.singular_values, svd.v_t.unwrap()); - let ds = Matrix3::from_diagonal(&s.map(|e| ComplexField::from_real(e))); - - prop_assert!(s.iter().all(|e| *e >= 0.0)); - prop_assert!(relative_eq!(m, &u * ds * &v_t, epsilon = 1.0e-5)); - prop_assert!(u.is_orthogonal(1.0e-5)); - prop_assert!(v_t.is_orthogonal(1.0e-5)); - prop_assert!(is_sorted_descending(s.as_slice())); - } - - #[test] - fn svd_static_5_2(m in matrix5x2_($scalar)) { - let svd = m.svd(true, true); - let (u, s, v_t) = (svd.u.unwrap(), svd.singular_values, svd.v_t.unwrap()); - let ds = Matrix2::from_diagonal(&s.map(|e| ComplexField::from_real(e))); - - prop_assert!(s.iter().all(|e| *e >= 0.0)); - prop_assert!(relative_eq!(m, &u * ds * &v_t, epsilon = 1.0e-5)); - prop_assert!(u.is_orthogonal(1.0e-5)); - prop_assert!(v_t.is_orthogonal(1.0e-5)); - prop_assert!(is_sorted_descending(s.as_slice())); - } - - #[test] - fn svd_static_3_5(m in matrix3x5_($scalar)) { - let svd = m.svd(true, true); - let (u, s, v_t) = (svd.u.unwrap(), svd.singular_values, svd.v_t.unwrap()); - - let ds = Matrix3::from_diagonal(&s.map(|e| ComplexField::from_real(e))); - - prop_assert!(s.iter().all(|e| *e >= 0.0)); - prop_assert!(relative_eq!(m, u * ds * v_t, epsilon = 1.0e-5)); - prop_assert!(is_sorted_descending(s.as_slice())); - } - - #[test] - fn svd_static_2_5(m in matrix2x5_($scalar)) { - let svd = m.svd(true, true); - let (u, s, v_t) = (svd.u.unwrap(), svd.singular_values, svd.v_t.unwrap()); - let ds = Matrix2::from_diagonal(&s.map(|e| ComplexField::from_real(e))); - - prop_assert!(s.iter().all(|e| *e >= 0.0)); - prop_assert!(relative_eq!(m, u * ds * v_t, epsilon = 1.0e-5)); - prop_assert!(is_sorted_descending(s.as_slice())); - } - - #[test] - fn svd_static_square(m in matrix4_($scalar)) { - let svd = m.svd(true, true); - let (u, s, v_t) = (svd.u.unwrap(), svd.singular_values, svd.v_t.unwrap()); - let ds = Matrix4::from_diagonal(&s.map(|e| ComplexField::from_real(e))); - - prop_assert!(s.iter().all(|e| *e >= 0.0)); - prop_assert!(relative_eq!(m, u * ds * v_t, epsilon = 1.0e-5)); - prop_assert!(u.is_orthogonal(1.0e-5)); - prop_assert!(v_t.is_orthogonal(1.0e-5)); - prop_assert!(is_sorted_descending(s.as_slice())); - } - - #[test] - fn svd_static_square_2x2(m in matrix2_($scalar)) { - let svd = m.svd(true, true); - let (u, s, v_t) = (svd.u.unwrap(), svd.singular_values, svd.v_t.unwrap()); - let ds = Matrix2::from_diagonal(&s.map(|e| ComplexField::from_real(e))); - - prop_assert!(s.iter().all(|e| *e >= 0.0)); - prop_assert!(relative_eq!(m, u * ds * v_t, epsilon = 1.0e-5)); - prop_assert!(u.is_orthogonal(1.0e-5)); - prop_assert!(v_t.is_orthogonal(1.0e-5)); - prop_assert!(is_sorted_descending(s.as_slice())); - } - - #[test] - fn svd_static_square_3x3(m in matrix3_($scalar)) { - let svd = m.svd(true, true); - let (u, s, v_t) = (svd.u.unwrap(), svd.singular_values, svd.v_t.unwrap()); - let ds = Matrix3::from_diagonal(&s.map(|e| ComplexField::from_real(e))); - - prop_assert!(s.iter().all(|e| *e >= 0.0)); - prop_assert!(relative_eq!(m, u * ds * v_t, epsilon = 1.0e-5)); - prop_assert!(u.is_orthogonal(1.0e-5)); - prop_assert!(v_t.is_orthogonal(1.0e-5)); - prop_assert!(is_sorted_descending(s.as_slice())); - } - - #[test] - fn svd_pseudo_inverse(m in dmatrix_($scalar)) { - let svd = m.clone().svd(true, true); - let pinv = svd.pseudo_inverse(1.0e-10).unwrap(); - - if m.nrows() > m.ncols() { - prop_assert!((pinv * m).is_identity(1.0e-5)) - } else { - prop_assert!((m * pinv).is_identity(1.0e-5)) - } - } - - #[test] - fn svd_solve(n in PROPTEST_MATRIX_DIM, nb in PROPTEST_MATRIX_DIM) { - let n = cmp::max(1, cmp::min(n, 10)); - let nb = cmp::min(nb, 10); - let m = DMatrix::<$scalar_type>::new_random(n, n).map(|e| e.0); - - let svd = m.clone().svd(true, true); - - if svd.rank(1.0e-7) == n { - let b1 = DVector::<$scalar_type>::new_random(n).map(|e| e.0); - let b2 = DMatrix::<$scalar_type>::new_random(n, nb).map(|e| e.0); - - let sol1 = svd.solve(&b1, 1.0e-7).unwrap(); - let sol2 = svd.solve(&b2, 1.0e-7).unwrap(); - - let recomp = svd.recompose().unwrap(); - - prop_assert!(relative_eq!(m, recomp, epsilon = 1.0e-6)); - prop_assert!(relative_eq!(&m * &sol1, b1, epsilon = 1.0e-6)); - prop_assert!(relative_eq!(&m * &sol2, b2, epsilon = 1.0e-6)); - } - } - - #[test] - fn svd_polar_decomposition(m in dmatrix_($scalar)) { - let svd = m.clone().svd_unordered(true, true); - let (p, u) = svd.to_polar().unwrap(); - - assert_relative_eq!(m, &p* &u, epsilon = 1.0e-5); - // semi-unitary check - assert!(u.is_orthogonal(1.0e-5) || u.transpose().is_orthogonal(1.0e-5)); - // hermitian check - assert_relative_eq!(p, p.adjoint(), epsilon = 1.0e-5); - - /* - * Same thing, but using the method instead of calling the SVD explicitly. - */ - let (p2, u2) = m.clone().polar(); - assert_eq!(p, p2); - assert_eq!(u, u2); - } - } - } - } - ); - - gen_tests!(complex, complex_f64(), RandComplex); - gen_tests!(f64, PROPTEST_F64, RandScalar); -} - -// Test proposed on the issue #176 of rulinalg. -#[test] -#[rustfmt::skip] -fn svd_singular() { - let m = DMatrix::from_row_slice(24, 24, &[ - 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - -1.0, -1.0, -1.0, -1.0, -1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, -1.0, -1.0, -1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, -1.0, -1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, 0.0, 1.0, 1.0, 1.0, - 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 4.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 4.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0]); - - let svd = m.clone().svd(true, true); - let (u, s, v_t) = (svd.u.unwrap(), svd.singular_values, svd.v_t.unwrap()); - let ds = DMatrix::from_diagonal(&s); - - assert!(s.iter().all(|e| *e >= 0.0)); - assert!(is_sorted_descending(s.as_slice())); - 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); -} - -// Same as the previous test but with one additional row. -#[test] -#[rustfmt::skip] -fn svd_singular_vertical() { - let m = DMatrix::from_row_slice(25, 24, &[ - 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - -1.0, -1.0, -1.0, -1.0, -1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, -1.0, -1.0, -1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, -1.0, -1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, 0.0, 1.0, 1.0, 1.0, - 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 4.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 4.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0]); - - - let svd = m.clone().svd(true, true); - let (u, s, v_t) = (svd.u.unwrap(), svd.singular_values, svd.v_t.unwrap()); - let ds = DMatrix::from_diagonal(&s); - - assert!(s.iter().all(|e| *e >= 0.0)); - assert!(is_sorted_descending(s.as_slice())); - assert_relative_eq!(m, &u * ds * &v_t, epsilon = 1.0e-5); -} - -// Same as the previous test but with one additional column. -#[test] -#[rustfmt::skip] -fn svd_singular_horizontal() { - let m = DMatrix::from_row_slice(24, 25, &[ - 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - -1.0, -1.0, -1.0, -1.0, -1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, -1.0, -1.0, -1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, -1.0, -1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, 0.0, 1.0, 1.0, 1.0, 1.0, - 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 4.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 4.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]); - - let svd = m.clone().svd(true, true); - let (u, s, v_t) = (svd.u.unwrap(), svd.singular_values, svd.v_t.unwrap()); - let ds = DMatrix::from_diagonal(&s); - - assert!(s.iter().all(|e| *e >= 0.0)); - assert!(is_sorted_descending(s.as_slice())); - assert_relative_eq!(m, &u * ds * &v_t, epsilon = 1.0e-5); -} - -#[test] -fn svd_zeros() { - let m = DMatrix::from_element(10, 10, 0.0); - let svd = m.clone().svd(true, true); - assert_eq!(Ok(m), svd.recompose()); -} - -#[test] -fn svd_identity() { - let m = DMatrix::::identity(10, 10); - let svd = m.clone().svd(true, true); - assert_eq!(Ok(m), svd.recompose()); - - let m = DMatrix::::identity(10, 15); - let svd = m.clone().svd(true, true); - assert_eq!(Ok(m), svd.recompose()); - - let m = DMatrix::::identity(15, 10); - let svd = m.clone().svd(true, true); - assert_eq!(Ok(m), svd.recompose()); -} - -#[test] -#[rustfmt::skip] -fn svd_with_delimited_subproblem() { - let mut m = DMatrix::::from_element(10, 10, 0.0); - m[(0, 0)] = 1.0; m[(0, 1)] = 2.0; - m[(1, 1)] = 0.0; m[(1, 2)] = 3.0; - m[(2, 2)] = 4.0; m[(2, 3)] = 5.0; - m[(3, 3)] = 6.0; m[(3, 4)] = 0.0; - m[(4, 4)] = 8.0; m[(3, 5)] = 9.0; - m[(5, 5)] = 10.0; m[(3, 6)] = 11.0; - m[(6, 6)] = 12.0; m[(3, 7)] = 12.0; - m[(7, 7)] = 14.0; m[(3, 8)] = 13.0; - 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); - - // Rectangular versions. - let mut m = DMatrix::::from_element(15, 10, 0.0); - m[(0, 0)] = 1.0; m[(0, 1)] = 2.0; - m[(1, 1)] = 0.0; m[(1, 2)] = 3.0; - m[(2, 2)] = 4.0; m[(2, 3)] = 5.0; - m[(3, 3)] = 6.0; m[(3, 4)] = 0.0; - m[(4, 4)] = 8.0; m[(3, 5)] = 9.0; - m[(5, 5)] = 10.0; m[(3, 6)] = 11.0; - m[(6, 6)] = 12.0; m[(3, 7)] = 12.0; - m[(7, 7)] = 14.0; m[(3, 8)] = 13.0; - 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); - - let svd = m.transpose().svd(true, true); - assert_relative_eq!(m.transpose(), svd.recompose().unwrap(), epsilon = 1.0e-7); -} - -#[test] -#[rustfmt::skip] -fn svd_fail() { - let m = Matrix6::new( - 0.9299319121545955, 0.9955870335651049, 0.8824725266413644, 0.28966880207132295, 0.06102723649846409, 0.9311880746048009, - 0.5938395242304351, 0.8398522876024204, 0.06672831951963198, 0.9941213119963099, 0.9431846038057834, 0.8159885168706427, - 0.9121962883152357, 0.6471119669367571, 0.4823309702814407, 0.6420516076705516, 0.7731203925207113, 0.7424069470756647, - 0.07311092531259344, 0.5579247949052946, 0.14518764691585773, 0.03502980663114896, 0.7991329455957719, 0.4929930019965745, - 0.12293810556077789, 0.6617084679545999, 0.9002240700227326, 0.027153062135304884, 0.3630189466989524, 0.18207502727558866, - 0.843196731466686, 0.08951878746549924, 0.7533450877576973, 0.009558876499740077, 0.9429679490873482, 0.9355764454129878); - - // Check unordered ... - let svd = m.clone().svd_unordered(true, true); - let recomp = svd.recompose().unwrap(); - assert_relative_eq!(m, recomp, epsilon = 1.0e-5); - - // ... and ordered SVD. - let svd = m.clone().svd(true, true); - let recomp = svd.recompose().unwrap(); - assert_relative_eq!(m, recomp, epsilon = 1.0e-5); -} - -#[test] -#[rustfmt::skip] -fn svd3_fail() { - // NOTE: this matrix fails the special case done for 3x3 SVDs. - // It was found on an actual application using SVD as part of the minimization of a - // quadratic error function. - let m = nalgebra::matrix![ - 0.0, 1.0, 0.0; - 0.0, 1.7320508075688772, 0.0; - 0.0, 0.0, 0.0 - ]; - - // Check unordered ... - let svd = m.svd_unordered(true, true); - let recomp = svd.recompose().unwrap(); - assert_relative_eq!(m, recomp, epsilon = 1.0e-5); - - // ... and ordered SVD. - let svd = m.svd(true, true); - let recomp = svd.recompose().unwrap(); - assert_relative_eq!(m, recomp, epsilon = 1.0e-5); -} - -#[test] -fn svd_err() { - let m = DMatrix::from_element(10, 10, 0.0); - let svd = m.clone().svd(false, false); - assert_eq!( - Err("SVD recomposition: U and V^t have not been computed."), - svd.clone().recompose() - ); - assert_eq!( - Err("SVD pseudo inverse: the epsilon must be non-negative."), - svd.clone().pseudo_inverse(-1.0) - ); -} - -#[test] -#[rustfmt::skip] -fn svd_sorted() { - let reference = nalgebra::matrix![ - 1.0, 2.0, 3.0, 4.0; - 5.0, 6.0, 7.0, 8.0; - 9.0, 10.0, 11.0, 12.0 - ]; - - let mut svd = nalgebra::SVD { - singular_values: nalgebra::matrix![1.72261225; 2.54368356e+01; 5.14037515e-16], - u: Some(nalgebra::matrix![ - -0.88915331, -0.20673589, 0.40824829; - -0.25438183, -0.51828874, -0.81649658; - 0.38038964, -0.82984158, 0.40824829 - ]), - v_t: Some(nalgebra::matrix![ - 0.73286619, 0.28984978, -0.15316664, -0.59618305; - -0.40361757, -0.46474413, -0.52587069, -0.58699725; - 0.44527162, -0.83143156, 0.32704826, 0.05911168 - ]), - }; - - assert_relative_eq!( - svd.recompose().expect("valid SVD"), - reference, - epsilon = 1.0e-5 - ); - - svd.sort_by_singular_values(); - - // Ensure successful sorting - assert_relative_eq!(svd.singular_values.x, 2.54368356e+01, epsilon = 1.0e-5); - - // Ensure that the sorted components represent the same decomposition - assert_relative_eq!( - svd.recompose().expect("valid SVD"), - reference, - epsilon = 1.0e-5 - ); -} - -#[test] -// Exercises bug reported in issue #983 of nalgebra (https://github.com/dimforge/nalgebra/issues/983) -fn svd_regression_issue_983() { - let m = nalgebra::dmatrix![ - 10.74785316637712f64, -5.994983325167452, -6.064492921857296; - -4.149751381521569, 20.654504205822462, -4.470436210703133; - -22.772715014220207, -1.4554372570788008, 18.108113992170573 - ] - .transpose(); - let svd1 = m.clone().svd(true, true); - let svd2 = m.clone().svd(false, true); - let svd3 = m.clone().svd(true, false); - let svd4 = m.svd(false, false); - - assert_relative_eq!(svd1.singular_values, svd2.singular_values, epsilon = 1e-9); - assert_relative_eq!(svd1.singular_values, svd3.singular_values, epsilon = 1e-9); - assert_relative_eq!(svd1.singular_values, svd4.singular_values, epsilon = 1e-9); - assert_relative_eq!( - svd1.singular_values, - nalgebra::dvector![3.16188022e+01, 2.23811978e+01, 0.], - epsilon = 1e-6 - ); -} - -#[test] -// Exercises bug reported in issue #1072 of nalgebra (https://github.com/dimforge/nalgebra/issues/1072) -fn svd_regression_issue_1072() { - let x = nalgebra::dmatrix![-6.206610118536945f64, -3.67612186839874; -1.2755730783423473, 6.047238193479124]; - let mut x_svd = x.svd(true, true); - x_svd.singular_values = nalgebra::dvector![1.0, 0.0]; - let y = x_svd.recompose().unwrap(); - let y_svd = y.svd(true, true); - assert_relative_eq!( - y_svd.singular_values, - nalgebra::dvector![1.0, 0.0], - epsilon = 1e-9 - ); -} - -#[test] -// Exercises bug reported in issue #1313 of nalgebra (https://github.com/dimforge/nalgebra/issues/1313) -fn svd_regression_issue_1313() { - let s = 6.123234e-16_f32; - let m = nalgebra::dmatrix![ - 10.0, 0.0, 0.0, 0.0, -10.0, 0.0, 0.0, 0.0; - s, 10.0, 0.0, 10.0, s, 0.0, 0.0, 0.0; - 20.0, -20.0, 0.0, 20.0, 20.0, 0.0, 0.0, 0.0; - ]; - let svd = m.clone().svd(true, true); - let m2 = svd.recompose().unwrap(); - assert_relative_eq!(&m, &m2, epsilon = 1e-5); -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/tridiagonal.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/tridiagonal.rs deleted file mode 100644 index f5e536c73..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/tridiagonal.rs +++ /dev/null @@ -1,56 +0,0 @@ -#![cfg(feature = "proptest-support")] - -macro_rules! gen_tests( - ($module: ident, $scalar: expr) => { - mod $module { - #[allow(unused_imports)] - use crate::core::helper::{RandScalar, RandComplex}; - use crate::proptest::*; - use proptest::{prop_assert, proptest}; - - proptest! { - #[test] - fn symm_tridiagonal(m in dmatrix_($scalar)) { - let m = &m * m.adjoint(); - let tri = m.clone().symmetric_tridiagonalize(); - let recomp = tri.recompose(); - - prop_assert!(relative_eq!(m.lower_triangle(), recomp.lower_triangle(), epsilon = 1.0e-7)); - } - - #[test] - fn symm_tridiagonal_singular(m in dmatrix_($scalar)) { - let mut m = &m * m.adjoint(); - let n = m.nrows(); - m.row_mut(n / 2).fill(na::zero()); - m.column_mut(n / 2).fill(na::zero()); - let tri = m.clone().symmetric_tridiagonalize(); - let recomp = tri.recompose(); - - prop_assert!(relative_eq!(m.lower_triangle(), recomp.lower_triangle(), epsilon = 1.0e-7)); - } - - #[test] - fn symm_tridiagonal_static_square(m in matrix4_($scalar)) { - let m = m.hermitian_part(); - let tri = m.symmetric_tridiagonalize(); - let recomp = tri.recompose(); - - prop_assert!(relative_eq!(m.lower_triangle(), recomp.lower_triangle(), epsilon = 1.0e-7)); - } - - #[test] - fn symm_tridiagonal_static_square_2x2(m in matrix2_($scalar)) { - let m = m.hermitian_part(); - let tri = m.symmetric_tridiagonalize(); - let recomp = tri.recompose(); - - prop_assert!(relative_eq!(m.lower_triangle(), recomp.lower_triangle(), epsilon = 1.0e-7)); - } - } - } - } -); - -gen_tests!(complex, complex_f64()); -gen_tests!(f64, PROPTEST_F64); diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/udu.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/udu.rs deleted file mode 100644 index 80563d0fd..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/linalg/udu.rs +++ /dev/null @@ -1,76 +0,0 @@ -use na::Matrix3; - -#[test] -#[rustfmt::skip] -fn udu_simple() { - let m = Matrix3::new( - 2.0, -1.0, 0.0, - -1.0, 2.0, -1.0, - 0.0, -1.0, 2.0); - - let udu = m.udu().unwrap(); - - // Rebuild - let p = udu.u * udu.d_matrix() * udu.u.transpose(); - - assert!(relative_eq!(m, p, epsilon = 3.0e-16)); -} - -#[test] -#[should_panic] -#[rustfmt::skip] -fn udu_non_sym_panic() { - let m = Matrix3::new( - 2.0, -1.0, 0.0, - 1.0, -2.0, 3.0, - -2.0, 1.0, 0.3); - - let udu = m.udu().unwrap(); - // Rebuild - let p = udu.u * udu.d_matrix() * udu.u.transpose(); - - assert!(relative_eq!(m, p, epsilon = 3.0e-16)); -} - -#[cfg(feature = "proptest-support")] -mod proptest_tests { - #[allow(unused_imports)] - use crate::core::helper::{RandComplex, RandScalar}; - - macro_rules! gen_tests( - ($module: ident, $scalar: expr) => { - mod $module { - #[allow(unused_imports)] - use crate::core::helper::{RandScalar, RandComplex}; - use crate::proptest::*; - use proptest::{prop_assert, proptest}; - - proptest! { - #[test] - fn udu(m in dmatrix_($scalar)) { - let m = &m * m.adjoint(); - - if let Some(udu) = m.clone().udu() { - let p = &udu.u * &udu.d_matrix() * &udu.u.transpose(); - println!("m: {}, p: {}", m, p); - - prop_assert!(relative_eq!(m, p, epsilon = 1.0e-7)); - } - } - - #[test] - fn udu_static(m in matrix4_($scalar)) { - let m = m.hermitian_part(); - - if let Some(udu) = m.udu() { - let p = udu.u * udu.d_matrix() * udu.u.transpose(); - prop_assert!(relative_eq!(m, p, epsilon = 1.0e-7)); - } - } - } - } - } - ); - - gen_tests!(f64, PROPTEST_F64); -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/matrix.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/matrix.rs deleted file mode 100644 index c8ba2b9e7..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/matrix.rs +++ /dev/null @@ -1,311 +0,0 @@ -use crate::macros::assert_eq_and_type; -use nalgebra::{ - DMatrix, DVector, Matrix1x2, Matrix1x3, Matrix1x4, Matrix2, Matrix2x1, Matrix2x3, Matrix2x4, - Matrix3, Matrix3x1, Matrix3x2, Matrix3x4, Matrix4, Matrix4x1, Matrix4x2, Matrix4x3, Point, - Point1, Point2, Point3, Point4, Point5, Point6, SMatrix, SVector, Vector1, Vector2, Vector3, - Vector4, Vector5, Vector6, -}; -use nalgebra_macros::{dmatrix, dvector, matrix, point, vector}; - -// Skip rustfmt because it just makes the test bloated without making it more readable -#[rustfmt::skip] -#[test] -fn matrix_small_dims_exhaustive() { - // 0x0 - assert_eq_and_type!(matrix![], SMatrix::::zeros()); - - // 1xN - assert_eq_and_type!(matrix![1], SMatrix::::new(1)); - assert_eq_and_type!(matrix![1, 2], Matrix1x2::new(1, 2)); - assert_eq_and_type!(matrix![1, 2, 3], Matrix1x3::new(1, 2, 3)); - assert_eq_and_type!(matrix![1, 2, 3, 4], Matrix1x4::new(1, 2, 3, 4)); - - // 2xN - assert_eq_and_type!(matrix![1; 2], Matrix2x1::new(1, 2)); - assert_eq_and_type!(matrix![1, 2; 3, 4], Matrix2::new(1, 2, 3, 4)); - assert_eq_and_type!(matrix![1, 2, 3; 4, 5, 6], Matrix2x3::new(1, 2, 3, 4, 5, 6)); - assert_eq_and_type!(matrix![1, 2, 3, 4; 5, 6, 7, 8], Matrix2x4::new(1, 2, 3, 4, 5, 6, 7, 8)); - - // 3xN - assert_eq_and_type!(matrix![1; 2; 3], Matrix3x1::new(1, 2, 3)); - assert_eq_and_type!(matrix![1, 2; 3, 4; 5, 6], Matrix3x2::new(1, 2, 3, 4, 5, 6)); - assert_eq_and_type!(matrix![1, 2, 3; 4, 5, 6; 7, 8, 9], Matrix3::new(1, 2, 3, 4, 5, 6, 7, 8, 9)); - assert_eq_and_type!(matrix![1, 2, 3, 4; 5, 6, 7, 8; 9, 10, 11, 12], - Matrix3x4::new(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)); - - // 4xN - assert_eq_and_type!(matrix![1; 2; 3; 4], Matrix4x1::new(1, 2, 3, 4)); - assert_eq_and_type!(matrix![1, 2; 3, 4; 5, 6; 7, 8], Matrix4x2::new(1, 2, 3, 4, 5, 6, 7, 8)); - assert_eq_and_type!(matrix![1, 2, 3; 4, 5, 6; 7, 8, 9; 10, 11, 12], - Matrix4x3::new(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)); - assert_eq_and_type!(matrix![1, 2, 3, 4; 5, 6, 7, 8; 9, 10, 11, 12; 13, 14, 15, 16], - Matrix4::new(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)); -} - -#[test] -fn matrix_const_fn() { - // Ensure that matrix! can be used in const contexts - const _: SMatrix = matrix![]; - const _: SMatrix = matrix![1, 2]; - const _: SMatrix = matrix![1, 2, 3; 4, 5, 6]; -} - -// Skip rustfmt because it just makes the test bloated without making it more readable -#[rustfmt::skip] -#[test] -fn dmatrix_small_dims_exhaustive() { - // 0x0 - assert_eq_and_type!(dmatrix![], DMatrix::::zeros(0, 0)); - - // 1xN - assert_eq_and_type!(dmatrix![1], DMatrix::from_row_slice(1, 1, &[1])); - assert_eq_and_type!(dmatrix![1, 2], DMatrix::from_row_slice(1, 2, &[1, 2])); - assert_eq_and_type!(dmatrix![1, 2, 3], DMatrix::from_row_slice(1, 3, &[1, 2, 3])); - assert_eq_and_type!(dmatrix![1, 2, 3, 4], DMatrix::from_row_slice(1, 4, &[1, 2, 3, 4])); - - // 2xN - assert_eq_and_type!(dmatrix![1; 2], DMatrix::from_row_slice(2, 1, &[1, 2])); - assert_eq_and_type!(dmatrix![1, 2; 3, 4], DMatrix::from_row_slice(2, 2, &[1, 2, 3, 4])); - assert_eq_and_type!(dmatrix![1, 2, 3; 4, 5, 6], DMatrix::from_row_slice(2, 3, &[1, 2, 3, 4, 5, 6])); - assert_eq_and_type!(dmatrix![1, 2, 3, 4; 5, 6, 7, 8], DMatrix::from_row_slice(2, 4, &[1, 2, 3, 4, 5, 6, 7, 8])); - - // 3xN - assert_eq_and_type!(dmatrix![1; 2; 3], DMatrix::from_row_slice(3, 1, &[1, 2, 3])); - assert_eq_and_type!(dmatrix![1, 2; 3, 4; 5, 6], DMatrix::from_row_slice(3, 2, &[1, 2, 3, 4, 5, 6])); - assert_eq_and_type!(dmatrix![1, 2, 3; 4, 5, 6; 7, 8, 9], DMatrix::from_row_slice(3, 3, &[1, 2, 3, 4, 5, 6, 7, 8, 9])); - assert_eq_and_type!(dmatrix![1, 2, 3, 4; 5, 6, 7, 8; 9, 10, 11, 12], - DMatrix::from_row_slice(3, 4, &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])); - - // 4xN - assert_eq_and_type!(dmatrix![1; 2; 3; 4], DMatrix::from_row_slice(4, 1, &[1, 2, 3, 4])); - assert_eq_and_type!(dmatrix![1, 2; 3, 4; 5, 6; 7, 8], DMatrix::from_row_slice(4, 2, &[1, 2, 3, 4, 5, 6, 7, 8])); - assert_eq_and_type!(dmatrix![1, 2, 3; 4, 5, 6; 7, 8, 9; 10, 11, 12], - DMatrix::from_row_slice(4, 3, &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])); - assert_eq_and_type!(dmatrix![1, 2, 3, 4; 5, 6, 7, 8; 9, 10, 11, 12; 13, 14, 15, 16], - DMatrix::from_row_slice(4, 4, &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16])); -} - -#[test] -fn matrix_trailing_semi() { - matrix![1, 2;]; - dmatrix![1, 2;]; -} - -// Skip rustfmt because it just makes the test bloated without making it more readable -#[rustfmt::skip] -#[test] -fn vector_small_dims_exhaustive() { - assert_eq_and_type!(vector![], SVector::::zeros()); - assert_eq_and_type!(vector![1], Vector1::::new(1)); - assert_eq_and_type!(vector![1, 2], Vector2::new(1, 2)); - assert_eq_and_type!(vector![1, 2, 3], Vector3::new(1, 2, 3)); - assert_eq_and_type!(vector![1, 2, 3, 4], Vector4::new(1, 2, 3, 4)); - assert_eq_and_type!(vector![1, 2, 3, 4, 5], Vector5::new(1, 2, 3, 4, 5)); - assert_eq_and_type!(vector![1, 2, 3, 4, 5, 6], Vector6::new(1, 2, 3, 4, 5, 6)); -} - -// Skip rustfmt because it just makes the test bloated without making it more readable -#[rustfmt::skip] -#[test] -fn point_small_dims_exhaustive() { - assert_eq_and_type!(point![], Point::::origin()); - assert_eq_and_type!(point![1], Point1::::new(1)); - assert_eq_and_type!(point![1, 2], Point2::new(1, 2)); - assert_eq_and_type!(point![1, 2, 3], Point3::new(1, 2, 3)); - assert_eq_and_type!(point![1, 2, 3, 4], Point4::new(1, 2, 3, 4)); - assert_eq_and_type!(point![1, 2, 3, 4, 5], Point5::new(1, 2, 3, 4, 5)); - assert_eq_and_type!(point![1, 2, 3, 4, 5, 6], Point6::new(1, 2, 3, 4, 5, 6)); -} - -#[test] -fn vector_const_fn() { - // Ensure that vector! can be used in const contexts - const _: SVector = vector![]; - const _: Vector1 = vector![1]; - const _: Vector2 = vector![1, 2]; - const _: Vector6 = vector![1, 2, 3, 4, 5, 6]; -} - -#[test] -fn point_const_fn() { - // Ensure that vector! can be used in const contexts - const _: Point = point![]; - const _: Point1 = point![1]; - const _: Point2 = point![1, 2]; - const _: Point6 = point![1, 2, 3, 4, 5, 6]; -} - -// Skip rustfmt because it just makes the test bloated without making it more readable -#[rustfmt::skip] -#[test] -fn dvector_small_dims_exhaustive() { - assert_eq_and_type!(dvector![], DVector::::zeros(0)); - assert_eq_and_type!(dvector![1], DVector::from_column_slice(&[1])); - assert_eq_and_type!(dvector![1, 2], DVector::from_column_slice(&[1, 2])); - assert_eq_and_type!(dvector![1, 2, 3], DVector::from_column_slice(&[1, 2, 3])); - assert_eq_and_type!(dvector![1, 2, 3, 4], DVector::from_column_slice(&[1, 2, 3, 4])); - assert_eq_and_type!(dvector![1, 2, 3, 4, 5], DVector::from_column_slice(&[1, 2, 3, 4, 5])); - assert_eq_and_type!(dvector![1, 2, 3, 4, 5, 6], DVector::from_column_slice(&[1, 2, 3, 4, 5, 6])); -} - -#[test] -fn vector_trailing_comma() { - vector![1, 2,]; - point![1, 2,]; - dvector![1, 2,]; -} - -#[test] -fn matrix_trybuild_tests() { - let t = trybuild::TestCases::new(); - - // Verify error message when we give a matrix with mismatched dimensions - t.compile_fail("tests/macros/trybuild/matrix_mismatched_dimensions.rs"); -} - -#[test] -fn dmatrix_trybuild_tests() { - let t = trybuild::TestCases::new(); - - // Verify error message when we give a matrix with mismatched dimensions - t.compile_fail("tests/macros/trybuild/dmatrix_mismatched_dimensions.rs"); -} - -#[test] -fn matrix_builtin_types() { - // Check that matrix! compiles for all built-in types - const _: SMatrix = matrix![0, 1; 2, 3]; - const _: SMatrix = matrix![0, 1; 2, 3]; - const _: SMatrix = matrix![0, 1; 2, 3]; - const _: SMatrix = matrix![0, 1; 2, 3]; - const _: SMatrix = matrix![0, 1; 2, 3]; - const _: SMatrix = matrix![0, 1; 2, 3]; - const _: SMatrix = matrix![0, 1; 2, 3]; - const _: SMatrix = matrix![0, 1; 2, 3]; - const _: SMatrix = matrix![0, 1; 2, 3]; - const _: SMatrix = matrix![0, 1; 2, 3]; - const _: SMatrix = matrix![0.0, 1.0; 2.0, 3.0]; - const _: SMatrix = matrix![0.0, 1.0; 2.0, 3.0]; -} - -#[test] -fn vector_builtin_types() { - // Check that vector! compiles for all built-in types - const _: SVector = vector![0, 1, 2, 3]; - const _: SVector = vector![0, 1, 2, 3]; - const _: SVector = vector![0, 1, 2, 3]; - const _: SVector = vector![0, 1, 2, 3]; - const _: SVector = vector![0, 1, 2, 3]; - const _: SVector = vector![0, 1, 2, 3]; - const _: SVector = vector![0, 1, 2, 3]; - const _: SVector = vector![0, 1, 2, 3]; - const _: SVector = vector![0, 1, 2, 3]; - const _: SVector = vector![0, 1, 2, 3]; - const _: SVector = vector![0.0, 1.0, 2.0, 3.0]; - const _: SVector = vector![0.0, 1.0, 2.0, 3.0]; -} - -#[test] -fn dmatrix_builtin_types() { - // Check that dmatrix! compiles for all built-in types - let _: DMatrix = dmatrix![0, 1; 2, 3]; - let _: DMatrix = dmatrix![0, 1; 2, 3]; - let _: DMatrix = dmatrix![0, 1; 2, 3]; - let _: DMatrix = dmatrix![0, 1; 2, 3]; - let _: DMatrix = dmatrix![0, 1; 2, 3]; - let _: DMatrix = dmatrix![0, 1; 2, 3]; - let _: DMatrix = dmatrix![0, 1; 2, 3]; - let _: DMatrix = dmatrix![0, 1; 2, 3]; - let _: DMatrix = dmatrix![0, 1; 2, 3]; - let _: DMatrix = dmatrix![0, 1; 2, 3]; - let _: DMatrix = dmatrix![0.0, 1.0; 2.0, 3.0]; - let _: DMatrix = dmatrix![0.0, 1.0; 2.0, 3.0]; -} - -#[test] -fn point_builtin_types() { - // Check that point! compiles for all built-in types - const _: Point = point![0, 1, 2, 3]; - const _: Point = point![0, 1, 2, 3]; - const _: Point = point![0, 1, 2, 3]; - const _: Point = point![0, 1, 2, 3]; - const _: Point = point![0, 1, 2, 3]; - const _: Point = point![0, 1, 2, 3]; - const _: Point = point![0, 1, 2, 3]; - const _: Point = point![0, 1, 2, 3]; - const _: Point = point![0, 1, 2, 3]; - const _: Point = point![0, 1, 2, 3]; - const _: Point = point![0.0, 1.0, 2.0, 3.0]; - const _: Point = point![0.0, 1.0, 2.0, 3.0]; -} - -#[test] -fn dvector_builtin_types() { - // Check that dvector! compiles for all built-in types - let _: DVector = dvector![0, 1, 2, 3]; - let _: DVector = dvector![0, 1, 2, 3]; - let _: DVector = dvector![0, 1, 2, 3]; - let _: DVector = dvector![0, 1, 2, 3]; - let _: DVector = dvector![0, 1, 2, 3]; - let _: DVector = dvector![0, 1, 2, 3]; - let _: DVector = dvector![0, 1, 2, 3]; - let _: DVector = dvector![0, 1, 2, 3]; - let _: DVector = dvector![0, 1, 2, 3]; - let _: DVector = dvector![0, 1, 2, 3]; - let _: DVector = dvector![0.0, 1.0, 2.0, 3.0]; - let _: DVector = dvector![0.0, 1.0, 2.0, 3.0]; -} - -/// Black box function that's just used for testing macros with function call expressions. -fn f(x: T) -> T { - x -} - -#[rustfmt::skip] -#[test] -fn matrix_arbitrary_expressions() { - // Test that matrix! supports arbitrary expressions for its elements - let a = matrix![1 + 2 , 2 * 3; - 4 * f(5 + 6), 7 - 8 * 9]; - let a_expected = Matrix2::new(1 + 2 , 2 * 3, - 4 * f(5 + 6), 7 - 8 * 9); - assert_eq_and_type!(a, a_expected); -} - -#[rustfmt::skip] -#[test] -fn dmatrix_arbitrary_expressions() { - // Test that dmatrix! supports arbitrary expressions for its elements - let a = dmatrix![1 + 2 , 2 * 3; - 4 * f(5 + 6), 7 - 8 * 9]; - let a_expected = DMatrix::from_row_slice(2, 2, &[1 + 2 , 2 * 3, - 4 * f(5 + 6), 7 - 8 * 9]); - assert_eq_and_type!(a, a_expected); -} - -#[rustfmt::skip] -#[test] -fn vector_arbitrary_expressions() { - // Test that vector! supports arbitrary expressions for its elements - let a = vector![1 + 2, 2 * 3, 4 * f(5 + 6), 7 - 8 * 9]; - let a_expected = Vector4::new(1 + 2, 2 * 3, 4 * f(5 + 6), 7 - 8 * 9); - assert_eq_and_type!(a, a_expected); -} - -#[rustfmt::skip] -#[test] -fn point_arbitrary_expressions() { - // Test that point! supports arbitrary expressions for its elements - let a = point![1 + 2, 2 * 3, 4 * f(5 + 6), 7 - 8 * 9]; - let a_expected = Point4::new(1 + 2, 2 * 3, 4 * f(5 + 6), 7 - 8 * 9); - assert_eq_and_type!(a, a_expected); -} - -#[rustfmt::skip] -#[test] -fn dvector_arbitrary_expressions() { - // Test that dvector! supports arbitrary expressions for its elements - let a = dvector![1 + 2, 2 * 3, 4 * f(5 + 6), 7 - 8 * 9]; - let a_expected = DVector::from_column_slice(&[1 + 2, 2 * 3, 4 * f(5 + 6), 7 - 8 * 9]); - assert_eq_and_type!(a, a_expected); -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/mod.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/mod.rs deleted file mode 100644 index 31a9f0cad..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/mod.rs +++ /dev/null @@ -1,19 +0,0 @@ -mod matrix; -mod stack; - -/// Wrapper for `assert_eq` that also asserts that the types are the same -// For some reason, rustfmt totally messes up the formatting of this macro. -// For now we skip, but once https://github.com/rust-lang/rustfmt/issues/6131 -// is fixed, we can perhaps remove the skip attribute -#[rustfmt::skip] -macro_rules! assert_eq_and_type { - ($left:expr, $right:expr $(,)?) => { - { - fn check_statically_same_type(_: &T, _: &T) {} - check_statically_same_type(&$left, &$right); - } - assert_eq!($left, $right); - }; -} - -pub(crate) use assert_eq_and_type; diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/stack.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/stack.rs deleted file mode 100644 index 1c996d93d..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/stack.rs +++ /dev/null @@ -1,427 +0,0 @@ -use crate::macros::assert_eq_and_type; -use cool_asserts::assert_panics; -use na::VecStorage; -use nalgebra::dimension::U1; -use nalgebra::{dmatrix, matrix, stack}; -use nalgebra::{ - DMatrix, DMatrixView, Dyn, Matrix, Matrix2, Matrix4, OMatrix, SMatrix, SMatrixView, - SMatrixViewMut, Scalar, U2, -}; -use nalgebra_macros::vector; -use num_traits::Zero; - -/// Simple implementation that stacks dynamic matrices. -/// -/// Used for verifying results of the stack! macro. `None` entries are considered to represent -/// a zero block. -fn stack_dyn(blocks: DMatrix>>) -> DMatrix { - let row_counts: Vec = blocks - .row_iter() - .map(|block_row| { - block_row - .iter() - .map(|block_or_implicit_zero| { - block_or_implicit_zero.as_ref().map(|block| block.nrows()) - }) - .reduce(|nrows1, nrows2| match (nrows1, nrows2) { - (Some(_), None) => nrows1, - (None, Some(_)) => nrows2, - (None, None) => None, - (Some(nrows1), Some(nrows2)) if nrows1 == nrows2 => Some(nrows1), - _ => panic!("Number of rows must be consistent in each block row"), - }) - .unwrap_or(Some(0)) - .expect("Each block row must have at least one entry which is not a zero literal") - }) - .collect(); - let col_counts: Vec = blocks - .column_iter() - .map(|block_col| { - block_col - .iter() - .map(|block_or_implicit_zero| { - block_or_implicit_zero.as_ref().map(|block| block.ncols()) - }) - .reduce(|ncols1, ncols2| match (ncols1, ncols2) { - (Some(_), None) => ncols1, - (None, Some(_)) => ncols2, - (None, None) => None, - (Some(ncols1), Some(ncols2)) if ncols1 == ncols2 => Some(ncols1), - _ => panic!("Number of columns must be consistent in each block column"), - }) - .unwrap_or(Some(0)) - .expect( - "Each block column must have at least one entry which is not a zero literal", - ) - }) - .collect(); - - let nrows_total = row_counts.iter().sum(); - let ncols_total = col_counts.iter().sum(); - let mut output = DMatrix::zeros(nrows_total, ncols_total); - - let mut col_offset = 0; - for j in 0..blocks.ncols() { - let mut row_offset = 0; - for i in 0..blocks.nrows() { - if let Some(input_ij) = &blocks[(i, j)] { - let (block_nrows, block_ncols) = input_ij.shape(); - output - .view_mut((row_offset, col_offset), (block_nrows, block_ncols)) - .copy_from(&input_ij); - } - row_offset += row_counts[i]; - } - col_offset += col_counts[j]; - } - - output -} - -macro_rules! stack_dyn_convert_to_dmatrix_option { - (0) => { - None - }; - ($entry:expr) => { - Some($entry.as_view::().clone_owned()) - }; -} - -/// Helper macro that compares the result of stack! with a simplified implementation that -/// works only with heap-allocated data. -/// -/// This implementation is essentially radically different to the implementation in stack!, -/// so if they both match, then it's a good sign that the stack! impl is correct. -macro_rules! verify_stack { - ($matrix_type:ty ; [$($($entry:expr),*);*]) => { - { - // Our input has the same syntax as the stack! macro (and matrix! macro, for that matter) - let stack_result: $matrix_type = stack![$($($entry),*);*]; - // Use the dmatrix! macro to nest matrices into each other - let dyn_result = stack_dyn( - dmatrix![$($(stack_dyn_convert_to_dmatrix_option!($entry)),*);*] - ); - // println!("{}", stack_result); - // println!("{}", dyn_result); - assert_eq!(stack_result, dyn_result); - } - } -} - -#[test] -fn stack_simple() { - let m = stack![ - Matrix2::::identity(), 0; - 0, &Matrix2::identity(); - ]; - - assert_eq_and_type!(m, Matrix4::identity()); -} - -#[test] -fn stack_diag() { - let m = stack![ - 0, matrix![1, 2; 3, 4;]; - matrix![5, 6; 7, 8;], 0; - ]; - - let res = matrix![ - 0, 0, 1, 2; - 0, 0, 3, 4; - 5, 6, 0, 0; - 7, 8, 0, 0; - ]; - - assert_eq_and_type!(m, res); -} - -#[test] -fn stack_dynamic() { - let m = stack![ - matrix![ 1, 2; 3, 4; ], 0; - 0, dmatrix![7, 8, 9; 10, 11, 12; ]; - ]; - - let res = dmatrix![ - 1, 2, 0, 0, 0; - 3, 4, 0, 0, 0; - 0, 0, 7, 8, 9; - 0, 0, 10, 11, 12; - ]; - - assert_eq_and_type!(m, res); -} - -#[test] -fn stack_nested() { - let m = stack![ - stack![ matrix![1, 2; 3, 4;]; matrix![5, 6;]], - stack![ matrix![7;9;10;], matrix![11; 12; 13;] ]; - ]; - - let res = matrix![ - 1, 2, 7, 11; - 3, 4, 9, 12; - 5, 6, 10, 13; - ]; - - assert_eq_and_type!(m, res); -} - -#[test] -fn stack_single() { - let a = matrix![1, 2; 3, 4]; - let b = stack![a]; - - assert_eq_and_type!(a, b); -} - -#[test] -fn stack_single_row() { - let a = matrix![1, 2; 3, 4]; - let m = stack![a, a]; - - let res = matrix![ - 1, 2, 1, 2; - 3, 4, 3, 4; - ]; - - assert_eq_and_type!(m, res); -} - -#[test] -fn stack_single_col() { - let a = matrix![1, 2; 3, 4]; - let m = stack![a; a]; - - let res = matrix![ - 1, 2; - 3, 4; - 1, 2; - 3, 4; - ]; - - assert_eq_and_type!(m, res); -} - -#[test] -#[rustfmt::skip] -fn stack_expr() { - let a = matrix![1, 2; 3, 4]; - let b = matrix![5, 6; 7, 8]; - let m = stack![a + b; 2i32 * b - a]; - - let res = matrix![ - 6, 8; - 10, 12; - 9, 10; - 11, 12; - ]; - - assert_eq_and_type!(m, res); -} - -#[test] -fn stack_edge_cases() { - { - // Empty stack should return zero matrix with specified type - let _: SMatrix = stack![]; - let _: SMatrix = stack![]; - } - - { - // Case suggested by @tpdickso: https://github.com/dimforge/nalgebra/pull/1080#discussion_r1435871752 - let a = matrix![1, 2; - 3, 4]; - let b = DMatrix::from_data(VecStorage::new(Dyn(2), Dyn(0), vec![])); - assert_eq!( - stack![a, 0; - 0, b], - matrix![1, 2; - 3, 4; - 0, 0; - 0, 0] - ); - } -} - -#[rustfmt::skip] -#[test] -fn stack_many_tests() { - // s prefix means static, d prefix means dynamic - // Static matrices - let s_0x0: SMatrix = matrix![]; - let s_0x1: SMatrix = Matrix::default(); - let s_1x0: SMatrix = Matrix::default(); - let s_1x1: SMatrix = matrix![1]; - let s_2x2: SMatrix = matrix![6, 7; 8, 9]; - let s_2x3: SMatrix = matrix![16, 17, 18; 19, 20, 21]; - let s_3x3: SMatrix = matrix![28, 29, 30; 31, 32, 33; 34, 35, 36]; - - // Dynamic matrices - let d_0x0: DMatrix = dmatrix![]; - let d_1x2: DMatrix = dmatrix![9, 10]; - let d_2x2: DMatrix = dmatrix![5, 6; 7, 8]; - let d_4x4: DMatrix = dmatrix![10, 11, 12, 13; 14, 15, 16, 17; 18, 19, 20, 21; 22, 23, 24, 25]; - - // Check for weirdness with matrices that have zero row/cols - verify_stack!(SMatrix<_, 0, 0>; [s_0x0]); - verify_stack!(SMatrix<_, 0, 1>; [s_0x1]); - verify_stack!(SMatrix<_, 1, 0>; [s_1x0]); - verify_stack!(SMatrix<_, 0, 0>; [s_0x0; s_0x0]); - verify_stack!(SMatrix<_, 0, 0>; [s_0x0, s_0x0; s_0x0, s_0x0]); - verify_stack!(SMatrix<_, 0, 2>; [s_0x1, s_0x1]); - verify_stack!(SMatrix<_, 2, 0>; [s_1x0; s_1x0]); - verify_stack!(SMatrix<_, 1, 0>; [s_1x0, s_1x0]); - verify_stack!(DMatrix<_>; [d_0x0]); - - // Horizontal stacking - verify_stack!(SMatrix<_, 1, 2>; [s_1x1, s_1x1]); - verify_stack!(SMatrix<_, 2, 4>; [s_2x2, s_2x2]); - verify_stack!(DMatrix<_>; [d_1x2, d_1x2]); - - // Vertical stacking - verify_stack!(SMatrix<_, 2, 1>; [s_1x1; s_1x1]); - verify_stack!(SMatrix<_, 4, 2>; [s_2x2; s_2x2]); - verify_stack!(DMatrix<_>; [d_2x2; d_2x2]); - - // Mix static and dynamic matrices - verify_stack!(OMatrix<_, U2, Dyn>; [s_2x2, d_2x2]); - verify_stack!(OMatrix<_, Dyn, U2>; [s_2x2; d_1x2]); - - // Stack more than two matrices - verify_stack!(SMatrix<_, 1, 3>; [s_1x1, s_1x1, s_1x1]); - verify_stack!(DMatrix<_>; [d_1x2, d_1x2, d_1x2]); - - // Slightly larger dims - verify_stack!(SMatrix<_, 3, 6>; [s_3x3, s_3x3]); - verify_stack!(DMatrix<_>; [d_4x4; d_4x4]); - verify_stack!(SMatrix<_, 4, 7>; [s_2x2, s_2x3, d_2x2; - d_2x2, s_2x3, s_2x2]); - - // Mix of references and owned - verify_stack!(OMatrix<_, Dyn, U2>; [&s_2x2; &d_1x2]); - verify_stack!(SMatrix<_, 4, 7>; [ s_2x2, &s_2x3, d_2x2; - &d_2x2, s_2x3, &s_2x2]); - - // Views - let s_2x2_v: SMatrixView<_, 2, 2> = s_2x2.as_view(); - let s_2x3_v: SMatrixView<_, 2, 3> = s_2x3.as_view(); - let d_2x2_v: DMatrixView<_> = d_2x2.as_view(); - let mut s_2x2_vm = s_2x2.clone(); - let s_2x2_vm: SMatrixViewMut<_, 2, 2> = s_2x2_vm.as_view_mut(); - let mut s_2x3_vm = s_2x3.clone(); - let s_2x3_vm: SMatrixViewMut<_, 2, 3> = s_2x3_vm.as_view_mut(); - verify_stack!(SMatrix<_, 4, 7>; [ s_2x2_vm, &s_2x3_vm, d_2x2_v; - &d_2x2_v, s_2x3_v, &s_2x2_v]); - - // Expressions - let matrix_fn = |matrix: &DMatrix<_>| matrix.map(|x_ij| x_ij * 3); - verify_stack!(SMatrix<_, 2, 5>; [ 2 * s_2x2 - 3 * &d_2x2, s_2x3 + 2 * s_2x3]); - verify_stack!(DMatrix<_>; [ 2 * matrix_fn(&d_2x2) ]); - verify_stack!(SMatrix<_, 2, 5>; [ (|matrix| 4 * matrix)(s_2x2), s_2x3 ]); -} - -#[test] -fn stack_trybuild_tests() { - let t = trybuild::TestCases::new(); - - // Verify error message when a row or column only contains a zero entry - t.compile_fail("tests/macros/trybuild/stack_empty_row.rs"); - t.compile_fail("tests/macros/trybuild/stack_empty_col.rs"); - t.compile_fail("tests/macros/trybuild/stack_incompatible_block_dimensions.rs"); - t.compile_fail("tests/macros/trybuild/stack_incompatible_block_dimensions2.rs"); -} - -#[test] -fn stack_mismatched_dimensions_runtime_panics() { - // s prefix denotes static, d dynamic - let s_2x2 = matrix![1, 2; 3, 4]; - let d_2x3 = dmatrix![5, 6, 7; 8, 9, 10]; - let d_1x2 = dmatrix![11, 12]; - let d_1x3 = dmatrix![13, 14, 15]; - - assert_panics!( - stack![s_2x2, d_1x2], - includes("All blocks in block row 0 must have the same number of rows") - ); - - assert_panics!( - stack![s_2x2; d_2x3], - includes("All blocks in block column 0 must have the same number of columns") - ); - - assert_panics!( - stack![s_2x2, s_2x2; d_1x2, d_2x3], - includes("All blocks in block row 1 must have the same number of rows") - ); - - assert_panics!( - stack![s_2x2, s_2x2; d_1x2, d_1x3], - includes("All blocks in block column 1 must have the same number of columns") - ); - - assert_panics!( - { - // Edge case suggested by @tpdickso: https://github.com/dimforge/nalgebra/pull/1080#discussion_r1435871752 - let d_3x0 = DMatrix::from_data(VecStorage::new(Dyn(3), Dyn(0), Vec::::new())); - stack![s_2x2, d_3x0] - }, - includes("All blocks in block row 0 must have the same number of rows") - ); -} - -#[test] -fn stack_test_builtin_types() { - // Other than T: Zero, there's nothing type-specific in the logic for stack! - // These tests are just sanity tests, to make sure it works with the common built-in types - let a = matrix![1, 2; 3, 4]; - let b = vector![5, 6]; - let c = matrix![7, 8]; - - let expected = matrix![ 1, 2, 5; - 3, 4, 6; - 7, 8, 0 ]; - - macro_rules! check_builtin { - ($T:ty) => {{ - // Cannot use .cast::<$T> because we cannot convert between unsigned and signed - let stacked = stack![a.map(|a_ij| a_ij as $T), b.map(|b_ij| b_ij as $T); - c.map(|c_ij| c_ij as $T), 0]; - assert_eq!(stacked, expected.map(|e_ij| e_ij as $T)); - }} - } - - check_builtin!(i8); - check_builtin!(i16); - check_builtin!(i32); - check_builtin!(i64); - check_builtin!(i128); - check_builtin!(u8); - check_builtin!(u16); - check_builtin!(u32); - check_builtin!(u64); - check_builtin!(u128); - check_builtin!(f32); - check_builtin!(f64); -} - -#[test] -fn stack_test_complex() { - use num_complex::Complex as C; - type C32 = C; - let a = matrix![C::new(1.0, 1.0), C::new(2.0, 2.0); C::new(3.0, 3.0), C::new(4.0, 4.0)]; - let b = vector![C::new(5.0, 5.0), C::new(6.0, 6.0)]; - let c = matrix![C::new(7.0, 7.0), C::new(8.0, 8.0)]; - - let expected = matrix![ 1, 2, 5; - 3, 4, 6; - 7, 8, 0 ] - .map(|x| C::new(x as f64, x as f64)); - - assert_eq!(stack![a, b; c, 0], expected); - assert_eq!( - stack![a.cast::(), b.cast::(); c.cast::(), 0], - expected.cast::() - ); -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/trybuild/dmatrix_mismatched_dimensions.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/trybuild/dmatrix_mismatched_dimensions.rs deleted file mode 100644 index b2e217eb2..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/trybuild/dmatrix_mismatched_dimensions.rs +++ /dev/null @@ -1,6 +0,0 @@ -use nalgebra::dmatrix; - -fn main() { - dmatrix![1, 2, 3; - 4, 5]; -} \ No newline at end of file diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/trybuild/dmatrix_mismatched_dimensions.stderr b/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/trybuild/dmatrix_mismatched_dimensions.stderr deleted file mode 100644 index e2e8d31cb..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/trybuild/dmatrix_mismatched_dimensions.stderr +++ /dev/null @@ -1,5 +0,0 @@ -error: Unexpected number of entries in row 1. Expected 3, found 2 entries. - --> tests/macros/trybuild/dmatrix_mismatched_dimensions.rs:5:13 - | -5 | 4, 5]; - | ^ diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/trybuild/matrix_mismatched_dimensions.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/trybuild/matrix_mismatched_dimensions.rs deleted file mode 100644 index 2e3b7bac9..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/trybuild/matrix_mismatched_dimensions.rs +++ /dev/null @@ -1,6 +0,0 @@ -use nalgebra::matrix; - -fn main() { - matrix![1, 2, 3; - 4, 5]; -} \ No newline at end of file diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/trybuild/matrix_mismatched_dimensions.stderr b/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/trybuild/matrix_mismatched_dimensions.stderr deleted file mode 100644 index 557cb99d1..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/trybuild/matrix_mismatched_dimensions.stderr +++ /dev/null @@ -1,5 +0,0 @@ -error: Unexpected number of entries in row 1. Expected 3, found 2 entries. - --> tests/macros/trybuild/matrix_mismatched_dimensions.rs:5:13 - | -5 | 4, 5]; - | ^ diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/trybuild/stack_empty_col.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/trybuild/stack_empty_col.rs deleted file mode 100644 index 9ba902b40..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/trybuild/stack_empty_col.rs +++ /dev/null @@ -1,6 +0,0 @@ -use nalgebra::{matrix, stack}; - -fn main() { - let m = matrix![1, 2; 3, 4]; - stack![0, m]; -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/trybuild/stack_empty_col.stderr b/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/trybuild/stack_empty_col.stderr deleted file mode 100644 index f712b7ac2..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/trybuild/stack_empty_col.stderr +++ /dev/null @@ -1,7 +0,0 @@ -error: Block column 0 cannot consist entirely of implicit zero blocks. - --> tests/macros/trybuild/stack_empty_col.rs:5:5 - | -5 | stack![0, m]; - | ^^^^^^^^^^^^ - | - = note: this error originates in the macro `stack` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/trybuild/stack_empty_row.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/trybuild/stack_empty_row.rs deleted file mode 100644 index 12d6fb4c3..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/trybuild/stack_empty_row.rs +++ /dev/null @@ -1,6 +0,0 @@ -use nalgebra::{matrix, stack}; - -fn main() { - let m = matrix![1, 2; 3, 4]; - stack![0; m]; -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/trybuild/stack_empty_row.stderr b/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/trybuild/stack_empty_row.stderr deleted file mode 100644 index 08687b9fc..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/trybuild/stack_empty_row.stderr +++ /dev/null @@ -1,7 +0,0 @@ -error: Block row 0 cannot consist entirely of implicit zero blocks. - --> tests/macros/trybuild/stack_empty_row.rs:5:5 - | -5 | stack![0; m]; - | ^^^^^^^^^^^^ - | - = note: this error originates in the macro `stack` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/trybuild/stack_incompatible_block_dimensions.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/trybuild/stack_incompatible_block_dimensions.rs deleted file mode 100644 index 59f714bd8..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/trybuild/stack_incompatible_block_dimensions.rs +++ /dev/null @@ -1,13 +0,0 @@ -use nalgebra::{matrix, stack}; - -fn main() { - // Use multi-letter names for checking that the reported span comes out correctly - let a11 = matrix![1, 2; - 3, 4]; - let a12 = matrix![5, 6; - 7, 8]; - let a21 = matrix![9, 10, 11]; - let a22 = matrix![12, 13]; - stack![a11, a12; - a21, a22]; -} \ No newline at end of file diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/trybuild/stack_incompatible_block_dimensions.stderr b/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/trybuild/stack_incompatible_block_dimensions.stderr deleted file mode 100644 index f843daa56..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/trybuild/stack_incompatible_block_dimensions.stderr +++ /dev/null @@ -1,37 +0,0 @@ -error[E0277]: the trait bound `ShapeConstraint: SameNumberOfColumns, Const<3>>` is not satisfied - --> tests/macros/trybuild/stack_incompatible_block_dimensions.rs:12:12 - | -12 | a21, a22]; - | ^^^ the trait `SameNumberOfColumns, Const<3>>` is not implemented for `ShapeConstraint` - | - = help: the following other types implement trait `SameNumberOfColumns`: - > - > - > - = note: this error originates in the macro `stack` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0282]: type annotations needed - --> tests/macros/trybuild/stack_incompatible_block_dimensions.rs:11:5 - | -11 | / stack![a11, a12; -12 | | a21, a22]; - | |____________________^ cannot infer type - | - = note: this error originates in the macro `stack` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0599]: no method named `generic_view_mut` found for struct `Matrix<_, Const<3>, _, _>` in the current scope - --> tests/macros/trybuild/stack_incompatible_block_dimensions.rs:11:5 - | -11 | stack![a11, a12; - | _____^ -12 | | a21, a22]; - | |____________________^ method not found in `Matrix<_, Const<3>, _, _>` - | - ::: src/base/matrix_view.rs - | - | generic_slice_mut => generic_view_mut, - | ---------------- the method is available for `Matrix<_, Const<3>, _, _>` here - | - = note: the method was found for - - `Matrix` - = note: this error originates in the macro `stack` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/trybuild/stack_incompatible_block_dimensions2.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/trybuild/stack_incompatible_block_dimensions2.rs deleted file mode 100644 index f1a7b233a..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/trybuild/stack_incompatible_block_dimensions2.rs +++ /dev/null @@ -1,14 +0,0 @@ -use nalgebra::{matrix, stack}; - -fn main() { - // Use multi-letter names for checking that the reported span comes out correctly - let a11 = matrix![1, 2; - 3, 4]; - let a12 = matrix![5, 6; - 7, 8]; - let a21 = matrix![9, 10]; - let a22 = matrix![11, 12; - 13, 14]; - stack![a11, a12; - a21, a22]; -} \ No newline at end of file diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/trybuild/stack_incompatible_block_dimensions2.stderr b/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/trybuild/stack_incompatible_block_dimensions2.stderr deleted file mode 100644 index f453914e1..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/macros/trybuild/stack_incompatible_block_dimensions2.stderr +++ /dev/null @@ -1,37 +0,0 @@ -error[E0277]: the trait bound `ShapeConstraint: SameNumberOfRows, Const<2>>` is not satisfied - --> tests/macros/trybuild/stack_incompatible_block_dimensions2.rs:13:17 - | -13 | a21, a22]; - | ^^^ the trait `SameNumberOfRows, Const<2>>` is not implemented for `ShapeConstraint` - | - = help: the following other types implement trait `SameNumberOfRows`: - > - > - > - = note: this error originates in the macro `stack` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0282]: type annotations needed - --> tests/macros/trybuild/stack_incompatible_block_dimensions2.rs:12:5 - | -12 | / stack![a11, a12; -13 | | a21, a22]; - | |____________________^ cannot infer type - | - = note: this error originates in the macro `stack` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0599]: no method named `generic_view_mut` found for struct `Matrix<_, _, Const<4>, _>` in the current scope - --> tests/macros/trybuild/stack_incompatible_block_dimensions2.rs:12:5 - | -12 | stack![a11, a12; - | _____^ -13 | | a21, a22]; - | |____________________^ method not found in `Matrix<_, _, Const<4>, _>` - | - ::: src/base/matrix_view.rs - | - | generic_slice_mut => generic_view_mut, - | ---------------- the method is available for `Matrix<_, _, Const<4>, _>` here - | - = note: the method was found for - - `Matrix` - = note: this error originates in the macro `stack` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/proptest/mod.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/proptest/mod.rs deleted file mode 100644 index 3f9f12c98..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/proptest/mod.rs +++ /dev/null @@ -1,370 +0,0 @@ -//! Tests for proptest-related functionality. - -#![allow(dead_code)] - -use nalgebra::allocator::Allocator; -use nalgebra::base::dimension::*; -use nalgebra::proptest::{DimRange, MatrixStrategy}; -use nalgebra::{ - DMatrix, DVector, DefaultAllocator, Dim, DualQuaternion, Isometry2, Isometry3, Matrix3, - OMatrix, Point2, Point3, Quaternion, Rotation2, Rotation3, Scalar, Similarity3, Translation2, - Translation3, UnitComplex, UnitDualQuaternion, UnitQuaternion, Vector3, U3, U4, -}; -use num_complex::Complex; -use proptest::prelude::*; -use proptest::strategy::{Strategy, ValueTree}; -use proptest::test_runner::TestRunner; -use std::ops::RangeInclusive; - -pub const PROPTEST_MATRIX_DIM: RangeInclusive = 1..=20; -pub const PROPTEST_F64: RangeInclusive = -100.0..=100.0; - -pub use nalgebra::proptest::{matrix, vector}; - -pub fn point2() -> impl Strategy> { - vector2().prop_map(|v| Point2::from(v)) -} - -pub fn point3() -> impl Strategy> { - vector3().prop_map(|v| Point3::from(v)) -} - -pub fn translation2() -> impl Strategy> { - vector2().prop_map(|v| Translation2::from(v)) -} - -pub fn translation3() -> impl Strategy> { - vector3().prop_map(|v| Translation3::from(v)) -} - -pub fn rotation2() -> impl Strategy> { - PROPTEST_F64.prop_map(|v| Rotation2::new(v)) -} - -pub fn rotation3() -> impl Strategy> { - vector3().prop_map(|v| Rotation3::new(v)) -} - -pub fn unit_complex() -> impl Strategy> { - PROPTEST_F64.prop_map(|v| UnitComplex::new(v)) -} - -pub fn isometry2() -> impl Strategy> { - vector3().prop_map(|v| Isometry2::new(v.xy(), v.z)) -} - -pub fn isometry3() -> impl Strategy> { - vector6().prop_map(|v| Isometry3::new(v.xyz(), Vector3::new(v.w, v.a, v.b))) -} - -// pub fn similarity2() -> impl Strategy> { -// vector4().prop_map(|v| Similarity2::new(v.xy(), v.z, v.w)) -// } - -pub fn similarity3() -> impl Strategy> { - vector(PROPTEST_F64, Const::<7>) - .prop_map(|v| Similarity3::new(v.xyz(), Vector3::new(v[3], v[4], v[5]), v[6])) -} - -pub fn unit_dual_quaternion() -> impl Strategy> { - isometry3().prop_map(|iso| UnitDualQuaternion::from_isometry(&iso)) -} - -pub fn dual_quaternion() -> impl Strategy> { - vector(PROPTEST_F64, Const::<8>).prop_map(|v| { - DualQuaternion::from_real_and_dual( - Quaternion::new(v[0], v[1], v[2], v[3]), - Quaternion::new(v[4], v[5], v[6], v[7]), - ) - }) -} - -pub fn quaternion() -> impl Strategy> { - vector4().prop_map(|v| Quaternion::from(v)) -} - -pub fn unit_quaternion() -> impl Strategy> { - vector3().prop_map(|v| UnitQuaternion::new(v)) -} - -pub fn complex_f64() -> impl Strategy> + Clone { - vector(PROPTEST_F64, Const::<2>).prop_map(|v| Complex::new(v.x, v.y)) -} - -pub fn dmatrix() -> impl Strategy> { - matrix(PROPTEST_F64, PROPTEST_MATRIX_DIM, PROPTEST_MATRIX_DIM) -} - -pub fn dvector() -> impl Strategy> { - vector(PROPTEST_F64, PROPTEST_MATRIX_DIM) -} - -pub fn dmatrix_( - scalar_strategy: ScalarStrategy, -) -> impl Strategy> -where - ScalarStrategy: Strategy + Clone + 'static, - ScalarStrategy::Value: Scalar, - DefaultAllocator: Allocator, -{ - matrix(scalar_strategy, PROPTEST_MATRIX_DIM, PROPTEST_MATRIX_DIM) -} - -// pub fn dvector_(range: RangeInclusive) -> impl Strategy> -// where -// RangeInclusive: Strategy, -// T: Scalar + PartialEq + Copy, -// DefaultAllocator: Allocator, -// { -// vector(range, PROPTEST_MATRIX_DIM) -// } - -macro_rules! define_strategies( - ($($strategy_: ident $strategy: ident<$nrows: literal, $ncols: literal>),*) => {$( - pub fn $strategy() -> impl Strategy, Const<$ncols>>> { - matrix(PROPTEST_F64, Const::<$nrows>, Const::<$ncols>) - } - - pub fn $strategy_(scalar_strategy: ScalarStrategy) -> impl Strategy, Const<$ncols>>> - where - ScalarStrategy: Strategy + Clone + 'static, - ScalarStrategy::Value: Scalar, { - matrix(scalar_strategy, Const::<$nrows>, Const::<$ncols>) - } - )*} -); - -define_strategies!( - matrix1_ matrix1<1, 1>, - matrix2_ matrix2<2, 2>, - matrix3_ matrix3<3, 3>, - matrix4_ matrix4<4, 4>, - matrix5_ matrix5<5, 5>, - matrix6_ matrix6<6, 6>, - - matrix5x2_ matrix5x2<5, 2>, - matrix2x5_ matrix2x5<2, 5>, - matrix5x3_ matrix5x3<5, 3>, - matrix3x5_ matrix3x5<3, 5>, - matrix5x4_ matrix5x4<5, 4>, - matrix4x5_ matrix4x5<4, 5>, - - vector1_ vector1<1, 1>, - vector2_ vector2<2, 1>, - vector3_ vector3<3, 1>, - vector4_ vector4<4, 1>, - vector5_ vector5<5, 1>, - vector6_ vector6<6, 1> -); - -/// Generate a proptest that tests that all matrices generated with the -/// provided rows and columns conform to the constraints defined by the -/// input. -macro_rules! generate_matrix_sanity_test { - ($test_name:ident, $rows:expr, $cols:expr) => { - proptest! { - #[test] - fn $test_name(a in matrix(-5 ..= 5i32, $rows, $cols)) { - // let a: OMatrix<_, $rows, $cols> = a; - let rows_range = DimRange::from($rows); - let cols_range = DimRange::from($cols); - prop_assert!(a.nrows() >= rows_range.lower_bound().value() - && a.nrows() <= rows_range.upper_bound().value()); - prop_assert!(a.ncols() >= cols_range.lower_bound().value() - && a.ncols() <= cols_range.upper_bound().value()); - prop_assert!(a.iter().all(|x_ij| *x_ij >= -5 && *x_ij <= 5)); - } - } - }; -} - -// Test all fixed-size matrices with row/col dimensions up to 3 -generate_matrix_sanity_test!(test_matrix_u0_u0, Const::<0>, Const::<0>); -generate_matrix_sanity_test!(test_matrix_u1_u0, Const::<1>, Const::<0>); -generate_matrix_sanity_test!(test_matrix_u0_u1, Const::<0>, Const::<1>); -generate_matrix_sanity_test!(test_matrix_u1_u1, Const::<1>, Const::<1>); -generate_matrix_sanity_test!(test_matrix_u2_u1, Const::<2>, Const::<1>); -generate_matrix_sanity_test!(test_matrix_u1_u2, Const::<1>, Const::<2>); -generate_matrix_sanity_test!(test_matrix_u2_u2, Const::<2>, Const::<2>); -generate_matrix_sanity_test!(test_matrix_u3_u2, Const::<3>, Const::<2>); -generate_matrix_sanity_test!(test_matrix_u2_u3, Const::<2>, Const::<3>); -generate_matrix_sanity_test!(test_matrix_u3_u3, Const::<3>, Const::<3>); - -// Similarly test all heap-allocated but fixed dim ranges -generate_matrix_sanity_test!(test_matrix_0_0, 0, 0); -generate_matrix_sanity_test!(test_matrix_0_1, 0, 1); -generate_matrix_sanity_test!(test_matrix_1_0, 1, 0); -generate_matrix_sanity_test!(test_matrix_1_1, 1, 1); -generate_matrix_sanity_test!(test_matrix_2_1, 2, 1); -generate_matrix_sanity_test!(test_matrix_1_2, 1, 2); -generate_matrix_sanity_test!(test_matrix_2_2, 2, 2); -generate_matrix_sanity_test!(test_matrix_3_2, 3, 2); -generate_matrix_sanity_test!(test_matrix_2_3, 2, 3); -generate_matrix_sanity_test!(test_matrix_3_3, 3, 3); - -// Test arbitrary inputs -generate_matrix_sanity_test!(test_matrix_input_1, Const::<5>, 1..=5); -generate_matrix_sanity_test!(test_matrix_input_2, 3..=4, 1..=5); -generate_matrix_sanity_test!(test_matrix_input_3, 1..=2, Const::<3>); -generate_matrix_sanity_test!(test_matrix_input_4, 3, Const::<4>); - -#[test] -fn test_matrix_output_types() { - // Test that the dimension types are correct for the given inputs - let _: MatrixStrategy<_, U3, U4> = matrix(-5..5, Const::<3>, Const::<4>); - let _: MatrixStrategy<_, U3, U3> = matrix(-5..5, Const::<3>, Const::<3>); - let _: MatrixStrategy<_, U3, Dyn> = matrix(-5..5, Const::<3>, 1..=5); - let _: MatrixStrategy<_, Dyn, U3> = matrix(-5..5, 1..=5, Const::<3>); - let _: MatrixStrategy<_, Dyn, Dyn> = matrix(-5..5, 1..=5, 1..=5); -} - -// Below we have some tests to ensure that specific instances of OMatrix are usable -// in a typical proptest scenario where we (implicitly) use the `Arbitrary` trait -proptest! { - #[test] - fn ensure_arbitrary_test_compiles_matrix3(_: Matrix3) {} - - #[test] - fn ensure_arbitrary_test_compiles_matrixmn_u3_dynamic(_: OMatrix) {} - - #[test] - fn ensure_arbitrary_test_compiles_matrixmn_dynamic_u3(_: OMatrix) {} - - #[test] - fn ensure_arbitrary_test_compiles_dmatrix(_: DMatrix) {} - - #[test] - fn ensure_arbitrary_test_compiles_vector3(_: Vector3) {} - - #[test] - fn ensure_arbitrary_test_compiles_dvector(_: DVector) {} -} - -#[test] -fn matrix_shrinking_satisfies_constraints() { - // We use a deterministic test runner to make the test "stable". - let mut runner = TestRunner::deterministic(); - - let strategy = matrix(-1..=2, 1..=3, 2..=4); - - let num_matrices = 25; - - macro_rules! maybeprintln { - ($($arg:tt)*) => { - // Uncomment the below line to enable printing of matrix sequences. This is handy - // for manually inspecting the sequences of simplified matrices. - // println!($($arg)*) - }; - } - - maybeprintln!("========================== (begin generation process)"); - - for _ in 0..num_matrices { - let mut tree = strategy - .new_tree(&mut runner) - .expect("Tree generation should not fail."); - - let mut current = Some(tree.current()); - - maybeprintln!("------------------"); - - while let Some(matrix) = current { - maybeprintln!("{}", matrix); - - assert!( - matrix.iter().all(|&v| v >= -1 && v <= 2), - "All matrix elements must satisfy constraints" - ); - assert!( - matrix.nrows() >= 1 && matrix.nrows() <= 3, - "Number of rows in matrix must satisfy constraints." - ); - assert!( - matrix.ncols() >= 2 && matrix.ncols() <= 4, - "Number of columns in matrix must satisfy constraints." - ); - - current = if tree.simplify() { - Some(tree.current()) - } else { - None - } - } - } - - maybeprintln!("========================== (end of generation process)"); -} - -#[cfg(feature = "slow-tests")] -mod slow { - use super::*; - use itertools::Itertools; - use std::collections::HashSet; - use std::iter::repeat; - - #[cfg(feature = "slow-tests")] - #[test] - fn matrix_samples_all_possible_outputs() { - // Test that the proptest generation covers all possible outputs for a small space of inputs - // given enough samples. - - // We use a deterministic test runner to make the test "stable". - let mut runner = TestRunner::deterministic(); - - // This number needs to be high enough so that we with high probability sample - // all possible cases - let num_generated_matrices = 200000; - - let values = -1..=1; - let rows = 0..=2; - let cols = 0..=3; - let strategy = matrix(values.clone(), rows.clone(), cols.clone()); - - // Enumerate all possible combinations - let mut all_combinations = HashSet::new(); - for nrows in rows { - for ncols in cols.clone() { - // For the given number of rows and columns - let n_values = nrows * ncols; - - if n_values == 0 { - // If we have zero rows or columns, the set of matrices with the given - // rows and columns is a single element: an empty matrix - all_combinations.insert(DMatrix::from_row_slice(nrows, ncols, &[])); - } else { - // Otherwise, we need to sample all possible matrices. - // To do this, we generate the values as the (multi) Cartesian product - // of the value sets. For example, for a 2x2 matrices, we consider - // all possible 4-element arrays that the matrices can take by - // considering all elements in the cartesian product - // V x V x V x V - // where V is the set of eligible values, e.g. V := -1 ..= 1 - for matrix_values in repeat(values.clone()) - .take(n_values) - .multi_cartesian_product() - { - all_combinations.insert(DMatrix::from_row_slice( - nrows, - ncols, - &matrix_values, - )); - } - } - } - } - - let mut visited_combinations = HashSet::new(); - for _ in 0..num_generated_matrices { - let tree = strategy - .new_tree(&mut runner) - .expect("Tree generation should not fail"); - let matrix = tree.current(); - visited_combinations.insert(matrix.clone()); - } - - assert_eq!( - visited_combinations, all_combinations, - "Did not sample all possible values." - ); - } -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/sparse/cs_cholesky.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/sparse/cs_cholesky.rs deleted file mode 100644 index 6c020e54c..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/sparse/cs_cholesky.rs +++ /dev/null @@ -1,75 +0,0 @@ -#![cfg_attr(rustfmt, rustfmt_skip)] - -use na::{CsMatrix, CsVector, CsCholesky, Cholesky, Matrix5, Vector5}; - -#[test] -fn cs_cholesky() { - let mut a = Matrix5::new( - 40.0, 0.0, 0.0, 0.0, 0.0, - 2.0, 60.0, 0.0, 0.0, 0.0, - 1.0, 0.0, 11.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 50.0, 0.0, - 1.0, 0.0, 0.0, 4.0, 10.0 - ); - a.fill_upper_triangle_with_lower_triangle(); - test_cholesky(a); - - let a = Matrix5::from_diagonal(&Vector5::new(40.0, 60.0, 11.0, 50.0, 10.0)); - test_cholesky(a); - - let mut a = Matrix5::new( - 40.0, 0.0, 0.0, 0.0, 0.0, - 2.0, 60.0, 0.0, 0.0, 0.0, - 1.0, 0.0, 11.0, 0.0, 0.0, - 1.0, 0.0, 0.0, 50.0, 0.0, - 0.0, 0.0, 0.0, 4.0, 10.0 - ); - a.fill_upper_triangle_with_lower_triangle(); - test_cholesky(a); - - let mut a = Matrix5::new( - 2.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 2.0, 0.0, 0.0, 0.0, - 1.0, 1.0, 2.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 2.0, 0.0, - 1.0, 1.0, 0.0, 0.0, 2.0 - ); - a.fill_upper_triangle_with_lower_triangle(); - // Test crate::new, left_looking, and up_looking implementations. - test_cholesky(a); -} - -fn test_cholesky(a: Matrix5) { - // Test crate::new - test_cholesky_variant(a, 0); - // Test up-looking - test_cholesky_variant(a, 1); - // Test left-looking - test_cholesky_variant(a, 2); -} - -fn test_cholesky_variant(a: Matrix5, option: usize) { - let cs_a: CsMatrix<_, _, _> = a.into(); - - let chol_a = Cholesky::new(a).unwrap(); - let mut chol_cs_a; - - match option { - 0 => chol_cs_a = CsCholesky::new(&cs_a), - 1 => { - chol_cs_a = CsCholesky::new_symbolic(&cs_a); - chol_cs_a.decompose_up_looking(cs_a.data.values()); - } - _ => { - chol_cs_a = CsCholesky::new_symbolic(&cs_a); - chol_cs_a.decompose_left_looking(cs_a.data.values()); - } - }; - - let l = chol_a.l(); - let cs_l = chol_cs_a.unwrap_l().unwrap(); - assert!(cs_l.is_sorted()); - - let cs_l_mat: Matrix5<_> = cs_l.into(); - assert_relative_eq!(l, cs_l_mat); -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/sparse/cs_construction.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/sparse/cs_construction.rs deleted file mode 100644 index d3f5a12fa..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/sparse/cs_construction.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/sparse/cs_conversion.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/sparse/cs_conversion.rs deleted file mode 100644 index e07bb1486..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/sparse/cs_conversion.rs +++ /dev/null @@ -1,86 +0,0 @@ -use na::{CsMatrix, DMatrix, Matrix4x5}; - -#[test] -fn cs_from_to_matrix() { - #[cfg_attr(rustfmt, rustfmt_skip)] - let m = Matrix4x5::new( - 5.0, 6.0, 0.0, 8.0, 15.0, - 9.0, 10.0, 11.0, 12.0, 0.0, - 0.0, 0.0, 13.0, 0.0, 0.0, - 0.0, 1.0, 4.0, 0.0, 14.0, - ); - - let cs: CsMatrix<_, _, _> = m.into(); - assert!(cs.is_sorted()); - - let m2: Matrix4x5<_> = cs.into(); - assert_eq!(m2, m); -} - -#[test] -fn cs_matrix_from_triplet() { - let mut irows = vec![0, 0, 0, 0, 1, 1, 1, 1, 2, 3, 3, 3]; - let mut icols = vec![0, 1, 3, 4, 0, 1, 2, 3, 2, 1, 2, 4]; - let mut vals = vec![ - 5.0, 6.0, 8.0, 15.0, 9.0, 10.0, 11.0, 12.0, 13.0, 1.0, 4.0, 14.0, - ]; - - #[cfg_attr(rustfmt, rustfmt_skip)] - let expected = DMatrix::from_row_slice(4, 5, &[ - 5.0, 6.0, 0.0, 8.0, 15.0, - 9.0, 10.0, 11.0, 12.0, 0.0, - 0.0, 0.0, 13.0, 0.0, 0.0, - 0.0, 1.0, 4.0, 0.0, 14.0, - ]); - let cs_expected = CsMatrix::from_parts( - 4, - 5, - vec![0, 2, 5, 8, 10], - vec![0, 1, 0, 1, 3, 1, 2, 3, 0, 1, 0, 3], - vec![ - 5.0, 9.0, 6.0, 10.0, 1.0, 11.0, 13.0, 4.0, 8.0, 12.0, 15.0, 14.0, - ], - ); - - let cs_mat = CsMatrix::from_triplet(4, 5, &irows, &icols, &vals); - assert!(cs_mat.is_sorted()); - assert_eq!(cs_mat, cs_expected); - - let m: DMatrix<_> = cs_mat.into(); - assert_eq!(m, expected); - - /* - * Try again with some permutations. - */ - let permutations = [(2, 5), (0, 4), (8, 10), (1, 11)]; - - for (i, j) in &permutations { - irows.swap(*i, *j); - icols.swap(*i, *j); - vals.swap(*i, *j); - } - - let cs_mat = CsMatrix::from_triplet(4, 5, &irows, &icols, &vals); - assert!(cs_mat.is_sorted()); - assert_eq!(cs_mat, cs_expected); - - let m: DMatrix<_> = cs_mat.into(); - assert_eq!(m, expected); - - /* - * Try again, duplicating all entries. - */ - let mut ir = irows.clone(); - let mut ic = icols.clone(); - let mut va = vals.clone(); - irows.append(&mut ir); - icols.append(&mut ic); - vals.append(&mut va); - - let cs_mat = CsMatrix::from_triplet(4, 5, &irows, &icols, &vals); - assert!(cs_mat.is_sorted()); - assert_eq!(cs_mat, cs_expected * 2.0); - - let m: DMatrix<_> = cs_mat.into(); - assert_eq!(m, expected * 2.0); -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/sparse/cs_matrix.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/sparse/cs_matrix.rs deleted file mode 100644 index 71c695b37..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/sparse/cs_matrix.rs +++ /dev/null @@ -1,22 +0,0 @@ -#![cfg_attr(rustfmt, rustfmt_skip)] - -use na::{Matrix4x5, Matrix5x4, CsMatrix}; - -#[test] -fn cs_transpose() { - let m = Matrix4x5::new( - 4.0, 1.0, 4.0, 0.0, 9.0, - 5.0, 6.0, 0.0, 8.0, 10.0, - 9.0, 10.0, 11.0, 12.0, 0.0, - 0.0, 0.0, 1.0, 0.0, 10.0 - ); - - let cs: CsMatrix<_, _, _> = m.into(); - assert!(cs.is_sorted()); - - let cs_transposed = cs.transpose(); - assert!(cs_transposed.is_sorted()); - - let cs_transposed_mat: Matrix5x4<_> = cs_transposed.into(); - assert_eq!(cs_transposed_mat, m.transpose()) -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/sparse/cs_matrix_market.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/sparse/cs_matrix_market.rs deleted file mode 100644 index 3a752d2f1..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/sparse/cs_matrix_market.rs +++ /dev/null @@ -1,54 +0,0 @@ -#![cfg_attr(rustfmt, rustfmt_skip)] - - -use na::io; -use na::DMatrix; - -#[test] -fn cs_matrix_market() { - let file_str = r#" - %%MatrixMarket matrix coordinate real general -%================================================================================= -% -% This ASCII file represents a sparse MxN matrix with L -% nonzeros in the following Matrix Market format: -% -% +----------------------------------------------+ -% |%%MatrixMarket matrix coordinate real general | <--- header line -% |% | <--+ -% |% comments | |-- 0 or more comment lines -% |% | <--+ -% | M T L | <--- rows, columns, entries -% | I1 J1 A(I1, J1) | <--+ -% | I2 J2 A(I2, J2) | | -% | I3 J3 A(I3, J3) | |-- L lines -% | . . . | | -% | IL JL A(IL, JL) | <--+ -% +----------------------------------------------+ -% -% Indices are 1-based, i.e. A(1,1) is the first element. -% -%================================================================================= - 5 5 8 - 1 1 1.000e+00 - 2 2 1.050e+01 - 3 3 1.500e-02 - 1 4 6.000e+00 - 4 2 2.505e+02 - 4 4 -2.800e+02 - 4 5 3.332e+01 - 5 5 1.200e+01 -"#; - - let cs_mat = io::cs_matrix_from_matrix_market_str(file_str).unwrap(); - let mat: DMatrix<_> = cs_mat.into(); - let expected = DMatrix::from_row_slice(5, 5, &[ - 1.0, 0.0, 0.0, 6.0, 0.0, - 0.0, 10.5, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.015, 0.0, 0.0, - 0.0, 250.5, 0.0, -280.0, 33.32, - 0.0, 0.0, 0.0, 0.0, 12.0, - ]); - - assert_eq!(mat, expected); -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/sparse/cs_ops.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/sparse/cs_ops.rs deleted file mode 100644 index 8e7161ce3..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/sparse/cs_ops.rs +++ /dev/null @@ -1,72 +0,0 @@ -#![cfg_attr(rustfmt, rustfmt_skip)] - - -use na::{Matrix3x4, Matrix4x5, Matrix3x5, CsMatrix, Vector5, CsVector}; - -#[test] -fn axpy_cs() { - let mut v1 = Vector5::new(1.0, 2.0, 3.0, 4.0, 5.0); - let v2 = Vector5::new(10.0, 0.0, 30.0, 0.0, 50.0); - let expected = 5.0 * v2 + 10.0 * v1; - - let cs: CsVector<_, _> = v2.into(); - v1.axpy_cs(5.0, &cs, 10.0); - - assert!(cs.is_sorted()); - assert_eq!(v1, expected) -} - - -#[test] -fn cs_mat_mul() { - let m1 = Matrix3x4::new( - 0.0, 1.0, 4.0, 0.0, - 5.0, 6.0, 0.0, 8.0, - 9.0, 10.0, 11.0, 12.0, - ); - - let m2 = Matrix4x5::new( - 5.0, 6.0, 0.0, 8.0, 15.0, - 9.0, 10.0, 11.0, 12.0, 0.0, - 0.0, 0.0, 13.0, 0.0, 0.0, - 0.0, 1.0, 4.0, 0.0, 14.0, - ); - - let sm1: CsMatrix<_, _, _> = m1.into(); - let sm2: CsMatrix<_, _, _> = m2.into(); - - let mul = &sm1 * &sm2; - - assert!(sm1.is_sorted()); - assert!(sm2.is_sorted()); - assert!(mul.is_sorted()); - assert_eq!(Matrix3x5::from(mul), m1 * m2); -} - - -#[test] -fn cs_mat_add() { - let m1 = Matrix4x5::new( - 4.0, 1.0, 4.0, 0.0, 0.0, - 5.0, 6.0, 0.0, 8.0, 0.0, - 9.0, 10.0, 11.0, 12.0, 0.0, - 0.0, 0.0, 1.0, 0.0, 10.0 - ); - - let m2 = Matrix4x5::new( - 0.0, 1.0, 4.0, 0.0, 14.0, - 5.0, 6.0, 0.0, 8.0, 15.0, - 9.0, 10.0, 11.0, 12.0, 0.0, - 0.0, 0.0, 13.0, 0.0, 0.0, - ); - - let sm1: CsMatrix<_, _, _> = m1.into(); - let sm2: CsMatrix<_, _, _> = m2.into(); - - let sum = &sm1 + &sm2; - - assert!(sm1.is_sorted()); - assert!(sm2.is_sorted()); - assert!(sum.is_sorted()); - assert_eq!(Matrix4x5::from(sum), m1 + m2); -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/sparse/cs_solve.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/sparse/cs_solve.rs deleted file mode 100644 index 41182f9ef..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/sparse/cs_solve.rs +++ /dev/null @@ -1,106 +0,0 @@ -#![cfg_attr(rustfmt, rustfmt_skip)] - -use na::{CsMatrix, CsVector, Matrix5, Vector5}; - - -#[test] -fn cs_lower_triangular_solve() { - let a = Matrix5::new( - 4.0, 1.0, 4.0, 0.0, 9.0, - 5.0, 6.0, 0.0, 8.0, 10.0, - 9.0, 10.0, 11.0, 12.0, 0.0, - 0.0, -8.0, 3.0, 5.0, 9.0, - 0.0, 0.0, 1.0, 0.0, -10.0 - ); - let b = Vector5::new(1.0, 2.0, 3.0, 4.0, 5.0); - - let cs_a: CsMatrix<_, _, _> = a.into(); - - assert_eq!(cs_a.solve_lower_triangular(&b), a.solve_lower_triangular(&b)); -} - -#[test] -fn cs_tr_lower_triangular_solve() { - let a = Matrix5::new( - 4.0, 1.0, 4.0, 0.0, 9.0, - 5.0, 6.0, 0.0, 8.0, 10.0, - 9.0, 10.0, 11.0, 12.0, 0.0, - 0.0, -8.0, 3.0, 5.0, 9.0, - 0.0, 0.0, 1.0, 0.0, -10.0 - ); - let b = Vector5::new(1.0, 2.0, 3.0, 4.0, 5.0); - - let cs_a: CsMatrix<_, _, _> = a.into(); - - assert!(cs_a.tr_solve_lower_triangular(&b).is_some()); - assert_eq!(cs_a.tr_solve_lower_triangular(&b), a.tr_solve_lower_triangular(&b)); - - // Singular case. - let a = Matrix5::new( - 4.0, 1.0, 4.0, 0.0, 9.0, - 5.0, 6.0, 0.0, 8.0, 10.0, - 9.0, 10.0, 0.0, 12.0, 0.0, - 0.0, -8.0, 3.0, 5.0, 9.0, - 0.0, 0.0, 1.0, 0.0, -10.0 - ); - let cs_a: CsMatrix<_, _, _> = a.into(); - - assert!(cs_a.tr_solve_lower_triangular(&b).is_none()); -} - - -#[test] -fn cs_lower_triangular_solve_cs() { - let a = Matrix5::new( - 4.0, 1.0, 4.0, 0.0, 9.0, - 5.0, 6.0, 0.0, 8.0, 10.0, - 9.0, 10.0, 11.0, 12.0, 0.0, - 0.0, -8.0, 3.0, 5.0, 9.0, - 0.0, 0.0, 1.0, 0.0, -10.0 - ); - let b1 = Vector5::zeros(); - let b2 = Vector5::new(1.0, 2.0, 3.0, 4.0, 5.0); - let b3 = Vector5::new(1.0, 0.0, 0.0, 4.0, 0.0); - let b4 = Vector5::new(0.0, 1.0, 0.0, 4.0, 5.0); - let b5 = Vector5::x(); - let b6 = Vector5::y(); - let b7 = Vector5::z(); - let b8 = Vector5::w(); - let b9 = Vector5::a(); - - let cs_a: CsMatrix<_, _, _> = a.into(); - let cs_b1: CsVector<_, _> = Vector5::zeros().into(); - let cs_b2: CsVector<_, _> = Vector5::new(1.0, 2.0, 3.0, 4.0, 5.0).into(); - let cs_b3: CsVector<_, _> = Vector5::new(1.0, 0.0, 0.0, 4.0, 0.0).into(); - let cs_b4: CsVector<_, _> = Vector5::new(0.0, 1.0, 0.0, 4.0, 5.0).into(); - let cs_b5: CsVector<_, _> = Vector5::x().into(); - let cs_b6: CsVector<_, _> = Vector5::y().into(); - let cs_b7: CsVector<_, _> = Vector5::z().into(); - let cs_b8: CsVector<_, _> = Vector5::w().into(); - let cs_b9: CsVector<_, _> = Vector5::a().into(); - - assert_eq!(cs_a.solve_lower_triangular_cs(&cs_b1).map(|v| { assert!(v.is_sorted()); v.into() }), a.solve_lower_triangular(&b1)); - assert_eq!(cs_a.solve_lower_triangular_cs(&cs_b5).map(|v| { assert!(v.is_sorted()); v.into() }), a.solve_lower_triangular(&b5)); - assert_eq!(cs_a.solve_lower_triangular_cs(&cs_b6).map(|v| { assert!(v.is_sorted()); v.into() }), a.solve_lower_triangular(&b6)); - assert_eq!(cs_a.solve_lower_triangular_cs(&cs_b7).map(|v| { assert!(v.is_sorted()); v.into() }), a.solve_lower_triangular(&b7)); - assert_eq!(cs_a.solve_lower_triangular_cs(&cs_b8).map(|v| { assert!(v.is_sorted()); v.into() }), a.solve_lower_triangular(&b8)); - assert_eq!(cs_a.solve_lower_triangular_cs(&cs_b9).map(|v| { assert!(v.is_sorted()); v.into() }), a.solve_lower_triangular(&b9)); - assert_eq!(cs_a.solve_lower_triangular_cs(&cs_b2).map(|v| { assert!(v.is_sorted()); v.into() }), a.solve_lower_triangular(&b2)); - assert_eq!(cs_a.solve_lower_triangular_cs(&cs_b3).map(|v| { assert!(v.is_sorted()); v.into() }), a.solve_lower_triangular(&b3)); - assert_eq!(cs_a.solve_lower_triangular_cs(&cs_b4).map(|v| { assert!(v.is_sorted()); v.into() }), a.solve_lower_triangular(&b4)); - - - // Singular case. - let a = Matrix5::new( - 4.0, 1.0, 4.0, 0.0, 9.0, - 5.0, 0.0, 0.0, 8.0, 10.0, - 9.0, 10.0, 0.0, 12.0, 0.0, - 0.0, -8.0, 3.0, 5.0, 9.0, - 0.0, 0.0, 1.0, 0.0, -10.0 - ); - let cs_a: CsMatrix<_, _, _> = a.into(); - - assert!(cs_a.solve_lower_triangular_cs(&cs_b2).is_none()); - assert!(cs_a.solve_lower_triangular_cs(&cs_b3).is_none()); - assert!(cs_a.solve_lower_triangular_cs(&cs_b4).is_none()); -} diff --git a/collector/compile-benchmarks/nalgebra-0.33.0/tests/sparse/mod.rs b/collector/compile-benchmarks/nalgebra-0.33.0/tests/sparse/mod.rs deleted file mode 100644 index 70492a57c..000000000 --- a/collector/compile-benchmarks/nalgebra-0.33.0/tests/sparse/mod.rs +++ /dev/null @@ -1,8 +0,0 @@ -mod cs_cholesky; -mod cs_construction; -mod cs_conversion; -mod cs_matrix; -#[cfg(feature = "io")] -mod cs_matrix_market; -mod cs_ops; -mod cs_solve;