11 #ifndef EIGEN_MACROS_H
12 #define EIGEN_MACROS_H
14 #define EIGEN_WORLD_VERSION 3
15 #define EIGEN_MAJOR_VERSION 1
16 #define EIGEN_MINOR_VERSION 2
18 #define EIGEN_VERSION_AT_LEAST(x,y,z) (EIGEN_WORLD_VERSION>x || (EIGEN_WORLD_VERSION>=x && \
19 (EIGEN_MAJOR_VERSION>y || (EIGEN_MAJOR_VERSION>=y && \
20 EIGEN_MINOR_VERSION>=z))))
22 #define EIGEN_GNUC_AT_LEAST(x,y) ((__GNUC__==x && __GNUC_MINOR__>=y) || __GNUC__>x)
24 #define EIGEN_GNUC_AT_LEAST(x,y) 0
28 #define EIGEN_GNUC_AT_MOST(x,y) ((__GNUC__==x && __GNUC_MINOR__<=y) || __GNUC__<x)
30 #define EIGEN_GNUC_AT_MOST(x,y) 0
33 #if EIGEN_GNUC_AT_MOST(4,3) && !defined(__clang__)
35 #define EIGEN_SAFE_TO_USE_STANDARD_ASSERT_MACRO 0
37 #define EIGEN_SAFE_TO_USE_STANDARD_ASSERT_MACRO 1
40 #if defined(__GNUC__) && (__GNUC__ <= 3)
41 #define EIGEN_GCC3_OR_OLDER 1
43 #define EIGEN_GCC3_OR_OLDER 0
53 #if defined(__GNUC__) && !(defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) || defined(__ppc__) || defined(__ia64__))
54 #define EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT 1
56 #define EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT 0
60 #if !EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT \
61 && !EIGEN_GCC3_OR_OLDER \
62 && !defined(__SUNPRO_CC) \
63 && !defined(__QNXNTO__)
64 #define EIGEN_ARCH_WANTS_STACK_ALIGNMENT 1
66 #define EIGEN_ARCH_WANTS_STACK_ALIGNMENT 0
69 #ifdef EIGEN_DONT_ALIGN
70 #ifndef EIGEN_DONT_ALIGN_STATICALLY
71 #define EIGEN_DONT_ALIGN_STATICALLY
80 #if EIGEN_ARCH_WANTS_STACK_ALIGNMENT && !defined(EIGEN_DONT_ALIGN_STATICALLY)
81 #define EIGEN_ALIGN_STATICALLY 1
83 #define EIGEN_ALIGN_STATICALLY 0
84 #ifndef EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT
85 #define EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT
89 #ifdef EIGEN_DEFAULT_TO_ROW_MAJOR
90 #define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION RowMajor
92 #define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION ColMajor
95 #ifndef EIGEN_DEFAULT_DENSE_INDEX_TYPE
96 #define EIGEN_DEFAULT_DENSE_INDEX_TYPE std::ptrdiff_t
104 #ifndef EIGEN_FAST_MATH
105 #define EIGEN_FAST_MATH 1
108 #define EIGEN_DEBUG_VAR(x) std::cerr << #x << " = " << x << std::endl;
111 #define EIGEN_CAT2(a,b) a ## b
112 #define EIGEN_CAT(a,b) EIGEN_CAT2(a,b)
115 #define EIGEN_MAKESTRING2(a) #a
116 #define EIGEN_MAKESTRING(a) EIGEN_MAKESTRING2(a)
118 #if EIGEN_GNUC_AT_LEAST(4,1) && !defined(__clang__) && !defined(__INTEL_COMPILER)
119 #define EIGEN_FLATTEN_ATTRIB __attribute__((flatten))
121 #define EIGEN_FLATTEN_ATTRIB
127 #if (defined _MSC_VER) || (defined __INTEL_COMPILER)
128 #define EIGEN_STRONG_INLINE __forceinline
130 #define EIGEN_STRONG_INLINE inline
140 #if EIGEN_GNUC_AT_LEAST(4,0)
141 #define EIGEN_ALWAYS_INLINE __attribute__((always_inline)) inline
143 #define EIGEN_ALWAYS_INLINE EIGEN_STRONG_INLINE
146 #if (defined __GNUC__)
147 #define EIGEN_DONT_INLINE __attribute__((noinline))
148 #elif (defined _MSC_VER)
149 #define EIGEN_DONT_INLINE __declspec(noinline)
151 #define EIGEN_DONT_INLINE
158 #define EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
159 #define EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS inline
162 # ifndef EIGEN_NO_DEBUG
163 # define EIGEN_NO_DEBUG
168 #ifdef EIGEN_NO_DEBUG
169 #define eigen_plain_assert(x)
171 #if EIGEN_SAFE_TO_USE_STANDARD_ASSERT_MACRO
174 inline bool copy_bool(
bool b) {
return b; }
177 #define eigen_plain_assert(x) assert(x)
188 EIGEN_DONT_INLINE
bool copy_bool(
bool b) {
return b; }
190 inline void assert_fail(
const char *condition,
const char *
function ,
const char *file,
int line)
192 std::cerr <<
"assertion failed: " << condition <<
" in function " <<
function <<
" at " << file <<
":" << line << std::endl;
197 #define eigen_plain_assert(x) \
199 if(!Eigen::internal::copy_bool(x)) \
200 Eigen::internal::assert_fail(EIGEN_MAKESTRING(x), __PRETTY_FUNCTION__, __FILE__, __LINE__); \
207 #define eigen_assert(x) eigen_plain_assert(x)
210 #ifdef EIGEN_INTERNAL_DEBUGGING
211 #define eigen_internal_assert(x) eigen_assert(x)
213 #define eigen_internal_assert(x)
216 #ifdef EIGEN_NO_DEBUG
217 #define EIGEN_ONLY_USED_FOR_DEBUG(x) (void)x
219 #define EIGEN_ONLY_USED_FOR_DEBUG(x)
222 #ifndef EIGEN_NO_DEPRECATED_WARNING
223 #if (defined __GNUC__)
224 #define EIGEN_DEPRECATED __attribute__((deprecated))
225 #elif (defined _MSC_VER)
226 #define EIGEN_DEPRECATED __declspec(deprecated)
228 #define EIGEN_DEPRECATED
231 #define EIGEN_DEPRECATED
234 #if (defined __GNUC__)
235 #define EIGEN_UNUSED __attribute__((unused))
241 #define EIGEN_UNUSED_VARIABLE(var) (void)var;
243 #if !defined(EIGEN_ASM_COMMENT) && (defined __GNUC__)
244 #define EIGEN_ASM_COMMENT(X) asm("#" X)
246 #define EIGEN_ASM_COMMENT(X)
256 #if (defined __GNUC__) || (defined __PGI) || (defined __IBMCPP__) || (defined __ARMCC_VERSION)
257 #define EIGEN_ALIGN_TO_BOUNDARY(n) __attribute__((aligned(n)))
258 #elif (defined _MSC_VER)
259 #define EIGEN_ALIGN_TO_BOUNDARY(n) __declspec(align(n))
260 #elif (defined __SUNPRO_CC)
262 #define EIGEN_ALIGN_TO_BOUNDARY(n) __attribute__((aligned(n)))
264 #error Please tell me what is the equivalent of __attribute__((aligned(n))) for your compiler
267 #define EIGEN_ALIGN16 EIGEN_ALIGN_TO_BOUNDARY(16)
269 #if EIGEN_ALIGN_STATICALLY
270 #define EIGEN_USER_ALIGN_TO_BOUNDARY(n) EIGEN_ALIGN_TO_BOUNDARY(n)
271 #define EIGEN_USER_ALIGN16 EIGEN_ALIGN16
273 #define EIGEN_USER_ALIGN_TO_BOUNDARY(n)
274 #define EIGEN_USER_ALIGN16
277 #ifdef EIGEN_DONT_USE_RESTRICT_KEYWORD
278 #define EIGEN_RESTRICT
280 #ifndef EIGEN_RESTRICT
281 #define EIGEN_RESTRICT __restrict
284 #ifndef EIGEN_STACK_ALLOCATION_LIMIT
285 #define EIGEN_STACK_ALLOCATION_LIMIT 20000
288 #ifndef EIGEN_DEFAULT_IO_FORMAT
289 #ifdef EIGEN_MAKING_DOCS
292 #define EIGEN_DEFAULT_IO_FORMAT Eigen::IOFormat(3, 0, " ", "\n", "", "")
294 #define EIGEN_DEFAULT_IO_FORMAT Eigen::IOFormat()
301 #if defined(_MSC_VER) && (!defined(__INTEL_COMPILER))
302 #define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
303 using Base::operator =;
305 #define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
306 using Base::operator =; \
307 EIGEN_STRONG_INLINE Derived& operator=(const Derived& other) \
309 Base::operator=(other); \
314 #define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived) \
315 EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived)
325 #define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived) \
326 typedef typename Eigen::internal::traits<Derived>::Scalar Scalar; \
327 typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; \
328 typedef typename Base::CoeffReturnType CoeffReturnType; \
329 typedef typename Eigen::internal::nested<Derived>::type Nested; \
330 typedef typename Eigen::internal::traits<Derived>::StorageKind StorageKind; \
331 typedef typename Eigen::internal::traits<Derived>::Index Index; \
332 enum { RowsAtCompileTime = Eigen::internal::traits<Derived>::RowsAtCompileTime, \
333 ColsAtCompileTime = Eigen::internal::traits<Derived>::ColsAtCompileTime, \
334 Flags = Eigen::internal::traits<Derived>::Flags, \
335 CoeffReadCost = Eigen::internal::traits<Derived>::CoeffReadCost, \
336 SizeAtCompileTime = Base::SizeAtCompileTime, \
337 MaxSizeAtCompileTime = Base::MaxSizeAtCompileTime, \
338 IsVectorAtCompileTime = Base::IsVectorAtCompileTime };
341 #define EIGEN_DENSE_PUBLIC_INTERFACE(Derived) \
342 typedef typename Eigen::internal::traits<Derived>::Scalar Scalar; \
343 typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; \
344 typedef typename Base::PacketScalar PacketScalar; \
345 typedef typename Base::CoeffReturnType CoeffReturnType; \
346 typedef typename Eigen::internal::nested<Derived>::type Nested; \
347 typedef typename Eigen::internal::traits<Derived>::StorageKind StorageKind; \
348 typedef typename Eigen::internal::traits<Derived>::Index Index; \
349 enum { RowsAtCompileTime = Eigen::internal::traits<Derived>::RowsAtCompileTime, \
350 ColsAtCompileTime = Eigen::internal::traits<Derived>::ColsAtCompileTime, \
351 MaxRowsAtCompileTime = Eigen::internal::traits<Derived>::MaxRowsAtCompileTime, \
352 MaxColsAtCompileTime = Eigen::internal::traits<Derived>::MaxColsAtCompileTime, \
353 Flags = Eigen::internal::traits<Derived>::Flags, \
354 CoeffReadCost = Eigen::internal::traits<Derived>::CoeffReadCost, \
355 SizeAtCompileTime = Base::SizeAtCompileTime, \
356 MaxSizeAtCompileTime = Base::MaxSizeAtCompileTime, \
357 IsVectorAtCompileTime = Base::IsVectorAtCompileTime }; \
358 using Base::derived; \
359 using Base::const_cast_derived;
362 #define EIGEN_PLAIN_ENUM_MIN(a,b) (((int)a <= (int)b) ? (int)a : (int)b)
363 #define EIGEN_PLAIN_ENUM_MAX(a,b) (((int)a >= (int)b) ? (int)a : (int)b)
368 #define EIGEN_SIZE_MIN_PREFER_DYNAMIC(a,b) (((int)a == 0 || (int)b == 0) ? 0 \
369 : ((int)a == 1 || (int)b == 1) ? 1 \
370 : ((int)a == Dynamic || (int)b == Dynamic) ? Dynamic \
371 : ((int)a <= (int)b) ? (int)a : (int)b)
376 #define EIGEN_SIZE_MIN_PREFER_FIXED(a,b) (((int)a == 0 || (int)b == 0) ? 0 \
377 : ((int)a == 1 || (int)b == 1) ? 1 \
378 : ((int)a == Dynamic && (int)b == Dynamic) ? Dynamic \
379 : ((int)a == Dynamic) ? (int)b \
380 : ((int)b == Dynamic) ? (int)a \
381 : ((int)a <= (int)b) ? (int)a : (int)b)
384 #define EIGEN_SIZE_MAX(a,b) (((int)a == Dynamic || (int)b == Dynamic) ? Dynamic \
385 : ((int)a >= (int)b) ? (int)a : (int)b)
387 #define EIGEN_LOGICAL_XOR(a,b) (((a) || (b)) && !((a) && (b)))
389 #define EIGEN_IMPLIES(a,b) (!(a) || (b))
391 #define EIGEN_MAKE_CWISE_BINARY_OP(METHOD,FUNCTOR) \
392 template<typename OtherDerived> \
393 EIGEN_STRONG_INLINE const CwiseBinaryOp<FUNCTOR<Scalar>, const Derived, const OtherDerived> \
394 (METHOD)(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const \
396 return CwiseBinaryOp<FUNCTOR<Scalar>, const Derived, const OtherDerived>(derived(), other.derived()); \
400 #define EIGEN_CWISE_PRODUCT_RETURN_TYPE(LHS,RHS) \
402 internal::scalar_product_op< \
403 typename internal::traits<LHS>::Scalar, \
404 typename internal::traits<RHS>::Scalar \
410 #endif // EIGEN_MACROS_H