Go to the documentation of this file.
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
189 static std::vector<EigenTest*>* ms_registered_tests =
new std::vector<EigenTest*>();
190 return *ms_registered_tests;
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;
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;
752 std::cout <<
"Invalid repeat value " <<
str << std::endl;
764 std::cout <<
"Invalid seed value " <<
str << std::endl;
770 int main(
int argc,
char *argv[])
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");
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;
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)
eigen_assert_exception(void)
static std::vector< std::string > g_test_stack
static unsigned int g_seed
Namespace containing all symbols from the Eigen library.
bool isMinusInf(const T &x)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
static const double d[K][N]
EIGEN_DEVICE_FUNC bool isApproxOrLessThan(const Scalar &x, const Scalar &y, const typename NumTraits< Scalar >::Real &precision=NumTraits< Scalar >::dummy_precision())
bool isNotNaN(const T &x)
bool test_is_equal(const T &actual, const U &expected, bool expect_equal=true)
static bool g_has_set_seed
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
Represents a 3D rotation as a rotation angle around an arbitrary 3D axis.
bool test_isApproxWithRef(const Scalar &a, const Scalar &b, const ScalarRef &ref)
bool isPlusInf(const T &x)
internal::enable_if< internal::is_same< T1, T2 >::value, bool >::type is_same_type(const T1 &, const T2 &)
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 isMuchSmallerThan(const Scalar &x, const OtherScalar &y, const typename NumTraits< Scalar >::Real &precision=NumTraits< Scalar >::dummy_precision())
bool test_isMuchSmallerThan(const std::complex< float > &a, const std::complex< float > &b)
void on_temporary_creation()
NumTraits< typename T1::RealScalar >::NonInteger test_relative_error(const EigenBase< T1 > &a, const EigenBase< T2 > &b)
static const std::vector< EigenTest * > & all()
bool verifyIsApprox(const Type1 &a, const Type2 &b)
static std::stringstream ss
std::string type_name< int >()
void set_repeat_from_string(const char *str)
std::complex< typename GetDifferentType< T >::type > type
bool test_isApprox(const std::complex< float > &a, const std::complex< float > &b)
eigen_static_assert_exception(void)
HouseholderSequenceType householderQ() const
static bool g_has_set_repeat
static long int nb_temporaries
void createRandomPIMatrixOfRank(Index desired_rank, Index rows, Index cols, MatrixType &m)
NumTraits< T >::Real test_precision()
static bool no_more_assert
~eigen_assert_exception()
double test_precision< double >()
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T mini(const T &x, const T &y)
bool test_isUnitary(const MatrixBase< Derived > &m)
static const Line3 l(Rot3(), 1, 1)
float test_precision< float >()
void swap(GeographicLib::NearestNeighbor< dist_t, pos_t, distfun_t > &a, GeographicLib::NearestNeighbor< dist_t, pos_t, distfun_t > &b)
long double test_precision< long double >()
static const Pose3 T2(Rot3::Rodrigues(0.3, 0.2, 0.1), P2)
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE CwiseAbs2ReturnType cwiseAbs2() const
Represents a rotation/orientation in a 2 dimensional space.
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
NumTraits< Scalar >::Real RealScalar
std::string type_name< long double >()
EIGEN_DEVICE_FUNC bool abs2(bool x)
bool test_isApproxOrLessThan(const long double &a, const long double &b)
static std::vector< EigenTest * > & get_registered_tests()
EigenTest(const char *a_name, void(*func)(void))
mp::number< mp::cpp_dec_float< 100 >, mp::et_on > Real
Reference counting helper.
#define EIGEN_TEST_SCALAR_TEST_OVERLOAD(TYPE)
Array< int, Dynamic, 1 > v
Base class of any sparse matrices or sparse expressions.
void set_seed_from_string(const char *str)
void randomPermutationVector(PermutationVectorType &v, Index size)
Represents a translation transformation.
~eigen_static_assert_exception()
std::string type_name< double >()
Base class for all dense matrices, vectors, and expressions.
int main(int argc, char *argv[])
static const Similarity3 T1(R, Point3(3.5, -8.2, 4.2), 1)
NumTraits< typename T::Scalar >::Real get_test_precision(const T &, const typename T::Scalar *=0)
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float sqrt(const float &x)
static bool report_on_cerr_on_assert_failure
std::string type_name< float >()
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
static const bool should_raise_an_assert
Jet< T, N > sqrt(const Jet< T, N > &f)
void verify_impl(bool condition, const char *testname, const char *file, int line, const char *condition_as_string)
Householder QR decomposition of a matrix.
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
const std::string & name() const
gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:02:44