diff options
author | Benoit Jacob <jacob.benoit.1@gmail.com> | 2011-01-20 10:36:32 -0500 |
---|---|---|
committer | Benoit Jacob <jacob.benoit.1@gmail.com> | 2011-01-20 10:36:32 -0500 |
commit | 34d93686db8f2df73b9bd7398ba841b11fbc3a7f (patch) | |
tree | b11bf509fc049156965fce78adea49f4f12017ac /test | |
parent | 66a2ffa9bdcaf97fcc7dbcf0cb882d58f49a7483 (diff) |
lots more EIGEN2_SUPPORT fixes. Now several of the most important core tests build and succeed.
Diffstat (limited to 'test')
-rw-r--r-- | test/eigen2/array.cpp | 6 | ||||
-rw-r--r-- | test/eigen2/main.h | 31 | ||||
-rw-r--r-- | test/eigen2/sizeof.cpp | 2 |
3 files changed, 19 insertions, 20 deletions
diff --git a/test/eigen2/array.cpp b/test/eigen2/array.cpp index 8b4652561..2ea5ebd65 100644 --- a/test/eigen2/array.cpp +++ b/test/eigen2/array.cpp @@ -61,7 +61,7 @@ template<typename MatrixType> void array(const MatrixType& m) VERIFY_IS_APPROX(m1.rowwise().sum().sum(), m1.sum()); if (!ei_isApprox(m1.sum(), (m1+m2).sum())) VERIFY_IS_NOT_APPROX(((m1+m2).rowwise().sum()).sum(), m1.sum()); - VERIFY_IS_APPROX(m1.colwise().sum(), m1.colwise().redux(ei_scalar_sum_op<Scalar>())); + VERIFY_IS_APPROX(m1.colwise().sum(), m1.colwise().redux(internal::scalar_sum_op<Scalar>())); } template<typename MatrixType> void comparisons(const MatrixType& m) @@ -115,8 +115,8 @@ template<typename MatrixType> void comparisons(const MatrixType& m) // count VERIFY(((m1.cwise().abs().cwise()+1).cwise()>RealScalar(0.1)).count() == rows*cols); - VERIFY_IS_APPROX(((m1.cwise().abs().cwise()+1).cwise()>RealScalar(0.1)).colwise().count(), RowVectorXi::Constant(cols,rows)); - VERIFY_IS_APPROX(((m1.cwise().abs().cwise()+1).cwise()>RealScalar(0.1)).rowwise().count(), VectorXi::Constant(rows, cols)); + VERIFY_IS_APPROX(((m1.cwise().abs().cwise()+1).cwise()>RealScalar(0.1)).colwise().count().template cast<int>(), RowVectorXi::Constant(cols,rows)); + VERIFY_IS_APPROX(((m1.cwise().abs().cwise()+1).cwise()>RealScalar(0.1)).rowwise().count().template cast<int>(), VectorXi::Constant(rows, cols)); } template<typename VectorType> void lpNorm(const VectorType& v) diff --git a/test/eigen2/main.h b/test/eigen2/main.h index 65d56377a..e144a28b1 100644 --- a/test/eigen2/main.h +++ b/test/eigen2/main.h @@ -58,10 +58,10 @@ namespace Eigen // This may happen when a second exceptions is raise in a destructor. static bool no_more_assert = false; - struct ei_assert_exception + struct eigen_assert_exception { - ei_assert_exception(void) {} - ~ei_assert_exception() { Eigen::no_more_assert = false; } + eigen_assert_exception(void) {} + ~eigen_assert_exception() { Eigen::no_more_assert = false; } }; } @@ -77,51 +77,50 @@ namespace Eigen namespace Eigen { static bool ei_push_assert = false; - static std::vector<std::string> ei_assert_list; + static std::vector<std::string> eigen_assert_list; } - #define ei_assert(a) \ + #define eigen_assert(a) \ if( (!(a)) && (!no_more_assert) ) \ { \ Eigen::no_more_assert = true; \ - throw Eigen::ei_assert_exception(); \ + throw Eigen::eigen_assert_exception(); \ } \ else if (Eigen::ei_push_assert) \ { \ - ei_assert_list.push_back(std::string(EI_PP_MAKE_STRING(__FILE__)" ("EI_PP_MAKE_STRING(__LINE__)") : "#a) ); \ + eigen_assert_list.push_back(std::string(EI_PP_MAKE_STRING(__FILE__)" ("EI_PP_MAKE_STRING(__LINE__)") : "#a) ); \ } #define VERIFY_RAISES_ASSERT(a) \ { \ Eigen::no_more_assert = false; \ try { \ - Eigen::ei_assert_list.clear(); \ + Eigen::eigen_assert_list.clear(); \ Eigen::ei_push_assert = true; \ a; \ Eigen::ei_push_assert = false; \ std::cerr << "One of the following asserts should have been raised:\n"; \ - for (uint ai=0 ; ai<ei_assert_list.size() ; ++ai) \ - std::cerr << " " << ei_assert_list[ai] << "\n"; \ + for (uint ai=0 ; ai<eigen_assert_list.size() ; ++ai) \ + std::cerr << " " << eigen_assert_list[ai] << "\n"; \ VERIFY(Eigen::should_raise_an_assert && # a); \ - } catch (Eigen::ei_assert_exception e) { \ + } catch (Eigen::eigen_assert_exception e) { \ Eigen::ei_push_assert = false; VERIFY(true); \ } \ } #else // EIGEN_DEBUG_ASSERTS - #undef ei_asset - #define ei_assert(a) \ + #define eigen_assert(a) \ if( (!(a)) && (!no_more_assert) ) \ { \ Eigen::no_more_assert = true; \ - throw Eigen::ei_assert_exception(); \ + throw Eigen::eigen_assert_exception(); \ } #define VERIFY_RAISES_ASSERT(a) { \ Eigen::no_more_assert = false; \ try { a; VERIFY(Eigen::should_raise_an_assert && # a); } \ - catch (Eigen::ei_assert_exception e) { VERIFY(true); } \ + catch (Eigen::eigen_assert_exception e) { VERIFY(true); } \ } #endif // EIGEN_DEBUG_ASSERTS @@ -143,7 +142,7 @@ namespace Eigen #define VERIFY(a) do { if (!(a)) { \ std::cerr << "Test " << g_test_stack.back() << " failed in "EI_PP_MAKE_STRING(__FILE__) << " (" << EI_PP_MAKE_STRING(__LINE__) << ")" \ << std::endl << " " << EI_PP_MAKE_STRING(a) << std::endl << std::endl; \ - std::exit(2); \ + abort(); \ } } while (0) #define VERIFY_IS_APPROX(a, b) VERIFY(test_ei_isApprox(a, b)) diff --git a/test/eigen2/sizeof.cpp b/test/eigen2/sizeof.cpp index 6c0485ae1..6ccb2330c 100644 --- a/test/eigen2/sizeof.cpp +++ b/test/eigen2/sizeof.cpp @@ -30,7 +30,7 @@ template<typename MatrixType> void verifySizeOf(const MatrixType&) if (MatrixType::RowsAtCompileTime!=Dynamic && MatrixType::ColsAtCompileTime!=Dynamic) VERIFY(sizeof(MatrixType)==sizeof(Scalar)*MatrixType::SizeAtCompileTime); else - VERIFY(sizeof(MatrixType)==sizeof(Scalar*) + 2 * sizeof(int)); + VERIFY(sizeof(MatrixType)==sizeof(Scalar*) + 2 * sizeof(typename MatrixType::Index)); } void test_sizeof() |