Medial Code Documentation
Loading...
Searching...
No Matches
Macros.h
1// This file is part of Eigen, a lightweight C++ template library
2// for linear algebra.
3//
4// Copyright (C) 2008-2015 Gael Guennebaud <gael.guennebaud@inria.fr>
5// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
6//
7// This Source Code Form is subject to the terms of the Mozilla
8// Public License v. 2.0. If a copy of the MPL was not distributed
9// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10
11#ifndef EIGEN_MACROS_H
12#define EIGEN_MACROS_H
13
14#define EIGEN_WORLD_VERSION 3
15#define EIGEN_MAJOR_VERSION 2
16#define EIGEN_MINOR_VERSION 92
17
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))))
21
22// Compiler identification, EIGEN_COMP_*
23
25#ifdef __GNUC__
26 #define EIGEN_COMP_GNUC 1
27#else
28 #define EIGEN_COMP_GNUC 0
29#endif
30
32#if defined(__clang__)
33 #define EIGEN_COMP_CLANG 1
34#else
35 #define EIGEN_COMP_CLANG 0
36#endif
37
38
40#if defined(__llvm__)
41 #define EIGEN_COMP_LLVM 1
42#else
43 #define EIGEN_COMP_LLVM 0
44#endif
45
47#if defined(__INTEL_COMPILER)
48 #define EIGEN_COMP_ICC __INTEL_COMPILER
49#else
50 #define EIGEN_COMP_ICC 0
51#endif
52
54#if defined(__MINGW32__)
55 #define EIGEN_COMP_MINGW 1
56#else
57 #define EIGEN_COMP_MINGW 0
58#endif
59
61#if defined(__SUNPRO_CC)
62 #define EIGEN_COMP_SUNCC 1
63#else
64 #define EIGEN_COMP_SUNCC 0
65#endif
66
68#if defined(_MSC_VER)
69 #define EIGEN_COMP_MSVC _MSC_VER
70#else
71 #define EIGEN_COMP_MSVC 0
72#endif
73
75#if EIGEN_COMP_MSVC && !(EIGEN_COMP_ICC)
76 #define EIGEN_COMP_MSVC_STRICT _MSC_VER
77#else
78 #define EIGEN_COMP_MSVC_STRICT 0
79#endif
80
82#if defined(__IBMCPP__) || defined(__xlc__)
83 #define EIGEN_COMP_IBM 1
84#else
85 #define EIGEN_COMP_IBM 0
86#endif
87
89#if defined(__PGI)
90 #define EIGEN_COMP_PGI 1
91#else
92 #define EIGEN_COMP_PGI 0
93#endif
94
96#if defined(__CC_ARM) || defined(__ARMCC_VERSION)
97 #define EIGEN_COMP_ARM 1
98#else
99 #define EIGEN_COMP_ARM 0
100#endif
101
102
104#if EIGEN_COMP_GNUC && !(EIGEN_COMP_CLANG || EIGEN_COMP_ICC || EIGEN_COMP_MINGW || EIGEN_COMP_PGI || EIGEN_COMP_IBM || EIGEN_COMP_ARM )
105 #define EIGEN_COMP_GNUC_STRICT 1
106#else
107 #define EIGEN_COMP_GNUC_STRICT 0
108#endif
109
110
111#if EIGEN_COMP_GNUC
112 #define EIGEN_GNUC_AT_LEAST(x,y) ((__GNUC__==x && __GNUC_MINOR__>=y) || __GNUC__>x)
113 #define EIGEN_GNUC_AT_MOST(x,y) ((__GNUC__==x && __GNUC_MINOR__<=y) || __GNUC__<x)
114 #define EIGEN_GNUC_AT(x,y) ( __GNUC__==x && __GNUC_MINOR__==y )
115#else
116 #define EIGEN_GNUC_AT_LEAST(x,y) 0
117 #define EIGEN_GNUC_AT_MOST(x,y) 0
118 #define EIGEN_GNUC_AT(x,y) 0
119#endif
120
121// FIXME: could probably be removed as we do not support gcc 3.x anymore
122#if EIGEN_COMP_GNUC && (__GNUC__ <= 3)
123#define EIGEN_GCC3_OR_OLDER 1
124#else
125#define EIGEN_GCC3_OR_OLDER 0
126#endif
127
128
129// Architecture identification, EIGEN_ARCH_*
130
131#if defined(__x86_64__) || defined(_M_X64) || defined(__amd64)
132 #define EIGEN_ARCH_x86_64 1
133#else
134 #define EIGEN_ARCH_x86_64 0
135#endif
136
137#if defined(__i386__) || defined(_M_IX86) || defined(_X86_) || defined(__i386)
138 #define EIGEN_ARCH_i386 1
139#else
140 #define EIGEN_ARCH_i386 0
141#endif
142
143#if EIGEN_ARCH_x86_64 || EIGEN_ARCH_i386
144 #define EIGEN_ARCH_i386_OR_x86_64 1
145#else
146 #define EIGEN_ARCH_i386_OR_x86_64 0
147#endif
148
150#if defined(__arm__)
151 #define EIGEN_ARCH_ARM 1
152#else
153 #define EIGEN_ARCH_ARM 0
154#endif
155
157#if defined(__aarch64__)
158 #define EIGEN_ARCH_ARM64 1
159#else
160 #define EIGEN_ARCH_ARM64 0
161#endif
162
163#if EIGEN_ARCH_ARM || EIGEN_ARCH_ARM64
164 #define EIGEN_ARCH_ARM_OR_ARM64 1
165#else
166 #define EIGEN_ARCH_ARM_OR_ARM64 0
167#endif
168
170#if defined(__mips__) || defined(__mips)
171 #define EIGEN_ARCH_MIPS 1
172#else
173 #define EIGEN_ARCH_MIPS 0
174#endif
175
177#if defined(__sparc__) || defined(__sparc)
178 #define EIGEN_ARCH_SPARC 1
179#else
180 #define EIGEN_ARCH_SPARC 0
181#endif
182
184#if defined(__ia64__)
185 #define EIGEN_ARCH_IA64 1
186#else
187 #define EIGEN_ARCH_IA64 0
188#endif
189
191#if defined(__powerpc__) || defined(__ppc__) || defined(_M_PPC)
192 #define EIGEN_ARCH_PPC 1
193#else
194 #define EIGEN_ARCH_PPC 0
195#endif
196
197
198
199// Operating system identification, EIGEN_OS_*
200
202#if defined(__unix__) || defined(__unix)
203 #define EIGEN_OS_UNIX 1
204#else
205 #define EIGEN_OS_UNIX 0
206#endif
207
209#if defined(__linux__)
210 #define EIGEN_OS_LINUX 1
211#else
212 #define EIGEN_OS_LINUX 0
213#endif
214
216// note: ANDROID is defined when using ndk_build, __ANDROID__ is defined when using a standalone toolchain.
217#if defined(__ANDROID__) || defined(ANDROID)
218 #define EIGEN_OS_ANDROID 1
219#else
220 #define EIGEN_OS_ANDROID 0
221#endif
222
224#if defined(__gnu_linux__) && !(EIGEN_OS_ANDROID)
225 #define EIGEN_OS_GNULINUX 1
226#else
227 #define EIGEN_OS_GNULINUX 0
228#endif
229
231#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__)
232 #define EIGEN_OS_BSD 1
233#else
234 #define EIGEN_OS_BSD 0
235#endif
236
238#if defined(__APPLE__)
239 #define EIGEN_OS_MAC 1
240#else
241 #define EIGEN_OS_MAC 0
242#endif
243
245#if defined(__QNX__)
246 #define EIGEN_OS_QNX 1
247#else
248 #define EIGEN_OS_QNX 0
249#endif
250
252#if defined(_WIN32)
253 #define EIGEN_OS_WIN 1
254#else
255 #define EIGEN_OS_WIN 0
256#endif
257
259#if defined(_WIN64)
260 #define EIGEN_OS_WIN64 1
261#else
262 #define EIGEN_OS_WIN64 0
263#endif
264
266#if defined(_WIN32_WCE)
267 #define EIGEN_OS_WINCE 1
268#else
269 #define EIGEN_OS_WINCE 0
270#endif
271
273#if defined(__CYGWIN__)
274 #define EIGEN_OS_CYGWIN 1
275#else
276 #define EIGEN_OS_CYGWIN 0
277#endif
278
280#if EIGEN_OS_WIN && !( EIGEN_OS_WINCE || EIGEN_OS_CYGWIN )
281 #define EIGEN_OS_WIN_STRICT 1
282#else
283 #define EIGEN_OS_WIN_STRICT 0
284#endif
285
287#if (defined(sun) || defined(__sun)) && !(defined(__SVR4) || defined(__svr4__))
288 #define EIGEN_OS_SUN 1
289#else
290 #define EIGEN_OS_SUN 0
291#endif
292
294#if (defined(sun) || defined(__sun)) && (defined(__SVR4) || defined(__svr4__))
295 #define EIGEN_OS_SOLARIS 1
296#else
297 #define EIGEN_OS_SOLARIS 0
298#endif
299
300
301
302#if EIGEN_GNUC_AT_MOST(4,3) && !EIGEN_COMP_CLANG
303 // see bug 89
304 #define EIGEN_SAFE_TO_USE_STANDARD_ASSERT_MACRO 0
305#else
306 #define EIGEN_SAFE_TO_USE_STANDARD_ASSERT_MACRO 1
307#endif
308
309// This macro can be used to prevent from macro expansion, e.g.:
310// std::max EIGEN_NOT_A_MACRO(a,b)
311#define EIGEN_NOT_A_MACRO
312
313#ifdef EIGEN_DEFAULT_TO_ROW_MAJOR
314#define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION Eigen::RowMajor
315#else
316#define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION Eigen::ColMajor
317#endif
318
319#ifndef EIGEN_DEFAULT_DENSE_INDEX_TYPE
320#define EIGEN_DEFAULT_DENSE_INDEX_TYPE std::ptrdiff_t
321#endif
322
323// Cross compiler wrapper around LLVM's __has_builtin
324#ifdef __has_builtin
325# define EIGEN_HAS_BUILTIN(x) __has_builtin(x)
326#else
327# define EIGEN_HAS_BUILTIN(x) 0
328#endif
329
330// A Clang feature extension to determine compiler features.
331// We use it to determine 'cxx_rvalue_references'
332#ifndef __has_feature
333# define __has_feature(x) 0
334#endif
335
336// Do we support r-value references?
337#if (__has_feature(cxx_rvalue_references) || \
338 (defined(__cplusplus) && __cplusplus >= 201103L) || \
339 defined(__GXX_EXPERIMENTAL_CXX0X__) || \
340 (EIGEN_COMP_MSVC >= 1600))
341 #define EIGEN_HAVE_RVALUE_REFERENCES
342#endif
343
344// Does the compiler support C99?
345#if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)) \
346 || (defined(__GNUC__) && defined(_GLIBCXX_USE_C99)) \
347 || (defined(_LIBCPP_VERSION) && !defined(_MSC_VER))
348#define EIGEN_HAS_C99_MATH 1
349#endif
350
351// Does the compiler support result_of?
352#if (__has_feature(cxx_lambdas) || (defined(__cplusplus) && __cplusplus >= 201103L))
353#define EIGEN_HAS_STD_RESULT_OF 1
354#endif
355
356// Does the compiler support variadic templates?
357#if __cplusplus > 199711L
358#define EIGEN_HAS_VARIADIC_TEMPLATES 1
359#endif
360
361// Does the compiler support const expressions?
362#ifdef __CUDACC__
363// Const expressions are supported provided that c++11 is enabled and we're using nvcc 7.5 or above
364#if defined(__CUDACC_VER__) && __CUDACC_VER__ >= 70500 && __cplusplus > 199711L
365 #define EIGEN_HAS_CONSTEXPR 1
366#endif
367#elif (defined(__cplusplus) && __cplusplus >= 201402L) || \
368 EIGEN_GNUC_AT_LEAST(4,8)
369#define EIGEN_HAS_CONSTEXPR 1
370#endif
371
372// Does the compiler support C++11 math?
373// Let's be conservative and enable the default C++11 implementation only if we are sure it exists
374#ifndef EIGEN_HAS_CXX11_MATH
375 #if (__cplusplus > 201103L) || (__cplusplus >= 201103L) && (EIGEN_COMP_GNUC_STRICT || EIGEN_COMP_CLANG || EIGEN_COMP_MSVC || EIGEN_COMP_ICC) \
376 && (EIGEN_ARCH_i386_OR_x86_64) && (EIGEN_OS_GNULINUX || EIGEN_OS_WIN_STRICT || EIGEN_OS_MAC)
377 #define EIGEN_HAS_CXX11_MATH 1
378 #else
379 #define EIGEN_HAS_CXX11_MATH 0
380 #endif
381#endif
382
383// Does the compiler support proper C++11 containers?
384#ifndef EIGEN_HAS_CXX11_CONTAINERS
385 #if (__cplusplus > 201103L) \
386 || ((__cplusplus >= 201103L) && (EIGEN_COMP_GNUC_STRICT || EIGEN_COMP_CLANG || EIGEN_COMP_ICC>=1400)) \
387 || EIGEN_COMP_MSVC >= 1900
388 #define EIGEN_HAS_CXX11_CONTAINERS 1
389 #else
390 #define EIGEN_HAS_CXX11_CONTAINERS 0
391 #endif
392#endif
393
394// Does the compiler support C++11 noexcept?
395#ifndef EIGEN_HAS_CXX11_NOEXCEPT
396 #if (__cplusplus > 201103L) \
397 || ((__cplusplus >= 201103L) && (EIGEN_COMP_GNUC_STRICT || EIGEN_COMP_CLANG || EIGEN_COMP_ICC>=1400)) \
398 || EIGEN_COMP_MSVC >= 1900
399 #define EIGEN_HAS_CXX11_NOEXCEPT 1
400 #else
401 #define EIGEN_HAS_CXX11_NOEXCEPT 0
402 #endif
403#endif
404
410#ifndef EIGEN_FAST_MATH
411#define EIGEN_FAST_MATH 1
412#endif
413
414#define EIGEN_DEBUG_VAR(x) std::cerr << #x << " = " << x << std::endl;
415
416// concatenate two tokens
417#define EIGEN_CAT2(a,b) a ## b
418#define EIGEN_CAT(a,b) EIGEN_CAT2(a,b)
419
420// convert a token to a string
421#define EIGEN_MAKESTRING2(a) #a
422#define EIGEN_MAKESTRING(a) EIGEN_MAKESTRING2(a)
423
424// EIGEN_STRONG_INLINE is a stronger version of the inline, using __forceinline on MSVC,
425// but it still doesn't use GCC's always_inline. This is useful in (common) situations where MSVC needs forceinline
426// but GCC is still doing fine with just inline.
427#if EIGEN_COMP_MSVC || EIGEN_COMP_ICC
428#define EIGEN_STRONG_INLINE __forceinline
429#else
430#define EIGEN_STRONG_INLINE inline
431#endif
432
433// EIGEN_ALWAYS_INLINE is the stronget, it has the effect of making the function inline and adding every possible
434// attribute to maximize inlining. This should only be used when really necessary: in particular,
435// it uses __attribute__((always_inline)) on GCC, which most of the time is useless and can severely harm compile times.
436// FIXME with the always_inline attribute,
437// gcc 3.4.x reports the following compilation error:
438// Eval.h:91: sorry, unimplemented: inlining failed in call to 'const Eigen::Eval<Derived> Eigen::MatrixBase<Scalar, Derived>::eval() const'
439// : function body not available
440#if EIGEN_GNUC_AT_LEAST(4,0)
441#define EIGEN_ALWAYS_INLINE __attribute__((always_inline)) inline
442#else
443#define EIGEN_ALWAYS_INLINE EIGEN_STRONG_INLINE
444#endif
445
446#if EIGEN_COMP_GNUC
447#define EIGEN_DONT_INLINE __attribute__((noinline))
448#elif EIGEN_COMP_MSVC
449#define EIGEN_DONT_INLINE __declspec(noinline)
450#else
451#define EIGEN_DONT_INLINE
452#endif
453
454#if EIGEN_COMP_GNUC
455#define EIGEN_PERMISSIVE_EXPR __extension__
456#else
457#define EIGEN_PERMISSIVE_EXPR
458#endif
459
460// this macro allows to get rid of linking errors about multiply defined functions.
461// - static is not very good because it prevents definitions from different object files to be merged.
462// So static causes the resulting linked executable to be bloated with multiple copies of the same function.
463// - inline is not perfect either as it unwantedly hints the compiler toward inlining the function.
464#define EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
465#define EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS inline
466
467#ifdef NDEBUG
468# ifndef EIGEN_NO_DEBUG
469# define EIGEN_NO_DEBUG
470# endif
471#endif
472
473// eigen_plain_assert is where we implement the workaround for the assert() bug in GCC <= 4.3, see bug 89
474#ifdef EIGEN_NO_DEBUG
475 #define eigen_plain_assert(x)
476#else
477 #if EIGEN_SAFE_TO_USE_STANDARD_ASSERT_MACRO
478 namespace Eigen {
479 namespace internal {
480 inline bool copy_bool(bool b) { return b; }
481 }
482 }
483 #define eigen_plain_assert(x) assert(x)
484 #else
485 // work around bug 89
486 #include <cstdlib> // for abort
487 #include <iostream> // for std::cerr
488
489 namespace Eigen {
490 namespace internal {
491 // trivial function copying a bool. Must be EIGEN_DONT_INLINE, so we implement it after including Eigen headers.
492 // see bug 89.
493 namespace {
494 EIGEN_DONT_INLINE bool copy_bool(bool b) { return b; }
495 }
496 inline void assert_fail(const char *condition, const char *function, const char *file, int line)
497 {
498 std::cerr << "assertion failed: " << condition << " in function " << function << " at " << file << ":" << line << std::endl;
499 abort();
500 }
501 }
502 }
503 #define eigen_plain_assert(x) \
504 do { \
505 if(!Eigen::internal::copy_bool(x)) \
506 Eigen::internal::assert_fail(EIGEN_MAKESTRING(x), __PRETTY_FUNCTION__, __FILE__, __LINE__); \
507 } while(false)
508 #endif
509#endif
510
511// eigen_assert can be overridden
512#ifndef eigen_assert
513#define eigen_assert(x) eigen_plain_assert(x)
514#endif
515
516#ifdef EIGEN_INTERNAL_DEBUGGING
517#define eigen_internal_assert(x) eigen_assert(x)
518#else
519#define eigen_internal_assert(x)
520#endif
521
522#ifdef EIGEN_NO_DEBUG
523#define EIGEN_ONLY_USED_FOR_DEBUG(x) EIGEN_UNUSED_VARIABLE(x)
524#else
525#define EIGEN_ONLY_USED_FOR_DEBUG(x)
526#endif
527
528#ifndef EIGEN_NO_DEPRECATED_WARNING
529 #if EIGEN_COMP_GNUC
530 #define EIGEN_DEPRECATED __attribute__((deprecated))
531 #elif EIGEN_COMP_MSVC
532 #define EIGEN_DEPRECATED __declspec(deprecated)
533 #else
534 #define EIGEN_DEPRECATED
535 #endif
536#else
537 #define EIGEN_DEPRECATED
538#endif
539
540#if EIGEN_COMP_GNUC
541#define EIGEN_UNUSED __attribute__((unused))
542#else
543#define EIGEN_UNUSED
544#endif
545
546// Suppresses 'unused variable' warnings.
547namespace Eigen {
548 namespace internal {
549 template<typename T> EIGEN_DEVICE_FUNC void ignore_unused_variable(const T&) {}
550 }
551}
552#define EIGEN_UNUSED_VARIABLE(var) Eigen::internal::ignore_unused_variable(var);
553
554#if !defined(EIGEN_ASM_COMMENT)
555 #if EIGEN_COMP_GNUC && (EIGEN_ARCH_i386_OR_x86_64 || EIGEN_ARCH_ARM_OR_ARM64)
556 #define EIGEN_ASM_COMMENT(X) __asm__("#" X)
557 #else
558 #define EIGEN_ASM_COMMENT(X)
559 #endif
560#endif
561
562
563//------------------------------------------------------------------------------------------
564// Static and dynamic alignment control
565//
566// The main purpose of this section is to define EIGEN_MAX_ALIGN_BYTES and EIGEN_MAX_STATIC_ALIGN_BYTES
567// as the maximal boundary in bytes on which dynamically and statically allocated data may be alignment respectively.
568// The values of EIGEN_MAX_ALIGN_BYTES and EIGEN_MAX_STATIC_ALIGN_BYTES can be specified by the user. If not,
569// a default value is automatically computed based on architecture, compiler, and OS.
570//
571// This section also defines macros EIGEN_ALIGN_TO_BOUNDARY(N) and the shortcuts EIGEN_ALIGN{8,16,32,_MAX}
572// to be used to declare statically aligned buffers.
573//------------------------------------------------------------------------------------------
574
575
576/* EIGEN_ALIGN_TO_BOUNDARY(n) forces data to be n-byte aligned. This is used to satisfy SIMD requirements.
577 * However, we do that EVEN if vectorization (EIGEN_VECTORIZE) is disabled,
578 * so that vectorization doesn't affect binary compatibility.
579 *
580 * If we made alignment depend on whether or not EIGEN_VECTORIZE is defined, it would be impossible to link
581 * vectorized and non-vectorized code.
582 */
583#if (defined __CUDACC__)
584 #define EIGEN_ALIGN_TO_BOUNDARY(n) __align__(n)
585#elif EIGEN_COMP_GNUC || EIGEN_COMP_PGI || EIGEN_COMP_IBM || EIGEN_COMP_ARM
586 #define EIGEN_ALIGN_TO_BOUNDARY(n) __attribute__((aligned(n)))
587#elif EIGEN_COMP_MSVC
588 #define EIGEN_ALIGN_TO_BOUNDARY(n) __declspec(align(n))
589#elif EIGEN_COMP_SUNCC
590 // FIXME not sure about this one:
591 #define EIGEN_ALIGN_TO_BOUNDARY(n) __attribute__((aligned(n)))
592#else
593 #error Please tell me what is the equivalent of __attribute__((aligned(n))) for your compiler
594#endif
595
596// If the user explicitly disable vectorization, then we also disable alignment
597#if defined(EIGEN_DONT_VECTORIZE)
598 #define EIGEN_IDEAL_MAX_ALIGN_BYTES 0
599#elif defined(__AVX__)
600 // 32 bytes static alignmeent is preferred only if really required
601 #define EIGEN_IDEAL_MAX_ALIGN_BYTES 32
602#else
603 #define EIGEN_IDEAL_MAX_ALIGN_BYTES 16
604#endif
605
606
607// EIGEN_MIN_ALIGN_BYTES defines the minimal value for which the notion of explicit alignment makes sense
608#define EIGEN_MIN_ALIGN_BYTES 16
609
610// Defined the boundary (in bytes) on which the data needs to be aligned. Note
611// that unless EIGEN_ALIGN is defined and not equal to 0, the data may not be
612// aligned at all regardless of the value of this #define.
613
614#if (defined(EIGEN_DONT_ALIGN_STATICALLY) || defined(EIGEN_DONT_ALIGN)) && defined(EIGEN_MAX_STATIC_ALIGN_BYTES) && EIGEN_MAX_STATIC_ALIGN_BYTES>0
615#error EIGEN_MAX_STATIC_ALIGN_BYTES and EIGEN_DONT_ALIGN[_STATICALLY] are both defined with EIGEN_MAX_STATIC_ALIGN_BYTES!=0. Use EIGEN_MAX_STATIC_ALIGN_BYTES=0 as a synonym of EIGEN_DONT_ALIGN_STATICALLY.
616#endif
617
618// EIGEN_DONT_ALIGN_STATICALLY and EIGEN_DONT_ALIGN are deprectated
619// They imply EIGEN_MAX_STATIC_ALIGN_BYTES=0
620#if defined(EIGEN_DONT_ALIGN_STATICALLY) || defined(EIGEN_DONT_ALIGN)
621 #ifdef EIGEN_MAX_STATIC_ALIGN_BYTES
622 #undef EIGEN_MAX_STATIC_ALIGN_BYTES
623 #endif
624 #define EIGEN_MAX_STATIC_ALIGN_BYTES 0
625#endif
626
627#ifndef EIGEN_MAX_STATIC_ALIGN_BYTES
628
629 // Try to automatically guess what is the best default value for EIGEN_MAX_STATIC_ALIGN_BYTES
630
631 // 16 byte alignment is only useful for vectorization. Since it affects the ABI, we need to enable
632 // 16 byte alignment on all platforms where vectorization might be enabled. In theory we could always
633 // enable alignment, but it can be a cause of problems on some platforms, so we just disable it in
634 // certain common platform (compiler+architecture combinations) to avoid these problems.
635 // Only static alignment is really problematic (relies on nonstandard compiler extensions),
636 // try to keep heap alignment even when we have to disable static alignment.
637 #if EIGEN_COMP_GNUC && !(EIGEN_ARCH_i386_OR_x86_64 || EIGEN_ARCH_ARM_OR_ARM64 || EIGEN_ARCH_PPC || EIGEN_ARCH_IA64)
638 #define EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT 1
639 #elif EIGEN_ARCH_ARM_OR_ARM64 && EIGEN_COMP_GNUC_STRICT && EIGEN_GNUC_AT_MOST(4, 6)
640 // Old versions of GCC on ARM, at least 4.4, were once seen to have buggy static alignment support.
641 // Not sure which version fixed it, hopefully it doesn't affect 4.7, which is still somewhat in use.
642 // 4.8 and newer seem definitely unaffected.
643 #define EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT 1
644 #else
645 #define EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT 0
646 #endif
647
648 // static alignment is completely disabled with GCC 3, Sun Studio, and QCC/QNX
649 #if !EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT \
650 && !EIGEN_GCC3_OR_OLDER \
651 && !EIGEN_COMP_SUNCC \
652 && !EIGEN_OS_QNX
653 #define EIGEN_ARCH_WANTS_STACK_ALIGNMENT 1
654 #else
655 #define EIGEN_ARCH_WANTS_STACK_ALIGNMENT 0
656 #endif
657
658 #if EIGEN_ARCH_WANTS_STACK_ALIGNMENT
659 #define EIGEN_MAX_STATIC_ALIGN_BYTES EIGEN_IDEAL_MAX_ALIGN_BYTES
660 #else
661 #define EIGEN_MAX_STATIC_ALIGN_BYTES 0
662 #endif
663
664#endif
665
666// If EIGEN_MAX_ALIGN_BYTES is defined, then it is considered as an upper bound for EIGEN_MAX_ALIGN_BYTES
667#if defined(EIGEN_MAX_ALIGN_BYTES) && EIGEN_MAX_ALIGN_BYTES<EIGEN_MAX_STATIC_ALIGN_BYTES
668#undef EIGEN_MAX_STATIC_ALIGN_BYTES
669#define EIGEN_MAX_STATIC_ALIGN_BYTES EIGEN_MAX_ALIGN_BYTES
670#endif
671
672#if EIGEN_MAX_STATIC_ALIGN_BYTES==0 && !defined(EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT)
673 #define EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT
674#endif
675
676// At this stage, EIGEN_MAX_STATIC_ALIGN_BYTES>0 is the true test whether we want to align arrays on the stack or not.
677// It takes into account both the user choice to explicitly enable/disable alignment (by settting EIGEN_MAX_STATIC_ALIGN_BYTES)
678// and the architecture config (EIGEN_ARCH_WANTS_STACK_ALIGNMENT).
679// Henceforth, only EIGEN_MAX_STATIC_ALIGN_BYTES should be used.
680
681
682// Shortcuts to EIGEN_ALIGN_TO_BOUNDARY
683#define EIGEN_ALIGN8 EIGEN_ALIGN_TO_BOUNDARY(8)
684#define EIGEN_ALIGN16 EIGEN_ALIGN_TO_BOUNDARY(16)
685#define EIGEN_ALIGN32 EIGEN_ALIGN_TO_BOUNDARY(32)
686#define EIGEN_ALIGN64 EIGEN_ALIGN_TO_BOUNDARY(64)
687#if EIGEN_MAX_STATIC_ALIGN_BYTES>0
688#define EIGEN_ALIGN_MAX EIGEN_ALIGN_TO_BOUNDARY(EIGEN_MAX_STATIC_ALIGN_BYTES)
689#else
690#define EIGEN_ALIGN_MAX
691#endif
692
693
694// Dynamic alignment control
695
696#if defined(EIGEN_DONT_ALIGN) && defined(EIGEN_MAX_ALIGN_BYTES) && EIGEN_MAX_ALIGN_BYTES>0
697#error EIGEN_MAX_ALIGN_BYTES and EIGEN_DONT_ALIGN are both defined with EIGEN_MAX_ALIGN_BYTES!=0. Use EIGEN_MAX_ALIGN_BYTES=0 as a synonym of EIGEN_DONT_ALIGN.
698#endif
699
700#ifdef EIGEN_DONT_ALIGN
701 #ifdef EIGEN_MAX_ALIGN_BYTES
702 #undef EIGEN_MAX_ALIGN_BYTES
703 #endif
704 #define EIGEN_MAX_ALIGN_BYTES 0
705#elif !defined(EIGEN_MAX_ALIGN_BYTES)
706 #define EIGEN_MAX_ALIGN_BYTES EIGEN_IDEAL_MAX_ALIGN_BYTES
707#endif
708
709#if EIGEN_IDEAL_MAX_ALIGN_BYTES > EIGEN_MAX_ALIGN_BYTES
710#define EIGEN_DEFAULT_ALIGN_BYTES EIGEN_IDEAL_MAX_ALIGN_BYTES
711#else
712#define EIGEN_DEFAULT_ALIGN_BYTES EIGEN_MAX_ALIGN_BYTES
713#endif
714
715//----------------------------------------------------------------------
716
717
718#ifdef EIGEN_DONT_USE_RESTRICT_KEYWORD
719 #define EIGEN_RESTRICT
720#endif
721#ifndef EIGEN_RESTRICT
722 #define EIGEN_RESTRICT __restrict
723#endif
724
725#ifndef EIGEN_STACK_ALLOCATION_LIMIT
726// 131072 == 128 KB
727#define EIGEN_STACK_ALLOCATION_LIMIT 131072
728#endif
729
730#ifndef EIGEN_DEFAULT_IO_FORMAT
731#ifdef EIGEN_MAKING_DOCS
732// format used in Eigen's documentation
733// needed to define it here as escaping characters in CMake add_definition's argument seems very problematic.
734#define EIGEN_DEFAULT_IO_FORMAT Eigen::IOFormat(3, 0, " ", "\n", "", "")
735#else
736#define EIGEN_DEFAULT_IO_FORMAT Eigen::IOFormat()
737#endif
738#endif
739
740// just an empty macro !
741#define EIGEN_EMPTY
742
743#if EIGEN_COMP_MSVC_STRICT && EIGEN_COMP_MSVC < 1900 // for older MSVC versions using the base operator is sufficient (cf Bug 1000)
744 #define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
745 using Base::operator =;
746#elif EIGEN_COMP_CLANG // workaround clang bug (see http://forum.kde.org/viewtopic.php?f=74&t=102653)
747 #define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
748 using Base::operator =; \
749 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const Derived& other) { Base::operator=(other); return *this; } \
750 template <typename OtherDerived> \
751 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const DenseBase<OtherDerived>& other) { Base::operator=(other.derived()); return *this; }
752#else
753 #define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
754 using Base::operator =; \
755 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const Derived& other) \
756 { \
757 Base::operator=(other); \
758 return *this; \
759 }
760#endif
761
762
767#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived) EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived)
768
777#define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived) \
778 typedef typename Eigen::internal::traits<Derived>::Scalar Scalar; \
779 typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; \
780 typedef typename Base::CoeffReturnType CoeffReturnType; \
781 typedef typename Eigen::internal::ref_selector<Derived>::type Nested; \
782 typedef typename Eigen::internal::traits<Derived>::StorageKind StorageKind; \
783 typedef typename Eigen::internal::traits<Derived>::StorageIndex StorageIndex; \
784 enum { RowsAtCompileTime = Eigen::internal::traits<Derived>::RowsAtCompileTime, \
785 ColsAtCompileTime = Eigen::internal::traits<Derived>::ColsAtCompileTime, \
786 Flags = Eigen::internal::traits<Derived>::Flags, \
787 SizeAtCompileTime = Base::SizeAtCompileTime, \
788 MaxSizeAtCompileTime = Base::MaxSizeAtCompileTime, \
789 IsVectorAtCompileTime = Base::IsVectorAtCompileTime }; \
790 using Base::derived; \
791 using Base::const_cast_derived;
792
793
794// FIXME Maybe the EIGEN_DENSE_PUBLIC_INTERFACE could be removed as importing PacketScalar is rarely needed
795#define EIGEN_DENSE_PUBLIC_INTERFACE(Derived) \
796 EIGEN_GENERIC_PUBLIC_INTERFACE(Derived) \
797 typedef typename Base::PacketScalar PacketScalar;
798
799
800#define EIGEN_PLAIN_ENUM_MIN(a,b) (((int)a <= (int)b) ? (int)a : (int)b)
801#define EIGEN_PLAIN_ENUM_MAX(a,b) (((int)a >= (int)b) ? (int)a : (int)b)
802
803// EIGEN_SIZE_MIN_PREFER_DYNAMIC gives the min between compile-time sizes. 0 has absolute priority, followed by 1,
804// followed by Dynamic, followed by other finite values. The reason for giving Dynamic the priority over
805// finite values is that min(3, Dynamic) should be Dynamic, since that could be anything between 0 and 3.
806#define EIGEN_SIZE_MIN_PREFER_DYNAMIC(a,b) (((int)a == 0 || (int)b == 0) ? 0 \
807 : ((int)a == 1 || (int)b == 1) ? 1 \
808 : ((int)a == Dynamic || (int)b == Dynamic) ? Dynamic \
809 : ((int)a <= (int)b) ? (int)a : (int)b)
810
811// EIGEN_SIZE_MIN_PREFER_FIXED is a variant of EIGEN_SIZE_MIN_PREFER_DYNAMIC comparing MaxSizes. The difference is that finite values
812// now have priority over Dynamic, so that min(3, Dynamic) gives 3. Indeed, whatever the actual value is
813// (between 0 and 3), it is not more than 3.
814#define EIGEN_SIZE_MIN_PREFER_FIXED(a,b) (((int)a == 0 || (int)b == 0) ? 0 \
815 : ((int)a == 1 || (int)b == 1) ? 1 \
816 : ((int)a == Dynamic && (int)b == Dynamic) ? Dynamic \
817 : ((int)a == Dynamic) ? (int)b \
818 : ((int)b == Dynamic) ? (int)a \
819 : ((int)a <= (int)b) ? (int)a : (int)b)
820
821// see EIGEN_SIZE_MIN_PREFER_DYNAMIC. No need for a separate variant for MaxSizes here.
822#define EIGEN_SIZE_MAX(a,b) (((int)a == Dynamic || (int)b == Dynamic) ? Dynamic \
823 : ((int)a >= (int)b) ? (int)a : (int)b)
824
825#define EIGEN_LOGICAL_XOR(a,b) (((a) || (b)) && !((a) && (b)))
826
827#define EIGEN_IMPLIES(a,b) (!(a) || (b))
828
829#define EIGEN_MAKE_CWISE_BINARY_OP(METHOD,FUNCTOR) \
830 template<typename OtherDerived> \
831 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseBinaryOp<FUNCTOR<Scalar>, const Derived, const OtherDerived> \
832 (METHOD)(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const \
833 { \
834 return CwiseBinaryOp<FUNCTOR<Scalar>, const Derived, const OtherDerived>(derived(), other.derived()); \
835 }
836
837// the expression type of a cwise product
838#define EIGEN_CWISE_PRODUCT_RETURN_TYPE(LHS,RHS) \
839 CwiseBinaryOp< \
840 internal::scalar_product_op< \
841 typename internal::traits<LHS>::Scalar, \
842 typename internal::traits<RHS>::Scalar \
843 >, \
844 const LHS, \
845 const RHS \
846 >
847
848#ifdef EIGEN_EXCEPTIONS
849# define EIGEN_THROW_X(X) throw X
850# define EIGEN_THROW throw
851# define EIGEN_TRY try
852# define EIGEN_CATCH(X) catch (X)
853#else
854# ifdef __CUDA_ARCH__
855# define EIGEN_THROW_X(X) asm("trap;") return {}
856# define EIGEN_THROW asm("trap;"); return {}
857# else
858# define EIGEN_THROW_X(X) std::abort()
859# define EIGEN_THROW std::abort()
860# endif
861# define EIGEN_TRY if (true)
862# define EIGEN_CATCH(X) else
863#endif
864
865#if EIGEN_HAS_CXX11_NOEXCEPT
866# define EIGEN_NO_THROW noexcept(true)
867# define EIGEN_EXCEPTION_SPEC(X) noexcept(false)
868#else
869# define EIGEN_NO_THROW throw()
870# define EIGEN_EXCEPTION_SPEC(X) throw(X)
871#endif
872
873#endif // EIGEN_MACROS_H