mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
lots more EIGEN2_SUPPORT fixes. Now several of the most important core tests build and succeed.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user