44 #define _OVERRIDE_COMPLEX_SPECIALIZATION_ 1 50 #if __cplusplus >= 201103L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201103L) 53 #ifdef EIGEN_USE_THREADS 59 #if defined(__CUDACC__) && !defined(EIGEN_NO_CUDA) 61 #define EIGEN_CUDACC __CUDACC__ 63 #if defined(EIGEN_CUDACC) 65 #define EIGEN_CUDA_SDK_VER (CUDA_VERSION * 10) 67 #define EIGEN_CUDA_SDK_VER 0 69 #if EIGEN_CUDA_SDK_VER >= 70500 70 #include <cuda_fp16.h> 77 #if !defined(__HIPCC__) && !defined(EIGEN_USE_SYCL) 91 #define min(A,B) please_protect_your_min_with_parentheses 92 #define max(A,B) please_protect_your_max_with_parentheses 93 #define isnan(X) please_protect_your_isnan_with_parentheses 94 #define isinf(X) please_protect_your_isinf_with_parentheses 95 #define isfinite(X) please_protect_your_isfinite_with_parentheses 106 #define M_PI please_use_EIGEN_PI_instead_of_M_PI 108 #define FORBIDDEN_IDENTIFIER (this_identifier_is_forbidden_to_avoid_clashes) this_identifier_is_forbidden_to_avoid_clashes 110 #define B0 FORBIDDEN_IDENTIFIER 112 #define I FORBIDDEN_IDENTIFIER 116 #ifndef EIGEN_NO_DEBUG_SMALL_PRODUCT_BLOCKS 117 #define EIGEN_DEBUG_SMALL_PRODUCT_BLOCKS 121 #define TEST_SET_BUT_UNUSED_VARIABLE(X) EIGEN_UNUSED_VARIABLE(X) 123 #ifdef TEST_ENABLE_TEMPORARY_TRACKING 126 static long int nb_temporaries_on_assert = -1;
131 if(nb_temporaries_on_assert>0) assert(
nb_temporaries<nb_temporaries_on_assert);
134 #define EIGEN_DENSE_STORAGE_CTOR_PLUGIN { on_temporary_creation(size); } 136 #define VERIFY_EVALUATION_COUNT(XPR,N) {\ 137 nb_temporaries = 0; \ 139 if(nb_temporaries!=(N)) { std::cerr << "nb_temporaries == " << nb_temporaries << "\n"; }\ 140 VERIFY( (#XPR) && nb_temporaries==(N) ); \ 157 #if defined(__ALTIVEC__) || defined(__VSX__) 158 #define EIGEN_MAKING_DOCS 161 #define DEFAULT_REPEAT 10 178 : m_name(a_name), m_func(
func)
180 get_registered_tests().push_back(
this);
182 const std::string&
name()
const {
return m_name; }
185 static const std::vector<EigenTest*>&
all() {
return get_registered_tests(); }
189 static std::vector<EigenTest*>* ms_registered_tests =
new std::vector<EigenTest*>();
190 return *ms_registered_tests;
193 void (*m_func)(void);
201 #define EIGEN_DECLARE_TEST(X) \ 202 void EIGEN_CAT(test_,X) (); \ 203 static EigenTest EIGEN_CAT(test_handler_,X) (EIGEN_MAKESTRING(X), & EIGEN_CAT(test_,X)); \ 204 void EIGEN_CAT(test_,X) () 207 #define TRACK std::cerr << __FILE__ << " " << __LINE__ << std::endl 210 #define EIGEN_DEFAULT_IO_FORMAT IOFormat(4, 0, " ", "\n", "", "", "", "") 212 #if (defined(_CPPUNWIND) || defined(__EXCEPTIONS)) && !defined(__CUDA_ARCH__) && !defined(__HIP_DEVICE_COMPILE__) && !defined(__SYCL_DEVICE_ONLY__) 213 #define EIGEN_EXCEPTIONS 216 #ifndef EIGEN_NO_ASSERTION_CHECKING 247 #ifdef EIGEN_DEBUG_ASSERTS 253 static bool push_assert =
false;
255 static std::vector<std::string> eigen_assert_list;
257 #define eigen_assert(a) \ 258 if( (!(a)) && (!no_more_assert) ) \ 260 if(report_on_cerr_on_assert_failure) \ 261 std::cerr << #a << " " __FILE__ << "(" << __LINE__ << ")\n"; \ 262 Eigen::no_more_assert = true; \ 263 EIGEN_THROW_X(Eigen::eigen_assert_exception()); \ 265 else if (Eigen::internal::push_assert) \ 267 eigen_assert_list.push_back(std::string(EIGEN_MAKESTRING(__FILE__) " (" EIGEN_MAKESTRING(__LINE__) ") : " #a) ); \ 270 #ifdef EIGEN_EXCEPTIONS 271 #define VERIFY_RAISES_ASSERT(a) \ 273 Eigen::no_more_assert = false; \ 274 Eigen::eigen_assert_list.clear(); \ 275 Eigen::internal::push_assert = true; \ 276 Eigen::report_on_cerr_on_assert_failure = false; \ 279 std::cerr << "One of the following asserts should have been triggered:\n"; \ 280 for (uint ai=0 ; ai<eigen_assert_list.size() ; ++ai) \ 281 std::cerr << " " << eigen_assert_list[ai] << "\n"; \ 282 VERIFY(Eigen::should_raise_an_assert && # a); \ 283 } catch (Eigen::eigen_assert_exception) { \ 284 Eigen::internal::push_assert = false; VERIFY(true); \ 286 Eigen::report_on_cerr_on_assert_failure = true; \ 287 Eigen::internal::push_assert = false; \ 289 #endif //EIGEN_EXCEPTIONS 291 #elif !defined(__CUDACC__) && !defined(__HIPCC__) && !defined(SYCL_DEVICE_ONLY) // EIGEN_DEBUG_ASSERTS 293 #define eigen_assert(a) \ 294 if( (!Eigen::internal::copy_bool(a)) && (!no_more_assert) )\ 296 Eigen::no_more_assert = true; \ 297 if(report_on_cerr_on_assert_failure) \ 298 eigen_plain_assert(a); \ 300 EIGEN_THROW_X(Eigen::eigen_assert_exception()); \ 303 #ifdef EIGEN_EXCEPTIONS 304 #define VERIFY_RAISES_ASSERT(a) { \ 305 Eigen::no_more_assert = false; \ 306 Eigen::report_on_cerr_on_assert_failure = false; \ 309 VERIFY(Eigen::should_raise_an_assert && # a); \ 311 catch (Eigen::eigen_assert_exception&) { VERIFY(true); } \ 312 Eigen::report_on_cerr_on_assert_failure = true; \ 314 #endif // EIGEN_EXCEPTIONS 315 #endif // EIGEN_DEBUG_ASSERTS 317 #if defined(TEST_CHECK_STATIC_ASSERTIONS) && defined(EIGEN_EXCEPTIONS) 318 #define EIGEN_STATIC_ASSERT(a,MSG) \ 319 if( (!Eigen::internal::copy_bool(a)) && (!no_more_assert) )\ 321 Eigen::no_more_assert = true; \ 322 if(report_on_cerr_on_assert_failure) \ 323 eigen_plain_assert((a) && #MSG); \ 325 EIGEN_THROW_X(Eigen::eigen_static_assert_exception()); \ 327 #define VERIFY_RAISES_STATIC_ASSERT(a) { \ 328 Eigen::no_more_assert = false; \ 329 Eigen::report_on_cerr_on_assert_failure = false; \ 332 VERIFY(Eigen::should_raise_an_assert && # a); \ 334 catch (Eigen::eigen_static_assert_exception&) { VERIFY(true); } \ 335 Eigen::report_on_cerr_on_assert_failure = true; \ 337 #endif // TEST_CHECK_STATIC_ASSERTIONS 339 #ifndef VERIFY_RAISES_ASSERT 340 #define VERIFY_RAISES_ASSERT(a) \ 341 std::cout << "Can't VERIFY_RAISES_ASSERT( " #a " ) with exceptions disabled\n"; 343 #ifndef VERIFY_RAISES_STATIC_ASSERT 344 #define VERIFY_RAISES_STATIC_ASSERT(a) \ 345 std::cout << "Can't VERIFY_RAISES_STATIC_ASSERT( " #a " ) with exceptions disabled\n"; 348 #if !defined(__CUDACC__) && !defined(__HIPCC__) && !defined(SYCL_DEVICE_ONLY) 349 #define EIGEN_USE_CUSTOM_ASSERT 352 #else // EIGEN_NO_ASSERTION_CHECKING 354 #define VERIFY_RAISES_ASSERT(a) {} 355 #define VERIFY_RAISES_STATIC_ASSERT(a) {} 357 #endif // EIGEN_NO_ASSERTION_CHECKING 359 #define EIGEN_INTERNAL_DEBUGGING 362 inline void verify_impl(
bool condition,
const char *testname,
const char *
file,
int line,
const char *condition_as_string)
367 std::cerr <<
"WARNING: ";
368 std::cerr <<
"Test " << testname <<
" failed in " << file <<
" (" << line <<
")" 369 << std::endl <<
" " << condition_as_string << std::endl;
370 std::cerr <<
"Stack:\n";
372 for(
int i=test_stack_size-1;
i>=0; --
i)
380 #define VERIFY(a) ::verify_impl(a, g_test_stack.back().c_str(), __FILE__, __LINE__, EIGEN_MAKESTRING(a)) 382 #define VERIFY_GE(a, b) ::verify_impl(a >= b, g_test_stack.back().c_str(), __FILE__, __LINE__, EIGEN_MAKESTRING(a >= b)) 383 #define VERIFY_LE(a, b) ::verify_impl(a <= b, g_test_stack.back().c_str(), __FILE__, __LINE__, EIGEN_MAKESTRING(a <= b)) 386 #define VERIFY_IS_EQUAL(a, b) VERIFY(test_is_equal(a, b, true)) 387 #define VERIFY_IS_NOT_EQUAL(a, b) VERIFY(test_is_equal(a, b, false)) 388 #define VERIFY_IS_APPROX(a, b) VERIFY(verifyIsApprox(a, b)) 389 #define VERIFY_IS_NOT_APPROX(a, b) VERIFY(!test_isApprox(a, b)) 390 #define VERIFY_IS_MUCH_SMALLER_THAN(a, b) VERIFY(test_isMuchSmallerThan(a, b)) 391 #define VERIFY_IS_NOT_MUCH_SMALLER_THAN(a, b) VERIFY(!test_isMuchSmallerThan(a, b)) 392 #define VERIFY_IS_APPROX_OR_LESS_THAN(a, b) VERIFY(test_isApproxOrLessThan(a, b)) 393 #define VERIFY_IS_NOT_APPROX_OR_LESS_THAN(a, b) VERIFY(!test_isApproxOrLessThan(a, b)) 395 #define VERIFY_IS_UNITARY(a) VERIFY(test_isUnitary(a)) 397 #define STATIC_CHECK(COND) EIGEN_STATIC_ASSERT( (COND) , EIGEN_INTERNAL_ERROR_PLEASE_FILE_A_BUG_REPORT ) 399 #define CALL_SUBTEST(FUNC) do { \ 400 g_test_stack.push_back(EIGEN_MAKESTRING(FUNC)); \ 402 g_test_stack.pop_back(); \ 408 template<
typename T1,
typename T2>
423 #define EIGEN_TEST_SCALAR_TEST_OVERLOAD(TYPE) \ 424 inline bool test_isApprox(TYPE a, TYPE b) \ 425 { return internal::isApprox(a, b, test_precision<TYPE>()); } \ 426 inline bool test_isMuchSmallerThan(TYPE a, TYPE b) \ 427 { return internal::isMuchSmallerThan(a, b, test_precision<TYPE>()); } \ 428 inline bool test_isApproxOrLessThan(TYPE a, TYPE b) \ 429 { return internal::isApproxOrLessThan(a, b, test_precision<TYPE>()); } 446 #undef EIGEN_TEST_SCALAR_TEST_OVERLOAD 448 #ifndef EIGEN_TEST_NO_COMPLEX 454 inline bool test_isApprox(
const std::complex<double>&
a,
const std::complex<double>&
b)
459 #ifndef EIGEN_TEST_NO_LONGDOUBLE 460 inline bool test_isApprox(
const std::complex<long double>&
a,
const std::complex<long double>&
b)
467 #ifndef EIGEN_TEST_NO_LONGDOUBLE 472 << std::endl <<
" actual = " << a
473 << std::endl <<
" expected = " << b << std::endl << std::endl;
481 #endif // EIGEN_TEST_NO_LONGDOUBLE 484 template<
typename T1,
typename T2>
494 template<
typename T1,
typename T2>
500 template<
typename T1,
typename T2>
506 template<
typename S,
int D>
512 template <
typename S,
int D,
int O>
518 template <
typename S,
int D>
525 template<
typename T1,
typename T2>
532 template<
typename T1,
typename T2>
539 template<
typename T1,
typename T2>
545 template<
typename T1,
typename T2>
564 template<
typename Type1,
typename Type2>
567 return a.isApprox(b, test_precision<typename Type1::Scalar>());
584 template<
typename Type1,
typename Type2>
602 template<
typename Scalar,
typename ScalarRef>
608 template<
typename Derived1,
typename Derived2>
615 template<
typename Derived>
622 template<
typename Derived>
629 template<
typename T,
typename U>
632 template<
typename T,
typename U>
635 if ((actual==expected) == expect_equal)
639 <<
"\n actual = " << actual
640 <<
"\n expected " << (expect_equal ?
"= " :
"!=") << expected <<
"\n\n";
650 template<
typename MatrixType>
652 template<
typename MatrixType>
656 enum { Rows = MatrixType::RowsAtCompileTime,
Cols = MatrixType::ColsAtCompileTime };
662 if(desired_rank == 0)
668 if(desired_rank == 1)
671 m = VectorType::Random(rows).normalized() * VectorType::Random(cols).normalized().transpose();
675 MatrixAType
a = MatrixAType::Random(rows,rows);
677 MatrixBType
b = MatrixBType::Random(cols,cols);
681 if(diag_size != desired_rank)
682 d.diagonal().segment(desired_rank, diag_size-desired_rank) = VectorType::Zero(diag_size-desired_rank);
690 template<
typename PermutationVectorType>
692 template<
typename PermutationVectorType>
698 if(size == 1)
return;
701 Index i = internal::random<Index>(0, size-1);
703 do j = internal::random<Index>(0, size-1);
while(j==i);
720 return x < NumTraits<T>::lowest();
733 template<
typename T> std::string
type_name();
734 template<
typename T> std::string
type_name() {
return "other"; }
739 template<> std::string type_name<std::complex<float> >() {
return "complex<float>"; }
740 template<> std::string type_name<std::complex<double> >() {
return "complex<double>"; }
741 template<> std::string type_name<std::complex<long double> >() {
return "complex<long double>"; }
742 template<> std::string type_name<std::complex<int> >() {
return "complex<int>"; }
744 using namespace Eigen;
749 g_repeat =
int(strtoul(str, 0, 10));
750 if(errno || g_repeat <= 0)
752 std::cout <<
"Invalid repeat value " << str << std::endl;
755 g_has_set_repeat =
true;
761 g_seed =
int(strtoul(str, 0, 10));
762 if(errno || g_seed == 0)
764 std::cout <<
"Invalid seed value " << str << std::endl;
770 int main(
int argc,
char *argv[])
772 g_has_set_repeat =
false;
774 bool need_help =
false;
776 for(
int i = 1;
i < argc;
i++)
778 if(argv[
i][0] ==
'r')
782 std::cout <<
"Argument " << argv[
i] <<
" conflicting with a former argument" << std::endl;
787 else if(argv[
i][0] ==
's')
791 std::cout <<
"Argument " << argv[
i] <<
" conflicting with a former argument" << std::endl;
804 std::cout <<
"This test application takes the following optional arguments:" << std::endl;
805 std::cout <<
" rN Repeat each test N times (default: " <<
DEFAULT_REPEAT <<
")" << std::endl;
806 std::cout <<
" sN Use N as seed for random numbers (default: based on current time)" << std::endl;
807 std::cout << std::endl;
808 std::cout <<
"If defined, the environment variables EIGEN_REPEAT and EIGEN_SEED" << std::endl;
809 std::cout <<
"will be used as default values for these parameters." << std::endl;
813 char *env_EIGEN_REPEAT = getenv(
"EIGEN_REPEAT");
814 if(!g_has_set_repeat && env_EIGEN_REPEAT)
816 char *env_EIGEN_SEED = getenv(
"EIGEN_SEED");
823 std::cout <<
"Initializing random number generator with seed " << g_seed << std::endl;
824 std::stringstream
ss;
826 g_test_stack.push_back(ss.str());
828 std::cout <<
"Repeating each test " << g_repeat <<
" times" << std::endl;
844 #if defined __INTEL_COMPILER 851 #pragma warning disable 279 383 1418 1572 856 #pragma warning( disable : 4503) AnnoyingScalar test_relative_error(const AnnoyingScalar &a, const AnnoyingScalar &b)
EIGEN_DEVICE_FUNC const VectorType &() min() const
long double test_precision< long double >()
EIGEN_DEVICE_FUNC bool isMuchSmallerThan(const Scalar &x, const OtherScalar &y, const typename NumTraits< Scalar >::Real &precision=NumTraits< Scalar >::dummy_precision())
EIGEN_DEVICE_FUNC Derived & setZero(Index size)
eigen_static_assert_exception(void)
#define EIGEN_TEST_SCALAR_TEST_OVERLOAD(TYPE)
static const Eigen::internal::all_t all
std::complex< typename GetDifferentType< T >::type > type
EIGEN_DEVICE_FUNC const VectorType & origin() const
static bool report_on_cerr_on_assert_failure
bool isNotNaN(const T &x)
bool isUnitary(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
bool test_isApproxOrLessThan(const long double &a, const long double &b)
Namespace containing all symbols from the Eigen library.
static const std::vector< EigenTest * > & all()
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
static const Pose3 T2(Rot3::Rodrigues(0.3, 0.2, 0.1), P2)
int main(int argc, char *argv[])
void verify_impl(bool condition, const char *testname, const char *file, int line, const char *condition_as_string)
float test_precision< float >()
void randomPermutationVector(PermutationVectorType &v, Index size)
bool test_isMuchSmallerThan(const AnnoyingScalar &a, const AnnoyingScalar &b)
static long int nb_temporaries
const std::string & name() const
~eigen_static_assert_exception()
void on_temporary_creation()
Represents a translation transformation.
void set_seed_from_string(const char *str)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Abs2ReturnType abs2() const
static bool g_has_set_seed
static const Line3 l(Rot3(), 1, 1)
Base class of any sparse matrices or sparse expressions.
bool test_isApproxWithRef(const Scalar &a, const Scalar &b, const ScalarRef &ref)
static bool g_has_set_repeat
bool test_isUnitary(const MatrixBase< Derived > &m)
EIGEN_DEVICE_FUNC const VectorType & vector() const
EIGEN_DEVICE_FUNC Scalar angle() const
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Array< int, Dynamic, 1 > v
AnnoyingScalar get_test_precision(const AnnoyingScalar &)
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
std::string type_name< double >()
double test_precision< double >()
eigen_assert_exception(void)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
HouseholderSequenceType householderQ() const
NumTraits< Scalar >::Real RealScalar
Reference counting helper.
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T mini(const T &x, const T &y)
void swap(GeographicLib::NearestNeighbor< dist_t, pos_t, distfun_t > &a, GeographicLib::NearestNeighbor< dist_t, pos_t, distfun_t > &b)
static std::vector< EigenTest * > & get_registered_tests()
static std::stringstream ss
EIGEN_DEVICE_FUNC const Vector3 & axis() const
std::string type_name< float >()
EigenTest(const char *a_name, void(*func)(void))
mp::number< mp::cpp_dec_float< 100 >, mp::et_on > Real
Represents a rotation/orientation in a 2 dimensional space.
internal::enable_if< internal::is_same< T1, T2 >::value, bool >::type is_same_type(const T1 &, const T2 &)
static bool no_more_assert
bool isPlusInf(const T &x)
static const Similarity3 T1(R, Point3(3.5, -8.2, 4.2), 1)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseAbs2ReturnType cwiseAbs2() const
static const bool should_raise_an_assert
bool test_isApprox(const AnnoyingScalar &a, const AnnoyingScalar &b)
Householder QR decomposition of a matrix.
void set_repeat_from_string(const char *str)
bool isMinusInf(const T &x)
NumTraits< T >::Real test_precision()
bool verifyIsApprox(const Eigen::EulerAngles< Scalar, System > &a, const Eigen::EulerAngles< Scalar, System > &b)
void createRandomPIMatrixOfRank(Index desired_rank, Index rows, Index cols, MatrixType &m)
Jet< T, N > sqrt(const Jet< T, N > &f)
DenseMatrixType toDense() const
Generic expression where a coefficient-wise unary operator is applied to an expression.
EIGEN_DEVICE_FUNC const VectorType &() max() const
EIGEN_DEVICE_FUNC bool isApprox(const Scalar &x, const Scalar &y, const typename NumTraits< Scalar >::Real &precision=NumTraits< Scalar >::dummy_precision())
EIGEN_DEVICE_FUNC bool isApproxOrLessThan(const Scalar &x, const Scalar &y, const typename NumTraits< Scalar >::Real &precision=NumTraits< Scalar >::dummy_precision())
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
EIGEN_DEVICE_FUNC Scalar angle() const
~eigen_assert_exception()
EIGEN_DEVICE_FUNC Derived & derived()
Base class for all dense matrices, vectors, and expressions.
Represents a 3D rotation as a rotation angle around an arbitrary 3D axis.
std::string type_name< int >()
EIGEN_DEVICE_FUNC bool isMuchSmallerThan(const RealScalar &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
std::string type_name< long double >()
static std::vector< std::string > g_test_stack
static unsigned int g_seed
bool test_is_equal(const T &actual, const U &expected, bool expect_equal=true)