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_sparse_block() { 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_block(SparseMatrix<double>(1, 1)) )); CALL_SUBTEST_1(( sparse_block(SparseMatrix<double>(8, 8)) )); CALL_SUBTEST_1(( sparse_block(SparseMatrix<double>(r, c)) )); CALL_SUBTEST_2(( sparse_block(SparseMatrix<std::complex<double>, ColMajor>(r, c)) )); CALL_SUBTEST_2(( sparse_block(SparseMatrix<std::complex<double>, RowMajor>(r, c)) )); CALL_SUBTEST_3(( sparse_block(SparseMatrix<double,ColMajor,long int>(r, c)) )); CALL_SUBTEST_3(( sparse_block(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_4(( sparse_block(SparseMatrix<double,ColMajor,short int>(short(r), short(c))) )); CALL_SUBTEST_4(( sparse_block(SparseMatrix<double,RowMajor,short int>(short(r), short(c))) )); } }
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))) ); } }
// Visual studio doesn't implement a rand_r() function since its // implementation of rand() is already thread safe int rand_reentrant(unsigned int* s) { #ifdef EIGEN_COMP_MSVC_STRICT EIGEN_UNUSED_VARIABLE(s); return rand(); #else return rand_r(s); #endif }
void test_triangular() { for(int i = 0; i < g_repeat ; i++) { int r = ei_random<int>(2,20); EIGEN_UNUSED_VARIABLE(r); int c = ei_random<int>(2,20); EIGEN_UNUSED_VARIABLE(c); CALL_SUBTEST_1( triangular_square(Matrix<float, 1, 1>()) ); CALL_SUBTEST_2( triangular_square(Matrix<float, 2, 2>()) ); CALL_SUBTEST_3( triangular_square(Matrix3d()) ); CALL_SUBTEST_4( triangular_square(Matrix<std::complex<float>,8, 8>()) ); CALL_SUBTEST_5( triangular_square(MatrixXcd(r,r)) ); CALL_SUBTEST_6( triangular_square(Matrix<float,Dynamic,Dynamic,RowMajor>(r, r)) ); CALL_SUBTEST_7( triangular_rect(Matrix<float, 4, 5>()) ); CALL_SUBTEST_8( triangular_rect(Matrix<double, 6, 2>()) ); CALL_SUBTEST_9( triangular_rect(MatrixXcf(r, c)) ); CALL_SUBTEST_5( triangular_rect(MatrixXcd(r, c)) ); CALL_SUBTEST_6( triangular_rect(Matrix<float,Dynamic,Dynamic,RowMajor>(r, c)) ); } }
void test_selfadjoint() { for(int i = 0; i < g_repeat ; i++) { int s = internal::random<int>(1,20); EIGEN_UNUSED_VARIABLE(s); CALL_SUBTEST_1( selfadjoint(Matrix<float, 1, 1>()) ); CALL_SUBTEST_2( selfadjoint(Matrix<float, 2, 2>()) ); CALL_SUBTEST_3( selfadjoint(Matrix3cf()) ); CALL_SUBTEST_4( selfadjoint(MatrixXcd(s,s)) ); CALL_SUBTEST_5( selfadjoint(Matrix<float,Dynamic,Dynamic,RowMajor>(s, s)) ); } CALL_SUBTEST_1( bug_159() ); }
void test_sparse_vector() { for(int i = 0; i < g_repeat; i++) { int r = Eigen::internal::random<int>(1,500), c = Eigen::internal::random<int>(1,500); 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_vector<double,int>(8, 8) )); CALL_SUBTEST_2(( sparse_vector<std::complex<double>, int>(r, c) )); CALL_SUBTEST_1(( sparse_vector<double,long int>(r, c) )); CALL_SUBTEST_1(( sparse_vector<double,short>(r, c) )); } }
void test_product_trmv() { int s; for(int i = 0; i < g_repeat ; i++) { CALL_SUBTEST_1( trmv(Matrix<float, 1, 1>()) ); CALL_SUBTEST_2( trmv(Matrix<float, 2, 2>()) ); CALL_SUBTEST_3( trmv(Matrix3d()) ); s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/2); CALL_SUBTEST_4( trmv(MatrixXcf(s,s)) ); s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/2); CALL_SUBTEST_5( trmv(MatrixXcd(s,s)) ); s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE); CALL_SUBTEST_6( trmv(Matrix<float,Dynamic,Dynamic,RowMajor>(s, s)) ); } EIGEN_UNUSED_VARIABLE(s); }
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 }