void test_geo_transformations() { for(int i = 0; i < g_repeat; i++) { CALL_SUBTEST_1(( transformations<double,Affine,AutoAlign>() )); CALL_SUBTEST_1(( non_projective_only<double,Affine,AutoAlign>() )); CALL_SUBTEST_2(( transformations<float,AffineCompact,AutoAlign>() )); CALL_SUBTEST_2(( non_projective_only<float,AffineCompact,AutoAlign>() )); CALL_SUBTEST_2(( transform_alignment<float>() )); CALL_SUBTEST_3(( transformations<double,Projective,AutoAlign>() )); CALL_SUBTEST_3(( transformations<double,Projective,DontAlign>() )); CALL_SUBTEST_3(( transform_alignment<double>() )); CALL_SUBTEST_4(( transformations<float,Affine,RowMajor|AutoAlign>() )); CALL_SUBTEST_4(( non_projective_only<float,Affine,RowMajor>() )); CALL_SUBTEST_5(( transformations<double,AffineCompact,RowMajor|AutoAlign>() )); CALL_SUBTEST_5(( non_projective_only<double,AffineCompact,RowMajor>() )); CALL_SUBTEST_6(( transformations<double,Projective,RowMajor|AutoAlign>() )); CALL_SUBTEST_6(( transformations<double,Projective,RowMajor|DontAlign>() )); CALL_SUBTEST_7(( transform_products<double,3,RowMajor|AutoAlign>() )); CALL_SUBTEST_7(( transform_products<float,2,AutoAlign>() )); } }
void test_array_for_matrix() { int maxsize = 40; for(int i = 0; i < g_repeat; i++) { CALL_SUBTEST_1( array_for_matrix(Matrix<float, 1, 1>()) ); CALL_SUBTEST_2( array_for_matrix(Matrix2f()) ); CALL_SUBTEST_3( array_for_matrix(Matrix4d()) ); CALL_SUBTEST_4( array_for_matrix(MatrixXcf(internal::random<int>(1,maxsize), internal::random<int>(1,maxsize))) ); CALL_SUBTEST_5( array_for_matrix(MatrixXf(internal::random<int>(1,maxsize), internal::random<int>(1,maxsize))) ); CALL_SUBTEST_6( array_for_matrix(MatrixXi(internal::random<int>(1,maxsize), internal::random<int>(1,maxsize))) ); } for(int i = 0; i < g_repeat; i++) { CALL_SUBTEST_1( comparisons(Matrix<float, 1, 1>()) ); CALL_SUBTEST_2( comparisons(Matrix2f()) ); CALL_SUBTEST_3( comparisons(Matrix4d()) ); CALL_SUBTEST_5( comparisons(MatrixXf(internal::random<int>(1,maxsize), internal::random<int>(1,maxsize))) ); CALL_SUBTEST_6( comparisons(MatrixXi(internal::random<int>(1,maxsize), internal::random<int>(1,maxsize))) ); } for(int i = 0; i < g_repeat; i++) { CALL_SUBTEST_1( lpNorm(Matrix<float, 1, 1>()) ); CALL_SUBTEST_2( lpNorm(Vector2f()) ); CALL_SUBTEST_7( lpNorm(Vector3d()) ); CALL_SUBTEST_8( lpNorm(Vector4f()) ); CALL_SUBTEST_5( lpNorm(VectorXf(internal::random<int>(1,maxsize))) ); CALL_SUBTEST_4( lpNorm(VectorXcf(internal::random<int>(1,maxsize))) ); } }
void test_stdvector_overload() { // some non vectorizable fixed sizes CALL_SUBTEST_1(check_stdvector_matrix(Vector2f())); CALL_SUBTEST_1(check_stdvector_matrix(Matrix3f())); CALL_SUBTEST_2(check_stdvector_matrix(Matrix3d())); // some vectorizable fixed sizes CALL_SUBTEST_1(check_stdvector_matrix(Matrix2f())); CALL_SUBTEST_1(check_stdvector_matrix(Vector4f())); CALL_SUBTEST_1(check_stdvector_matrix(Matrix4f())); CALL_SUBTEST_2(check_stdvector_matrix(Matrix4d())); // some dynamic sizes CALL_SUBTEST_3(check_stdvector_matrix(MatrixXd(1,1))); CALL_SUBTEST_3(check_stdvector_matrix(VectorXd(20))); CALL_SUBTEST_3(check_stdvector_matrix(RowVectorXf(20))); CALL_SUBTEST_3(check_stdvector_matrix(MatrixXcf(10,10))); // some Transform CALL_SUBTEST_4(check_stdvector_transform(Affine2f())); // does not need the specialization (2+1)^2 = 9 CALL_SUBTEST_4(check_stdvector_transform(Affine3f())); CALL_SUBTEST_4(check_stdvector_transform(Affine3d())); // some Quaternion CALL_SUBTEST_5(check_stdvector_quaternion(Quaternionf())); CALL_SUBTEST_5(check_stdvector_quaternion(Quaterniond())); }
void test_redux() { // the max size cannot be too large, otherwise reduxion operations obviously generate large errors. int maxsize = (std::min)(100,EIGEN_TEST_MAX_SIZE); EIGEN_UNUSED_VARIABLE(maxsize); for(int i = 0; i < g_repeat; i++) { CALL_SUBTEST_1( matrixRedux(Matrix<float, 1, 1>()) ); CALL_SUBTEST_1( matrixRedux(Array<float, 1, 1>()) ); CALL_SUBTEST_2( matrixRedux(Matrix2f()) ); CALL_SUBTEST_2( matrixRedux(Array2f()) ); CALL_SUBTEST_3( matrixRedux(Matrix4d()) ); CALL_SUBTEST_3( matrixRedux(Array4d()) ); CALL_SUBTEST_4( matrixRedux(MatrixXcf(internal::random<int>(1,maxsize), internal::random<int>(1,maxsize))) ); CALL_SUBTEST_4( matrixRedux(ArrayXXcf(internal::random<int>(1,maxsize), internal::random<int>(1,maxsize))) ); CALL_SUBTEST_5( matrixRedux(MatrixXd (internal::random<int>(1,maxsize), internal::random<int>(1,maxsize))) ); CALL_SUBTEST_5( matrixRedux(ArrayXXd (internal::random<int>(1,maxsize), internal::random<int>(1,maxsize))) ); CALL_SUBTEST_6( matrixRedux(MatrixXi (internal::random<int>(1,maxsize), internal::random<int>(1,maxsize))) ); CALL_SUBTEST_6( matrixRedux(ArrayXXi (internal::random<int>(1,maxsize), internal::random<int>(1,maxsize))) ); } for(int i = 0; i < g_repeat; i++) { CALL_SUBTEST_7( vectorRedux(Vector4f()) ); CALL_SUBTEST_7( vectorRedux(Array4f()) ); CALL_SUBTEST_5( vectorRedux(VectorXd(internal::random<int>(1,maxsize))) ); CALL_SUBTEST_5( vectorRedux(ArrayXd(internal::random<int>(1,maxsize))) ); CALL_SUBTEST_8( vectorRedux(VectorXf(internal::random<int>(1,maxsize))) ); CALL_SUBTEST_8( vectorRedux(ArrayXf(internal::random<int>(1,maxsize))) ); } }
void test_eigen2_array() { for(int i = 0; i < g_repeat; i++) { CALL_SUBTEST_1( array(Matrix<float, 1, 1>()) ); CALL_SUBTEST_2( array(Matrix2f()) ); CALL_SUBTEST_3( array(Matrix4d()) ); CALL_SUBTEST_4( array(MatrixXcf(3, 3)) ); CALL_SUBTEST_5( array(MatrixXf(8, 12)) ); CALL_SUBTEST_6( array(MatrixXi(8, 12)) ); } for(int i = 0; i < g_repeat; i++) { CALL_SUBTEST_1( comparisons(Matrix<float, 1, 1>()) ); CALL_SUBTEST_2( comparisons(Matrix2f()) ); CALL_SUBTEST_3( comparisons(Matrix4d()) ); CALL_SUBTEST_5( comparisons(MatrixXf(8, 12)) ); CALL_SUBTEST_6( comparisons(MatrixXi(8, 12)) ); } for(int i = 0; i < g_repeat; i++) { CALL_SUBTEST_1( lpNorm(Matrix<float, 1, 1>()) ); CALL_SUBTEST_2( lpNorm(Vector2f()) ); CALL_SUBTEST_3( lpNorm(Vector3d()) ); CALL_SUBTEST_4( lpNorm(Vector4f()) ); CALL_SUBTEST_5( lpNorm(VectorXf(16)) ); CALL_SUBTEST_7( lpNorm(VectorXcd(10)) ); } }
void test_stdvector() { // some non vectorizable fixed sizes CALL_SUBTEST_1(check_stdvector_matrix(Vector2f())); CALL_SUBTEST_1(check_stdvector_matrix(Matrix3f())); CALL_SUBTEST_2(check_stdvector_matrix(Matrix3d())); // some vectorizable fixed sizes CALL_SUBTEST_1(check_stdvector_matrix(Matrix2f())); CALL_SUBTEST_1(check_stdvector_matrix(Vector4f())); CALL_SUBTEST_1(check_stdvector_matrix(Matrix4f())); CALL_SUBTEST_2(check_stdvector_matrix(Matrix4d())); // some dynamic sizes CALL_SUBTEST_3(check_stdvector_matrix(MatrixXd(1,1))); CALL_SUBTEST_3(check_stdvector_matrix(VectorXd(20))); CALL_SUBTEST_3(check_stdvector_matrix(RowVectorXf(20))); CALL_SUBTEST_3(check_stdvector_matrix(MatrixXcf(10,10))); // some Transform CALL_SUBTEST_4(check_stdvector_transform(Projective2f())); CALL_SUBTEST_4(check_stdvector_transform(Projective3f())); CALL_SUBTEST_4(check_stdvector_transform(Projective3d())); //CALL_SUBTEST(heck_stdvector_transform(Projective4d())); // some Quaternion CALL_SUBTEST_5(check_stdvector_quaternion(Quaternionf())); CALL_SUBTEST_5(check_stdvector_quaternion(Quaterniond())); }
void test_sparse_basic() { for(int i = 0; i < g_repeat; i++) { int r = Eigen::internal::random<int>(1,200), c = Eigen::internal::random<int>(1,200); if(Eigen::internal::random<int>(0,4) == 0) { r = c; // check square matrices in 25% of tries } EIGEN_UNUSED_VARIABLE(r+c); CALL_SUBTEST_1(( sparse_basic(SparseMatrix<double>(1, 1)) )); CALL_SUBTEST_1(( sparse_basic(SparseMatrix<double>(8, 8)) )); CALL_SUBTEST_2(( sparse_basic(SparseMatrix<std::complex<double>, ColMajor>(r, c)) )); CALL_SUBTEST_2(( sparse_basic(SparseMatrix<std::complex<double>, RowMajor>(r, c)) )); CALL_SUBTEST_1(( sparse_basic(SparseMatrix<double>(r, c)) )); CALL_SUBTEST_5(( sparse_basic(SparseMatrix<double,ColMajor,long int>(r, c)) )); CALL_SUBTEST_5(( sparse_basic(SparseMatrix<double,RowMajor,long int>(r, c)) )); r = Eigen::internal::random<int>(1,100); c = Eigen::internal::random<int>(1,100); if(Eigen::internal::random<int>(0,4) == 0) { r = c; // check square matrices in 25% of tries } CALL_SUBTEST_6(( sparse_basic(SparseMatrix<double,ColMajor,short int>(short(r), short(c))) )); CALL_SUBTEST_6(( sparse_basic(SparseMatrix<double,RowMajor,short int>(short(r), short(c))) )); } // Regression test for bug 900: (manually insert higher values here, if you have enough RAM): CALL_SUBTEST_3((big_sparse_triplet<SparseMatrix<float, RowMajor, int> >(10000, 10000, 0.125))); CALL_SUBTEST_4((big_sparse_triplet<SparseMatrix<double, ColMajor, long int> >(10000, 10000, 0.125))); }
void test_integer_types() { for(int i = 0; i < g_repeat; i++) { CALL_SUBTEST_1( integer_type_tests(Matrix<unsigned int, 1, 1>()) ); CALL_SUBTEST_1( integer_type_tests(Matrix<unsigned long, 3, 4>()) ); CALL_SUBTEST_2( integer_type_tests(Matrix<long, 2, 2>()) ); CALL_SUBTEST_2( signed_integer_type_tests(Matrix<long, 2, 2>()) ); CALL_SUBTEST_3( integer_type_tests(Matrix<char, 2, Dynamic>(2, 10)) ); CALL_SUBTEST_3( signed_integer_type_tests(Matrix<signed char, 2, Dynamic>(2, 10)) ); CALL_SUBTEST_4( integer_type_tests(Matrix<unsigned char, 3, 3>()) ); CALL_SUBTEST_4( integer_type_tests(Matrix<unsigned char, Dynamic, Dynamic>(20, 20)) ); CALL_SUBTEST_5( integer_type_tests(Matrix<short, Dynamic, 4>(7, 4)) ); CALL_SUBTEST_5( signed_integer_type_tests(Matrix<short, Dynamic, 4>(7, 4)) ); CALL_SUBTEST_6( integer_type_tests(Matrix<unsigned short, 4, 4>()) ); CALL_SUBTEST_7( integer_type_tests(Matrix<long long, 11, 13>()) ); CALL_SUBTEST_7( signed_integer_type_tests(Matrix<long long, 11, 13>()) ); CALL_SUBTEST_8( integer_type_tests(Matrix<unsigned long long, Dynamic, 5>(1, 5)) ); } }
void test_mapstaticmethods() { ptr = internal::aligned_new<float>(1000); for(int i = 0; i < 1000; i++) ptr[i] = float(i); const_ptr = ptr; CALL_SUBTEST_1(( mapstaticmethods(Matrix<float, 1, 1>()) )); CALL_SUBTEST_1(( mapstaticmethods(Vector2f()) )); CALL_SUBTEST_2(( mapstaticmethods(Vector3f()) )); CALL_SUBTEST_2(( mapstaticmethods(Matrix2f()) )); CALL_SUBTEST_3(( mapstaticmethods(Matrix4f()) )); CALL_SUBTEST_3(( mapstaticmethods(Array4f()) )); CALL_SUBTEST_4(( mapstaticmethods(Array3f()) )); CALL_SUBTEST_4(( mapstaticmethods(Array33f()) )); CALL_SUBTEST_5(( mapstaticmethods(Array44f()) )); CALL_SUBTEST_5(( mapstaticmethods(VectorXf(1)) )); CALL_SUBTEST_5(( mapstaticmethods(VectorXf(8)) )); CALL_SUBTEST_6(( mapstaticmethods(MatrixXf(1,1)) )); CALL_SUBTEST_6(( mapstaticmethods(MatrixXf(5,7)) )); CALL_SUBTEST_7(( mapstaticmethods(ArrayXf(1)) )); CALL_SUBTEST_7(( mapstaticmethods(ArrayXf(5)) )); CALL_SUBTEST_8(( mapstaticmethods(ArrayXXf(1,1)) )); CALL_SUBTEST_8(( mapstaticmethods(ArrayXXf(8,6)) )); internal::aligned_delete(ptr, 1000); }
void test_mapstride() { for(int i = 0; i < g_repeat; i++) { EIGEN_UNUSED int maxn = 30; CALL_SUBTEST_1( map_class_vector<Aligned>(Matrix<float, 1, 1>()) ); CALL_SUBTEST_1( map_class_vector<Unaligned>(Matrix<float, 1, 1>()) ); CALL_SUBTEST_2( map_class_vector<Aligned>(Vector4d()) ); CALL_SUBTEST_2( map_class_vector<Unaligned>(Vector4d()) ); CALL_SUBTEST_3( map_class_vector<Aligned>(RowVector4f()) ); CALL_SUBTEST_3( map_class_vector<Unaligned>(RowVector4f()) ); CALL_SUBTEST_4( map_class_vector<Aligned>(VectorXcf(internal::random<int>(1,maxn))) ); CALL_SUBTEST_4( map_class_vector<Unaligned>(VectorXcf(internal::random<int>(1,maxn))) ); CALL_SUBTEST_5( map_class_vector<Aligned>(VectorXi(internal::random<int>(1,maxn))) ); CALL_SUBTEST_5( map_class_vector<Unaligned>(VectorXi(internal::random<int>(1,maxn))) ); CALL_SUBTEST_1( map_class_matrix<Aligned>(Matrix<float, 1, 1>()) ); CALL_SUBTEST_1( map_class_matrix<Unaligned>(Matrix<float, 1, 1>()) ); CALL_SUBTEST_2( map_class_matrix<Aligned>(Matrix4d()) ); CALL_SUBTEST_2( map_class_matrix<Unaligned>(Matrix4d()) ); CALL_SUBTEST_3( map_class_matrix<Aligned>(Matrix<float,3,5>()) ); CALL_SUBTEST_3( map_class_matrix<Unaligned>(Matrix<float,3,5>()) ); CALL_SUBTEST_3( map_class_matrix<Aligned>(Matrix<float,4,8>()) ); CALL_SUBTEST_3( map_class_matrix<Unaligned>(Matrix<float,4,8>()) ); CALL_SUBTEST_4( map_class_matrix<Aligned>(MatrixXcf(internal::random<int>(1,maxn),internal::random<int>(1,maxn))) ); CALL_SUBTEST_4( map_class_matrix<Unaligned>(MatrixXcf(internal::random<int>(1,maxn),internal::random<int>(1,maxn))) ); CALL_SUBTEST_5( map_class_matrix<Aligned>(MatrixXi(internal::random<int>(1,maxn),internal::random<int>(1,maxn))) ); CALL_SUBTEST_5( map_class_matrix<Unaligned>(MatrixXi(internal::random<int>(1,maxn),internal::random<int>(1,maxn))) ); CALL_SUBTEST_6( map_class_matrix<Aligned>(MatrixXcd(internal::random<int>(1,maxn),internal::random<int>(1,maxn))) ); CALL_SUBTEST_6( map_class_matrix<Unaligned>(MatrixXcd(internal::random<int>(1,maxn),internal::random<int>(1,maxn))) ); } }
void test_mapped_matrix() { for(int i = 0; i < g_repeat; i++) { CALL_SUBTEST_1( map_class_vector(Matrix<float, 1, 1>()) ); CALL_SUBTEST_1( check_const_correctness(Matrix<float, 1, 1>()) ); CALL_SUBTEST_2( map_class_vector(Vector4d()) ); CALL_SUBTEST_2( map_class_vector(VectorXd(13)) ); CALL_SUBTEST_2( check_const_correctness(Matrix4d()) ); CALL_SUBTEST_3( map_class_vector(RowVector4f()) ); CALL_SUBTEST_4( map_class_vector(VectorXcf(8)) ); CALL_SUBTEST_5( map_class_vector(VectorXi(12)) ); CALL_SUBTEST_5( check_const_correctness(VectorXi(12)) ); CALL_SUBTEST_1( map_class_matrix(Matrix<float, 1, 1>()) ); CALL_SUBTEST_2( map_class_matrix(Matrix4d()) ); CALL_SUBTEST_11( map_class_matrix(Matrix<float,3,5>()) ); CALL_SUBTEST_4( map_class_matrix(MatrixXcf(internal::random<int>(1,10),internal::random<int>(1,10))) ); CALL_SUBTEST_5( map_class_matrix(MatrixXi(internal::random<int>(1,10),internal::random<int>(1,10))) ); CALL_SUBTEST_6( map_static_methods(Matrix<double, 1, 1>()) ); CALL_SUBTEST_7( map_static_methods(Vector3f()) ); CALL_SUBTEST_8( map_static_methods(RowVector3d()) ); CALL_SUBTEST_9( map_static_methods(VectorXcd(8)) ); CALL_SUBTEST_10( map_static_methods(VectorXf(12)) ); CALL_SUBTEST_11( map_not_aligned_on_scalar<double>() ); } }
void test_boostmultiprec() { typedef Matrix<Real,Dynamic,Dynamic> Mat; typedef Matrix<std::complex<Real>,Dynamic,Dynamic> MatC; std::cout << "NumTraits<Real>::epsilon() = " << NumTraits<Real>::epsilon() << std::endl; std::cout << "NumTraits<Real>::dummy_precision() = " << NumTraits<Real>::dummy_precision() << std::endl; std::cout << "NumTraits<Real>::lowest() = " << NumTraits<Real>::lowest() << std::endl; std::cout << "NumTraits<Real>::highest() = " << NumTraits<Real>::highest() << std::endl; std::cout << "NumTraits<Real>::digits10() = " << NumTraits<Real>::digits10() << std::endl; // chekc stream output { Mat A(10,10); A.setRandom(); std::stringstream ss; ss << A; } { MatC A(10,10); A.setRandom(); std::stringstream ss; ss << A; } for(int i = 0; i < g_repeat; i++) { int s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE); CALL_SUBTEST_1( cholesky(Mat(s,s)) ); CALL_SUBTEST_2( lu_non_invertible<Mat>() ); CALL_SUBTEST_2( lu_invertible<Mat>() ); CALL_SUBTEST_2( lu_non_invertible<MatC>() ); CALL_SUBTEST_2( lu_invertible<MatC>() ); CALL_SUBTEST_3( qr(Mat(internal::random<int>(1,EIGEN_TEST_MAX_SIZE),internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) ); CALL_SUBTEST_3( qr_invertible<Mat>() ); CALL_SUBTEST_4( qr<Mat>() ); CALL_SUBTEST_4( cod<Mat>() ); CALL_SUBTEST_4( qr_invertible<Mat>() ); CALL_SUBTEST_5( qr<Mat>() ); CALL_SUBTEST_5( qr_invertible<Mat>() ); CALL_SUBTEST_6( selfadjointeigensolver(Mat(s,s)) ); CALL_SUBTEST_7( eigensolver(Mat(s,s)) ); CALL_SUBTEST_8( generalized_eigensolver_real(Mat(s,s)) ); TEST_SET_BUT_UNUSED_VARIABLE(s) } CALL_SUBTEST_9(( jacobisvd(Mat(internal::random<int>(EIGEN_TEST_MAX_SIZE/4, EIGEN_TEST_MAX_SIZE), internal::random<int>(EIGEN_TEST_MAX_SIZE/4, EIGEN_TEST_MAX_SIZE/2))) )); CALL_SUBTEST_10(( bdcsvd(Mat(internal::random<int>(EIGEN_TEST_MAX_SIZE/4, EIGEN_TEST_MAX_SIZE), internal::random<int>(EIGEN_TEST_MAX_SIZE/4, EIGEN_TEST_MAX_SIZE/2))) )); }
void test_matrix_power() { CALL_SUBTEST_2(test2dRotation<double>(1e-13)); CALL_SUBTEST_1(test2dRotation<float>(2e-5)); // was 1e-5, relaxed for clang 2.8 / linux / x86-64 CALL_SUBTEST_9(test2dRotation<long double>(1e-13)); CALL_SUBTEST_2(test2dHyperbolicRotation<double>(1e-14)); CALL_SUBTEST_1(test2dHyperbolicRotation<float>(1e-5)); CALL_SUBTEST_9(test2dHyperbolicRotation<long double>(1e-14)); CALL_SUBTEST_10(test3dRotation<double>(1e-13)); CALL_SUBTEST_11(test3dRotation<float>(1e-5)); CALL_SUBTEST_12(test3dRotation<long double>(1e-13)); CALL_SUBTEST_2(testGeneral(Matrix2d(), 1e-13)); CALL_SUBTEST_7(testGeneral(Matrix3dRowMajor(), 1e-13)); CALL_SUBTEST_3(testGeneral(Matrix4cd(), 1e-13)); CALL_SUBTEST_4(testGeneral(MatrixXd(8,8), 2e-12)); CALL_SUBTEST_1(testGeneral(Matrix2f(), 1e-4)); CALL_SUBTEST_5(testGeneral(Matrix3cf(), 1e-4)); CALL_SUBTEST_8(testGeneral(Matrix4f(), 1e-4)); CALL_SUBTEST_6(testGeneral(MatrixXf(2,2), 1e-3)); // see bug 614 CALL_SUBTEST_9(testGeneral(MatrixXe(7,7), 1e-13)); CALL_SUBTEST_10(testGeneral(Matrix3d(), 1e-13)); CALL_SUBTEST_11(testGeneral(Matrix3f(), 1e-4)); CALL_SUBTEST_12(testGeneral(Matrix3e(), 1e-13)); CALL_SUBTEST_2(testSingular(Matrix2d(), 1e-13)); CALL_SUBTEST_7(testSingular(Matrix3dRowMajor(), 1e-13)); CALL_SUBTEST_3(testSingular(Matrix4cd(), 1e-13)); CALL_SUBTEST_4(testSingular(MatrixXd(8,8), 2e-12)); CALL_SUBTEST_1(testSingular(Matrix2f(), 1e-4)); CALL_SUBTEST_5(testSingular(Matrix3cf(), 1e-4)); CALL_SUBTEST_8(testSingular(Matrix4f(), 1e-4)); CALL_SUBTEST_6(testSingular(MatrixXf(2,2), 1e-3)); CALL_SUBTEST_9(testSingular(MatrixXe(7,7), 1e-13)); CALL_SUBTEST_10(testSingular(Matrix3d(), 1e-13)); CALL_SUBTEST_11(testSingular(Matrix3f(), 1e-4)); CALL_SUBTEST_12(testSingular(Matrix3e(), 1e-13)); CALL_SUBTEST_2(testLogThenExp(Matrix2d(), 1e-13)); CALL_SUBTEST_7(testLogThenExp(Matrix3dRowMajor(), 1e-13)); CALL_SUBTEST_3(testLogThenExp(Matrix4cd(), 1e-13)); CALL_SUBTEST_4(testLogThenExp(MatrixXd(8,8), 2e-12)); CALL_SUBTEST_1(testLogThenExp(Matrix2f(), 1e-4)); CALL_SUBTEST_5(testLogThenExp(Matrix3cf(), 1e-4)); CALL_SUBTEST_8(testLogThenExp(Matrix4f(), 1e-4)); CALL_SUBTEST_6(testLogThenExp(MatrixXf(2,2), 1e-3)); CALL_SUBTEST_9(testLogThenExp(MatrixXe(7,7), 1e-13)); CALL_SUBTEST_10(testLogThenExp(Matrix3d(), 1e-13)); CALL_SUBTEST_11(testLogThenExp(Matrix3f(), 1e-4)); CALL_SUBTEST_12(testLogThenExp(Matrix3e(), 1e-13)); }
void test_eigen2_eigensolver() { for(int i = 0; i < g_repeat; i++) { // very important to test a 3x3 matrix since we provide a special path for it CALL_SUBTEST_1( selfadjointeigensolver(Matrix3f()) ); CALL_SUBTEST_2( selfadjointeigensolver(Matrix4d()) ); CALL_SUBTEST_3( selfadjointeigensolver(MatrixXf(7,7)) ); CALL_SUBTEST_4( selfadjointeigensolver(MatrixXcd(5,5)) ); CALL_SUBTEST_5( selfadjointeigensolver(MatrixXd(19,19)) ); CALL_SUBTEST_6( eigensolver(Matrix4f()) ); CALL_SUBTEST_5( eigensolver(MatrixXd(17,17)) ); } }
void test_eigensolver_selfadjoint() { int s = 0; for(int i = 0; i < g_repeat; i++) { // very important to test 3x3 and 2x2 matrices since we provide special paths for them CALL_SUBTEST_1( selfadjointeigensolver(Matrix2f()) ); CALL_SUBTEST_1( selfadjointeigensolver(Matrix2d()) ); CALL_SUBTEST_1( selfadjointeigensolver(Matrix3f()) ); CALL_SUBTEST_1( selfadjointeigensolver(Matrix3d()) ); CALL_SUBTEST_2( selfadjointeigensolver(Matrix4d()) ); s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/4); CALL_SUBTEST_3( selfadjointeigensolver(MatrixXf(s,s)) ); s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/4); CALL_SUBTEST_4( selfadjointeigensolver(MatrixXd(s,s)) ); s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/4); CALL_SUBTEST_5( selfadjointeigensolver(MatrixXcd(s,s)) ); s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/4); CALL_SUBTEST_9( selfadjointeigensolver(Matrix<std::complex<double>,Dynamic,Dynamic,RowMajor>(s,s)) ); // some trivial but implementation-wise tricky cases CALL_SUBTEST_4( selfadjointeigensolver(MatrixXd(1,1)) ); CALL_SUBTEST_4( selfadjointeigensolver(MatrixXd(2,2)) ); CALL_SUBTEST_6( selfadjointeigensolver(Matrix<double,1,1>()) ); CALL_SUBTEST_7( selfadjointeigensolver(Matrix<double,2,2>()) ); } // Test problem size constructors s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/4); CALL_SUBTEST_8(SelfAdjointEigenSolver<MatrixXf> tmp1(s)); CALL_SUBTEST_8(Tridiagonalization<MatrixXf> tmp2(s)); TEST_SET_BUT_UNUSED_VARIABLE(s) }
void test_product_trsolve() { for(int i = 0; i < g_repeat ; i++) { // matrices CALL_SUBTEST_1((trsolve<float,Dynamic,Dynamic>(internal::random<int>(1,EIGEN_TEST_MAX_SIZE),internal::random<int>(1,EIGEN_TEST_MAX_SIZE)))); CALL_SUBTEST_2((trsolve<double,Dynamic,Dynamic>(internal::random<int>(1,EIGEN_TEST_MAX_SIZE),internal::random<int>(1,EIGEN_TEST_MAX_SIZE)))); CALL_SUBTEST_3((trsolve<std::complex<float>,Dynamic,Dynamic>(internal::random<int>(1,EIGEN_TEST_MAX_SIZE/2),internal::random<int>(1,EIGEN_TEST_MAX_SIZE/2)))); CALL_SUBTEST_4((trsolve<std::complex<double>,Dynamic,Dynamic>(internal::random<int>(1,EIGEN_TEST_MAX_SIZE/2),internal::random<int>(1,EIGEN_TEST_MAX_SIZE/2)))); // vectors CALL_SUBTEST_5((trsolve<float,Dynamic,1>(internal::random<int>(1,EIGEN_TEST_MAX_SIZE)))); CALL_SUBTEST_6((trsolve<double,Dynamic,1>(internal::random<int>(1,EIGEN_TEST_MAX_SIZE)))); CALL_SUBTEST_7((trsolve<std::complex<float>,Dynamic,1>(internal::random<int>(1,EIGEN_TEST_MAX_SIZE)))); CALL_SUBTEST_8((trsolve<std::complex<double>,Dynamic,1>(internal::random<int>(1,EIGEN_TEST_MAX_SIZE)))); // meta-unrollers CALL_SUBTEST_9((trsolve<float,4,1>())); CALL_SUBTEST_10((trsolve<double,4,1>())); CALL_SUBTEST_11((trsolve<std::complex<float>,4,1>())); CALL_SUBTEST_12((trsolve<float,1,1>())); CALL_SUBTEST_13((trsolve<float,1,2>())); CALL_SUBTEST_14((trsolve<float,3,1>())); } }
void test_eigen2_product_large() { for(int i = 0; i < g_repeat; i++) { CALL_SUBTEST_1( product(MatrixXf(ei_random<int>(1,320), ei_random<int>(1,320))) ); CALL_SUBTEST_2( product(MatrixXd(ei_random<int>(1,320), ei_random<int>(1,320))) ); CALL_SUBTEST_3( product(MatrixXi(ei_random<int>(1,320), ei_random<int>(1,320))) ); CALL_SUBTEST_4( product(MatrixXcf(ei_random<int>(1,50), ei_random<int>(1,50))) ); CALL_SUBTEST_5( product(Matrix<float,Dynamic,Dynamic,RowMajor>(ei_random<int>(1,320), ei_random<int>(1,320))) ); } #ifdef EIGEN_TEST_PART_6 { // test a specific issue in DiagonalProduct int N = 1000000; VectorXf v = VectorXf::Ones(N); MatrixXf m = MatrixXf::Ones(N,3); m = (v+v).asDiagonal() * m; VERIFY_IS_APPROX(m, MatrixXf::Constant(N,3,2)); } { // test deferred resizing in Matrix::operator= MatrixXf a = MatrixXf::Random(10,4), b = MatrixXf::Random(4,10), c = a; VERIFY_IS_APPROX((a = a * b), (c * b).eval()); } { MatrixXf mat1(10,10); mat1.setRandom(); MatrixXf mat2(32,10); mat2.setRandom(); MatrixXf result = mat1.row(2)*mat2.transpose(); VERIFY_IS_APPROX(result, (mat1.row(2)*mat2.transpose()).eval()); } #endif }
void test_adjoint() { for(int i = 0; i < g_repeat; i++) { CALL_SUBTEST_1( adjoint(Matrix<float, 1, 1>()) ); CALL_SUBTEST_2( adjoint(Matrix3d()) ); CALL_SUBTEST_3( adjoint(Matrix4f()) ); CALL_SUBTEST_4( adjoint(MatrixXcf(internal::random<int>(1,50), internal::random<int>(1,50))) ); CALL_SUBTEST_5( adjoint(MatrixXi(internal::random<int>(1,50), internal::random<int>(1,50))) ); CALL_SUBTEST_6( adjoint(MatrixXf(internal::random<int>(1,50), internal::random<int>(1,50))) ); } // test a large matrix only once CALL_SUBTEST_7( adjoint(Matrix<float, 100, 100>()) ); #ifdef EIGEN_TEST_PART_4 { MatrixXcf a(10,10), b(10,10); VERIFY_RAISES_ASSERT(a = a.transpose()); VERIFY_RAISES_ASSERT(a = a.transpose() + b); VERIFY_RAISES_ASSERT(a = b + a.transpose()); VERIFY_RAISES_ASSERT(a = a.conjugate().transpose()); VERIFY_RAISES_ASSERT(a = a.adjoint()); VERIFY_RAISES_ASSERT(a = a.adjoint() + b); VERIFY_RAISES_ASSERT(a = b + a.adjoint()); // no assertion should be triggered for these cases: a.transpose() = a.transpose(); a.transpose() += a.transpose(); a.transpose() += a.transpose() + b; a.transpose() = a.adjoint(); a.transpose() += a.adjoint(); a.transpose() += a.adjoint() + b; } #endif }
void test_nullary() { CALL_SUBTEST_1( testMatrixType(Matrix2d()) ); CALL_SUBTEST_2( testMatrixType(MatrixXcf(internal::random<int>(1,300),internal::random<int>(1,300))) ); CALL_SUBTEST_3( testMatrixType(MatrixXf(internal::random<int>(1,300),internal::random<int>(1,300))) ); for(int i = 0; i < g_repeat; i++) { CALL_SUBTEST_4( testVectorType(VectorXd(internal::random<int>(1,300))) ); CALL_SUBTEST_5( testVectorType(Vector4d()) ); // regression test for bug 232 CALL_SUBTEST_6( testVectorType(Vector3d()) ); CALL_SUBTEST_7( testVectorType(VectorXf(internal::random<int>(1,300))) ); CALL_SUBTEST_8( testVectorType(Vector3f()) ); CALL_SUBTEST_8( testVectorType(Vector4f()) ); CALL_SUBTEST_8( testVectorType(Matrix<float,8,1>()) ); CALL_SUBTEST_8( testVectorType(Matrix<float,1,1>()) ); CALL_SUBTEST_9( testVectorType(VectorXi(internal::random<int>(1,300))) ); CALL_SUBTEST_9( testVectorType(Matrix<int,1,1>()) ); } #ifdef EIGEN_TEST_PART_6 // Assignment of a RowVectorXd to a MatrixXd (regression test for bug #79). VERIFY( (MatrixXd(RowVectorXd::LinSpaced(3, 0, 1)) - RowVector3d(0, 0.5, 1)).norm() < std::numeric_limits<double>::epsilon() ); #endif }
void test_eigensolver_generic() { int s = 0; for(int i = 0; i < g_repeat; i++) { CALL_SUBTEST_1( eigensolver(Matrix4f()) ); s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/4); CALL_SUBTEST_2( eigensolver(MatrixXd(s,s)) ); // some trivial but implementation-wise tricky cases CALL_SUBTEST_2( eigensolver(MatrixXd(1,1)) ); CALL_SUBTEST_2( eigensolver(MatrixXd(2,2)) ); CALL_SUBTEST_3( eigensolver(Matrix<double,1,1>()) ); CALL_SUBTEST_4( eigensolver(Matrix2d()) ); } CALL_SUBTEST_1( eigensolver_verify_assert(Matrix4f()) ); s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/4); CALL_SUBTEST_2( eigensolver_verify_assert(MatrixXd(s,s)) ); CALL_SUBTEST_3( eigensolver_verify_assert(Matrix<double,1,1>()) ); CALL_SUBTEST_4( eigensolver_verify_assert(Matrix2d()) ); // Test problem size constructors CALL_SUBTEST_5(EigenSolver<MatrixXf> tmp(s)); // regression test for bug 410 CALL_SUBTEST_2( { MatrixXd A(1,1); A(0,0) = std::sqrt(-1.); Eigen::EigenSolver<MatrixXd> solver(A); MatrixXd V(1, 1); V(0,0) = solver.eigenvectors()(0,0).real(); } );
void test_eigensolver_generic() { int s = 0; for(int i = 0; i < g_repeat; i++) { CALL_SUBTEST_1( eigensolver(Matrix4f()) ); s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/4); CALL_SUBTEST_2( eigensolver(MatrixXd(s,s)) ); TEST_SET_BUT_UNUSED_VARIABLE(s) // some trivial but implementation-wise tricky cases CALL_SUBTEST_2( eigensolver(MatrixXd(1,1)) ); CALL_SUBTEST_2( eigensolver(MatrixXd(2,2)) ); CALL_SUBTEST_3( eigensolver(Matrix<double,1,1>()) ); CALL_SUBTEST_4( eigensolver(Matrix2d()) ); } CALL_SUBTEST_1( eigensolver_verify_assert(Matrix4f()) ); s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/4); CALL_SUBTEST_2( eigensolver_verify_assert(MatrixXd(s,s)) ); CALL_SUBTEST_3( eigensolver_verify_assert(Matrix<double,1,1>()) ); CALL_SUBTEST_4( eigensolver_verify_assert(Matrix2d()) ); // Test problem size constructors CALL_SUBTEST_5(EigenSolver<MatrixXf> tmp(s)); // regression test for bug 410 CALL_SUBTEST_2( { MatrixXd A(1,1); A(0,0) = std::sqrt(-1.); // is Not-a-Number Eigen::EigenSolver<MatrixXd> solver(A); VERIFY_IS_EQUAL(solver.info(), NumericalIssue); } );
void test_eigen2_sum() { for(int i = 0; i < g_repeat; i++) { CALL_SUBTEST_1( matrixSum(Matrix<float, 1, 1>()) ); CALL_SUBTEST_2( matrixSum(Matrix2f()) ); CALL_SUBTEST_3( matrixSum(Matrix4d()) ); CALL_SUBTEST_4( matrixSum(MatrixXcf(3, 3)) ); CALL_SUBTEST_5( matrixSum(MatrixXf(8, 12)) ); CALL_SUBTEST_6( matrixSum(MatrixXi(8, 12)) ); } for(int i = 0; i < g_repeat; i++) { CALL_SUBTEST_5( vectorSum(VectorXf(5)) ); CALL_SUBTEST_7( vectorSum(VectorXd(10)) ); CALL_SUBTEST_5( vectorSum(VectorXf(33)) ); } }
void test_basicstuff() { for(int i = 0; i < g_repeat; i++) { CALL_SUBTEST_1( basicStuff(Matrix<float, 1, 1>()) ); CALL_SUBTEST_2( basicStuff(Matrix4d()) ); CALL_SUBTEST_3( basicStuff(MatrixXcf(3, 3)) ); CALL_SUBTEST_4( basicStuff(MatrixXi(8, 12)) ); CALL_SUBTEST_5( basicStuff(MatrixXcd(20, 20)) ); CALL_SUBTEST_6( basicStuff(Matrix<float, 100, 100>()) ); CALL_SUBTEST_7( basicStuff(Matrix<long double,Dynamic,Dynamic>(10,10)) ); CALL_SUBTEST_3( basicStuffComplex(MatrixXcf(21, 17)) ); CALL_SUBTEST_5( basicStuffComplex(MatrixXcd(2, 3)) ); } CALL_SUBTEST_2(casting()); }
void test_matrix_exponential() { CALL_SUBTEST_2(test2dRotation<double>(1e-13)); CALL_SUBTEST_1(test2dRotation<float>(2e-5)); // was 1e-5, relaxed for clang 2.8 / linux / x86-64 CALL_SUBTEST_2(test2dHyperbolicRotation<double>(1e-14)); CALL_SUBTEST_1(test2dHyperbolicRotation<float>(1e-5)); CALL_SUBTEST_6(testPascal<float>(1e-6)); CALL_SUBTEST_5(testPascal<double>(1e-15)); CALL_SUBTEST_2(randomTest(Matrix2d(), 1e-13)); CALL_SUBTEST_7(randomTest(Matrix<double,3,3,RowMajor>(), 1e-13)); CALL_SUBTEST_3(randomTest(Matrix4cd(), 1e-13)); CALL_SUBTEST_4(randomTest(MatrixXd(8,8), 1e-13)); CALL_SUBTEST_1(randomTest(Matrix2f(), 1e-4)); CALL_SUBTEST_5(randomTest(Matrix3cf(), 1e-4)); CALL_SUBTEST_1(randomTest(Matrix4f(), 1e-4)); CALL_SUBTEST_6(randomTest(MatrixXf(8,8), 1e-4)); }
void test_basicstuff() { for(int i = 0; i < g_repeat; i++) { CALL_SUBTEST_1( basicStuff(Matrix<float, 1, 1>()) ); CALL_SUBTEST_2( basicStuff(Matrix4d()) ); CALL_SUBTEST_3( basicStuff(MatrixXcf(ei_random<int>(1,100), ei_random<int>(1,100))) ); CALL_SUBTEST_4( basicStuff(MatrixXi(ei_random<int>(1,100), ei_random<int>(1,100))) ); CALL_SUBTEST_5( basicStuff(MatrixXcd(ei_random<int>(1,100), ei_random<int>(1,100))) ); CALL_SUBTEST_6( basicStuff(Matrix<float, 100, 100>()) ); CALL_SUBTEST_7( basicStuff(Matrix<long double,Dynamic,Dynamic>(ei_random<int>(1,100),ei_random<int>(1,100))) ); CALL_SUBTEST_3( basicStuffComplex(MatrixXcf(ei_random<int>(1,100), ei_random<int>(1,100))) ); CALL_SUBTEST_5( basicStuffComplex(MatrixXcd(ei_random<int>(1,100), ei_random<int>(1,100))) ); } CALL_SUBTEST_2(casting()); }
void test_sparse_basic() { for(int i = 0; i < g_repeat; i++) { int r = Eigen::internal::random<int>(1,200), c = Eigen::internal::random<int>(1,200); if(Eigen::internal::random<int>(0,4) == 0) { r = c; // check square matrices in 25% of tries } EIGEN_UNUSED_VARIABLE(r+c); CALL_SUBTEST_1(( sparse_basic(SparseMatrix<double>(1, 1)) )); CALL_SUBTEST_1(( sparse_basic(SparseMatrix<double>(8, 8)) )); CALL_SUBTEST_2(( sparse_basic(SparseMatrix<std::complex<double>, ColMajor>(r, c)) )); CALL_SUBTEST_2(( sparse_basic(SparseMatrix<std::complex<double>, RowMajor>(r, c)) )); CALL_SUBTEST_1(( sparse_basic(SparseMatrix<double>(r, c)) )); CALL_SUBTEST_5(( sparse_basic(SparseMatrix<double,ColMajor,long int>(r, c)) )); CALL_SUBTEST_5(( sparse_basic(SparseMatrix<double,RowMajor,long int>(r, c)) )); r = Eigen::internal::random<int>(1,100); c = Eigen::internal::random<int>(1,100); if(Eigen::internal::random<int>(0,4) == 0) { r = c; // check square matrices in 25% of tries } CALL_SUBTEST_6(( sparse_basic(SparseMatrix<double,ColMajor,short int>(short(r), short(c))) )); CALL_SUBTEST_6(( sparse_basic(SparseMatrix<double,RowMajor,short int>(short(r), short(c))) )); } // Regression test for bug 900: (manually insert higher values here, if you have enough RAM): CALL_SUBTEST_3((big_sparse_triplet<SparseMatrix<float, RowMajor, int> >(10000, 10000, 0.125))); CALL_SUBTEST_4((big_sparse_triplet<SparseMatrix<double, ColMajor, long int> >(10000, 10000, 0.125))); // Regression test for bug 1105 #ifdef EIGEN_TEST_PART_7 { int n = Eigen::internal::random<int>(200,600); SparseMatrix<std::complex<double>,0, long> mat(n, n); std::complex<double> val; for(int i=0; i<n; ++i) { mat.coeffRef(i, i%(n/10)) = val; VERIFY(mat.data().allocatedSize()<20*n); } } #endif }
void test_vectorwiseop() { CALL_SUBTEST_1(vectorwiseop_array(Array22cd())); CALL_SUBTEST_2(vectorwiseop_array(Array<double, 3, 2>())); CALL_SUBTEST_3(vectorwiseop_array(ArrayXXf(3, 4))); CALL_SUBTEST_4(vectorwiseop_matrix(Matrix4cf())); CALL_SUBTEST_5(vectorwiseop_matrix(Matrix<float,4,5>())); CALL_SUBTEST_6(vectorwiseop_matrix(MatrixXd(7,2))); }
void test_schur_real() { CALL_SUBTEST_1(( schur<Matrix4f>() )); CALL_SUBTEST_2(( schur<MatrixXd>(internal::random<int>(1,50)) )); CALL_SUBTEST_3(( schur<Matrix<float, 1, 1> >() )); CALL_SUBTEST_4(( schur<Matrix<double, 3, 3, Eigen::RowMajor> >() )); // Test problem size constructors CALL_SUBTEST_5(RealSchur<MatrixXf>(10)); }
void test_stable_norm() { for(int i = 0; i < g_repeat; i++) { CALL_SUBTEST_1( stable_norm(Matrix<float, 1, 1>()) ); CALL_SUBTEST_2( stable_norm(Vector4d()) ); CALL_SUBTEST_3( stable_norm(VectorXd(internal::random<int>(10,2000))) ); CALL_SUBTEST_4( stable_norm(VectorXf(internal::random<int>(10,2000))) ); CALL_SUBTEST_5( stable_norm(VectorXcd(internal::random<int>(10,2000))) ); } }
void test_schur_complex() { CALL_SUBTEST_1(( schur<Matrix4cd>() )); CALL_SUBTEST_2(( schur<MatrixXcf>(internal::random<int>(1,EIGEN_TEST_MAX_SIZE/4)) )); CALL_SUBTEST_3(( schur<Matrix<std::complex<float>, 1, 1> >() )); CALL_SUBTEST_4(( schur<Matrix<float, 3, 3, Eigen::RowMajor> >() )); // Test problem size constructors CALL_SUBTEST_5(ComplexSchur<MatrixXf>(10)); }