Go to the documentation of this file.
26 #ifndef EIGEN_MACROS_H
27 #define EIGEN_MACROS_H
29 #define EIGEN_WORLD_VERSION 3
30 #define EIGEN_MAJOR_VERSION 0
31 #define EIGEN_MINOR_VERSION 93
33 #define EIGEN_VERSION_AT_LEAST(x,y,z) (EIGEN_WORLD_VERSION>x || (EIGEN_WORLD_VERSION>=x && \
34 (EIGEN_MAJOR_VERSION>y || (EIGEN_MAJOR_VERSION>=y && \
35 EIGEN_MINOR_VERSION>=z))))
37 #define EIGEN_GNUC_AT_LEAST(x,y) ((__GNUC__==x && __GNUC_MINOR__>=y) || __GNUC__>x)
39 #define EIGEN_GNUC_AT_LEAST(x,y) 0
43 #define EIGEN_GNUC_AT_MOST(x,y) ((__GNUC__==x && __GNUC_MINOR__<=y) || __GNUC__<x)
45 #define EIGEN_GNUC_AT_MOST(x,y) 0
48 #if EIGEN_GNUC_AT_MOST(4,3) && !defined(__clang__)
50 #define EIGEN_SAFE_TO_USE_STANDARD_ASSERT_MACRO 0
52 #define EIGEN_SAFE_TO_USE_STANDARD_ASSERT_MACRO 1
55 #if defined(__GNUC__) && (__GNUC__ <= 3)
56 #define EIGEN_GCC3_OR_OLDER 1
58 #define EIGEN_GCC3_OR_OLDER 0
68 #if defined(__GNUC__) && !(defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) || defined(__ppc__) || defined(__ia64__))
69 #define EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT 1
71 #define EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT 0
75 #if !EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT \
76 && !EIGEN_GCC3_OR_OLDER \
77 && !defined(__SUNPRO_CC) \
78 && !defined(__QNXNTO__)
79 #define EIGEN_ARCH_WANTS_STACK_ALIGNMENT 1
81 #define EIGEN_ARCH_WANTS_STACK_ALIGNMENT 0
84 #ifdef EIGEN_DONT_ALIGN
85 #ifndef EIGEN_DONT_ALIGN_STATICALLY
86 #define EIGEN_DONT_ALIGN_STATICALLY
95 #if EIGEN_ARCH_WANTS_STACK_ALIGNMENT && !defined(EIGEN_DONT_ALIGN_STATICALLY)
96 #define EIGEN_ALIGN_STATICALLY 1
98 #define EIGEN_ALIGN_STATICALLY 0
99 #ifndef EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT
100 #define EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT
104 #ifdef EIGEN_DEFAULT_TO_ROW_MAJOR
105 #define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION RowMajor
107 #define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION ColMajor
110 #ifndef EIGEN_DEFAULT_DENSE_INDEX_TYPE
111 #define EIGEN_DEFAULT_DENSE_INDEX_TYPE std::ptrdiff_t
119 #ifndef EIGEN_FAST_MATH
120 #define EIGEN_FAST_MATH 1
123 #define EIGEN_DEBUG_VAR(x) std::cerr << #x << " = " << x << std::endl;
126 #define EIGEN_CAT2(a,b) a ## b
127 #define EIGEN_CAT(a,b) EIGEN_CAT2(a,b)
130 #define EIGEN_MAKESTRING2(a) #a
131 #define EIGEN_MAKESTRING(a) EIGEN_MAKESTRING2(a)
133 #if EIGEN_GNUC_AT_LEAST(4,1) && !defined(__clang__) && !defined(__INTEL_COMPILER)
134 #define EIGEN_FLATTEN_ATTRIB __attribute__((flatten))
136 #define EIGEN_FLATTEN_ATTRIB
142 #if (defined _MSC_VER) || (defined __INTEL_COMPILER)
143 #define EIGEN_STRONG_INLINE __forceinline
145 #define EIGEN_STRONG_INLINE inline
155 #if EIGEN_GNUC_AT_LEAST(4,0)
156 #define EIGEN_ALWAYS_INLINE __attribute__((always_inline)) inline
158 #define EIGEN_ALWAYS_INLINE EIGEN_STRONG_INLINE
161 #if (defined __GNUC__)
162 #define EIGEN_DONT_INLINE __attribute__((noinline))
163 #elif (defined _MSC_VER)
164 #define EIGEN_DONT_INLINE __declspec(noinline)
166 #define EIGEN_DONT_INLINE
173 #define EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
174 #define EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS inline
177 # ifndef EIGEN_NO_DEBUG
178 # define EIGEN_NO_DEBUG
183 #ifdef EIGEN_NO_DEBUG
184 #define eigen_plain_assert(x)
186 #if EIGEN_SAFE_TO_USE_STANDARD_ASSERT_MACRO
192 #define eigen_plain_assert(x) assert(x)
205 inline void assert_fail(
const char *condition,
const char *
function,
const char *file,
int line)
207 std::cerr <<
"assertion failed: " << condition <<
" in function " <<
function <<
" at " << file <<
":" << line << std::endl;
212 #define eigen_plain_assert(x) \
214 if(!Eigen::internal::copy_bool(x)) \
215 Eigen::internal::assert_fail(EIGEN_MAKESTRING(x), __PRETTY_FUNCTION__, __FILE__, __LINE__); \
222 #define eigen_assert(x) eigen_plain_assert(x)
225 #ifdef EIGEN_INTERNAL_DEBUGGING
226 #define eigen_internal_assert(x) eigen_assert(x)
228 #define eigen_internal_assert(x)
231 #ifdef EIGEN_NO_DEBUG
232 #define EIGEN_ONLY_USED_FOR_DEBUG(x) (void)x
234 #define EIGEN_ONLY_USED_FOR_DEBUG(x)
237 #ifndef EIGEN_NO_DEPRECATED_WARNING
238 #if (defined __GNUC__)
239 #define EIGEN_DEPRECATED __attribute__((deprecated))
240 #elif (defined _MSC_VER)
241 #define EIGEN_DEPRECATED __declspec(deprecated)
243 #define EIGEN_DEPRECATED
246 #define EIGEN_DEPRECATED
249 #if (defined __GNUC__)
250 #define EIGEN_UNUSED __attribute__((unused))
256 #define EIGEN_UNUSED_VARIABLE(var) (void)var;
258 #if !defined(EIGEN_ASM_COMMENT) && (defined __GNUC__)
259 #define EIGEN_ASM_COMMENT(X) asm("#" X)
261 #define EIGEN_ASM_COMMENT(X)
271 #if (defined __GNUC__) || (defined __PGI) || (defined __IBMCPP__) || (defined __ARMCC_VERSION)
272 #define EIGEN_ALIGN_TO_BOUNDARY(n) __attribute__((aligned(n)))
273 #elif (defined _MSC_VER)
274 #define EIGEN_ALIGN_TO_BOUNDARY(n) __declspec(align(n))
275 #elif (defined __SUNPRO_CC)
277 #define EIGEN_ALIGN_TO_BOUNDARY(n) __attribute__((aligned(n)))
279 #error Please tell me what is the equivalent of __attribute__((aligned(n))) for your compiler
282 #define EIGEN_ALIGN16 EIGEN_ALIGN_TO_BOUNDARY(16)
284 #if EIGEN_ALIGN_STATICALLY
285 #define EIGEN_USER_ALIGN_TO_BOUNDARY(n) EIGEN_ALIGN_TO_BOUNDARY(n)
286 #define EIGEN_USER_ALIGN16 EIGEN_ALIGN16
288 #define EIGEN_USER_ALIGN_TO_BOUNDARY(n)
289 #define EIGEN_USER_ALIGN16
292 #ifdef EIGEN_DONT_USE_RESTRICT_KEYWORD
293 #define EIGEN_RESTRICT
295 #ifndef EIGEN_RESTRICT
296 #define EIGEN_RESTRICT __restrict
299 #ifndef EIGEN_STACK_ALLOCATION_LIMIT
300 #define EIGEN_STACK_ALLOCATION_LIMIT 20000
303 #ifndef EIGEN_DEFAULT_IO_FORMAT
304 #ifdef EIGEN_MAKING_DOCS
307 #define EIGEN_DEFAULT_IO_FORMAT Eigen::IOFormat(3, 0, " ", "\n", "", "")
309 #define EIGEN_DEFAULT_IO_FORMAT Eigen::IOFormat()
316 #if defined(_MSC_VER) && (!defined(__INTEL_COMPILER))
317 #define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
318 using Base::operator =;
320 #define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
321 using Base::operator =; \
322 EIGEN_STRONG_INLINE Derived& operator=(const Derived& other) \
324 Base::operator=(other); \
329 #define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived) \
330 EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived)
340 #define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived) \
341 typedef typename Eigen::internal::traits<Derived>::Scalar Scalar; \
342 typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; \
343 typedef typename Base::CoeffReturnType CoeffReturnType; \
344 typedef typename Eigen::internal::nested<Derived>::type Nested; \
345 typedef typename Eigen::internal::traits<Derived>::StorageKind StorageKind; \
346 typedef typename Eigen::internal::traits<Derived>::Index Index; \
347 enum { RowsAtCompileTime = Eigen::internal::traits<Derived>::RowsAtCompileTime, \
348 ColsAtCompileTime = Eigen::internal::traits<Derived>::ColsAtCompileTime, \
349 Flags = Eigen::internal::traits<Derived>::Flags, \
350 CoeffReadCost = Eigen::internal::traits<Derived>::CoeffReadCost, \
351 SizeAtCompileTime = Base::SizeAtCompileTime, \
352 MaxSizeAtCompileTime = Base::MaxSizeAtCompileTime, \
353 IsVectorAtCompileTime = Base::IsVectorAtCompileTime };
356 #define EIGEN_DENSE_PUBLIC_INTERFACE(Derived) \
357 typedef typename Eigen::internal::traits<Derived>::Scalar Scalar; \
358 typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; \
359 typedef typename Base::PacketScalar PacketScalar; \
360 typedef typename Base::CoeffReturnType CoeffReturnType; \
361 typedef typename Eigen::internal::nested<Derived>::type Nested; \
362 typedef typename Eigen::internal::traits<Derived>::StorageKind StorageKind; \
363 typedef typename Eigen::internal::traits<Derived>::Index Index; \
364 enum { RowsAtCompileTime = Eigen::internal::traits<Derived>::RowsAtCompileTime, \
365 ColsAtCompileTime = Eigen::internal::traits<Derived>::ColsAtCompileTime, \
366 MaxRowsAtCompileTime = Eigen::internal::traits<Derived>::MaxRowsAtCompileTime, \
367 MaxColsAtCompileTime = Eigen::internal::traits<Derived>::MaxColsAtCompileTime, \
368 Flags = Eigen::internal::traits<Derived>::Flags, \
369 CoeffReadCost = Eigen::internal::traits<Derived>::CoeffReadCost, \
370 SizeAtCompileTime = Base::SizeAtCompileTime, \
371 MaxSizeAtCompileTime = Base::MaxSizeAtCompileTime, \
372 IsVectorAtCompileTime = Base::IsVectorAtCompileTime }; \
373 using Base::derived; \
374 using Base::const_cast_derived;
377 #define EIGEN_PLAIN_ENUM_MIN(a,b) (((int)a <= (int)b) ? (int)a : (int)b)
378 #define EIGEN_PLAIN_ENUM_MAX(a,b) (((int)a >= (int)b) ? (int)a : (int)b)
383 #define EIGEN_SIZE_MIN_PREFER_DYNAMIC(a,b) (((int)a == 0 || (int)b == 0) ? 0 \
384 : ((int)a == 1 || (int)b == 1) ? 1 \
385 : ((int)a == Dynamic || (int)b == Dynamic) ? Dynamic \
386 : ((int)a <= (int)b) ? (int)a : (int)b)
391 #define EIGEN_SIZE_MIN_PREFER_FIXED(a,b) (((int)a == 0 || (int)b == 0) ? 0 \
392 : ((int)a == 1 || (int)b == 1) ? 1 \
393 : ((int)a == Dynamic && (int)b == Dynamic) ? Dynamic \
394 : ((int)a == Dynamic) ? (int)b \
395 : ((int)b == Dynamic) ? (int)a \
396 : ((int)a <= (int)b) ? (int)a : (int)b)
399 #define EIGEN_SIZE_MAX(a,b) (((int)a == Dynamic || (int)b == Dynamic) ? Dynamic \
400 : ((int)a >= (int)b) ? (int)a : (int)b)
402 #define EIGEN_LOGICAL_XOR(a,b) (((a) || (b)) && !((a) && (b)))
404 #define EIGEN_IMPLIES(a,b) (!(a) || (b))
406 #define EIGEN_MAKE_CWISE_BINARY_OP(METHOD,FUNCTOR) \
407 template<typename OtherDerived> \
408 EIGEN_STRONG_INLINE const CwiseBinaryOp<FUNCTOR<Scalar>, const Derived, const OtherDerived> \
409 (METHOD)(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const \
411 return CwiseBinaryOp<FUNCTOR<Scalar>, const Derived, const OtherDerived>(derived(), other.derived()); \
415 #define EIGEN_CWISE_PRODUCT_RETURN_TYPE(LHS,RHS) \
417 internal::scalar_product_op< \
418 typename internal::traits<LHS>::Scalar, \
419 typename internal::traits<RHS>::Scalar \
425 #endif // EIGEN_MACROS_H