Eigen  3.2.91
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 91
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 result_of?
345 #if (__has_feature(cxx_lambdas) || (defined(__cplusplus) && __cplusplus >= 201103L))
346 #define EIGEN_HAS_STD_RESULT_OF 1
347 #endif
348 
349 // Does the compiler support variadic templates?
350 #if __cplusplus > 199711L
351 #define EIGEN_HAS_VARIADIC_TEMPLATES 1
352 #endif
353 
354 // Does the compiler support const expressions?
355 #ifdef __CUDACC__
356  // Const expressions are not supported regardless of what host compiler is used
357 #elif (defined(__cplusplus) && __cplusplus >= 201402L) || \
358  EIGEN_GNUC_AT_LEAST(4,9)
359 #define EIGEN_HAS_CONSTEXPR 1
360 #endif
361 
362 // Does the compiler support C++11 math?
363 // Let's be conservative and enable the default C++11 implementation only if we are sure it exists
364 #ifndef EIGEN_HAS_CXX11_MATH
365  #if (__cplusplus >= 201103L) && (EIGEN_COMP_GNUC_STRICT || EIGEN_COMP_CLANG || EIGEN_COMP_MSVC || EIGEN_COMP_ICC) \
366  && (EIGEN_ARCH_i386_OR_x86_64) && (EIGEN_OS_GNULINUX || EIGEN_OS_WIN_STRICT || EIGEN_OS_MAC)
367  #define EIGEN_HAS_CXX11_MATH 1
368  #else
369  #define EIGEN_HAS_CXX11_MATH 0
370  #endif
371 #endif
372 
373 // Does the compiler support proper C++11 containers?
374 #ifndef EIGEN_HAS_CXX11_CONTAINERS
375  #if ((__cplusplus >= 201103L) && (EIGEN_COMP_GNUC_STRICT || EIGEN_COMP_CLANG)) || EIGEN_COMP_MSVC >= 1900
376  #define EIGEN_HAS_CXX11_CONTAINERS 1
377  #else
378  #define EIGEN_HAS_CXX11_CONTAINERS 0
379  #endif
380 #endif
381 
387 #ifndef EIGEN_FAST_MATH
388 #define EIGEN_FAST_MATH 1
389 #endif
390 
391 #define EIGEN_DEBUG_VAR(x) std::cerr << #x << " = " << x << std::endl;
392 
393 // concatenate two tokens
394 #define EIGEN_CAT2(a,b) a ## b
395 #define EIGEN_CAT(a,b) EIGEN_CAT2(a,b)
396 
397 // convert a token to a string
398 #define EIGEN_MAKESTRING2(a) #a
399 #define EIGEN_MAKESTRING(a) EIGEN_MAKESTRING2(a)
400 
401 // EIGEN_STRONG_INLINE is a stronger version of the inline, using __forceinline on MSVC,
402 // but it still doesn't use GCC's always_inline. This is useful in (common) situations where MSVC needs forceinline
403 // but GCC is still doing fine with just inline.
404 #if EIGEN_COMP_MSVC || EIGEN_COMP_ICC
405 #define EIGEN_STRONG_INLINE __forceinline
406 #else
407 #define EIGEN_STRONG_INLINE inline
408 #endif
409 
410 // EIGEN_ALWAYS_INLINE is the stronget, it has the effect of making the function inline and adding every possible
411 // attribute to maximize inlining. This should only be used when really necessary: in particular,
412 // it uses __attribute__((always_inline)) on GCC, which most of the time is useless and can severely harm compile times.
413 // FIXME with the always_inline attribute,
414 // gcc 3.4.x reports the following compilation error:
415 // Eval.h:91: sorry, unimplemented: inlining failed in call to 'const Eigen::Eval<Derived> Eigen::MatrixBase<Scalar, Derived>::eval() const'
416 // : function body not available
417 #if EIGEN_GNUC_AT_LEAST(4,0)
418 #define EIGEN_ALWAYS_INLINE __attribute__((always_inline)) inline
419 #else
420 #define EIGEN_ALWAYS_INLINE EIGEN_STRONG_INLINE
421 #endif
422 
423 #if EIGEN_COMP_GNUC
424 #define EIGEN_DONT_INLINE __attribute__((noinline))
425 #elif EIGEN_COMP_MSVC
426 #define EIGEN_DONT_INLINE __declspec(noinline)
427 #else
428 #define EIGEN_DONT_INLINE
429 #endif
430 
431 #if EIGEN_COMP_GNUC
432 #define EIGEN_PERMISSIVE_EXPR __extension__
433 #else
434 #define EIGEN_PERMISSIVE_EXPR
435 #endif
436 
437 // this macro allows to get rid of linking errors about multiply defined functions.
438 // - static is not very good because it prevents definitions from different object files to be merged.
439 // So static causes the resulting linked executable to be bloated with multiple copies of the same function.
440 // - inline is not perfect either as it unwantedly hints the compiler toward inlining the function.
441 #define EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
442 #define EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS inline
443 
444 #ifdef NDEBUG
445 # ifndef EIGEN_NO_DEBUG
446 # define EIGEN_NO_DEBUG
447 # endif
448 #endif
449 
450 // eigen_plain_assert is where we implement the workaround for the assert() bug in GCC <= 4.3, see bug 89
451 #ifdef EIGEN_NO_DEBUG
452  #define eigen_plain_assert(x)
453 #else
454  #if EIGEN_SAFE_TO_USE_STANDARD_ASSERT_MACRO
455  namespace Eigen {
456  namespace internal {
457  inline bool copy_bool(bool b) { return b; }
458  }
459  }
460  #define eigen_plain_assert(x) assert(x)
461  #else
462  // work around bug 89
463  #include <cstdlib> // for abort
464  #include <iostream> // for std::cerr
465 
466  namespace Eigen {
467  namespace internal {
468  // trivial function copying a bool. Must be EIGEN_DONT_INLINE, so we implement it after including Eigen headers.
469  // see bug 89.
470  namespace {
471  EIGEN_DONT_INLINE bool copy_bool(bool b) { return b; }
472  }
473  inline void assert_fail(const char *condition, const char *function, const char *file, int line)
474  {
475  std::cerr << "assertion failed: " << condition << " in function " << function << " at " << file << ":" << line << std::endl;
476  abort();
477  }
478  }
479  }
480  #define eigen_plain_assert(x) \
481  do { \
482  if(!Eigen::internal::copy_bool(x)) \
483  Eigen::internal::assert_fail(EIGEN_MAKESTRING(x), __PRETTY_FUNCTION__, __FILE__, __LINE__); \
484  } while(false)
485  #endif
486 #endif
487 
488 // eigen_assert can be overridden
489 #ifndef eigen_assert
490 #define eigen_assert(x) eigen_plain_assert(x)
491 #endif
492 
493 #ifdef EIGEN_INTERNAL_DEBUGGING
494 #define eigen_internal_assert(x) eigen_assert(x)
495 #else
496 #define eigen_internal_assert(x)
497 #endif
498 
499 #ifdef EIGEN_NO_DEBUG
500 #define EIGEN_ONLY_USED_FOR_DEBUG(x) EIGEN_UNUSED_VARIABLE(x)
501 #else
502 #define EIGEN_ONLY_USED_FOR_DEBUG(x)
503 #endif
504 
505 #ifndef EIGEN_NO_DEPRECATED_WARNING
506  #if EIGEN_COMP_GNUC
507  #define EIGEN_DEPRECATED __attribute__((deprecated))
508  #elif EIGEN_COMP_MSVC
509  #define EIGEN_DEPRECATED __declspec(deprecated)
510  #else
511  #define EIGEN_DEPRECATED
512  #endif
513 #else
514  #define EIGEN_DEPRECATED
515 #endif
516 
517 #if EIGEN_COMP_GNUC
518 #define EIGEN_UNUSED __attribute__((unused))
519 #else
520 #define EIGEN_UNUSED
521 #endif
522 
523 // Suppresses 'unused variable' warnings.
524 namespace Eigen {
525  namespace internal {
526  template<typename T> EIGEN_DEVICE_FUNC void ignore_unused_variable(const T&) {}
527  }
528 }
529 #define EIGEN_UNUSED_VARIABLE(var) Eigen::internal::ignore_unused_variable(var);
530 
531 #if !defined(EIGEN_ASM_COMMENT)
532  #if EIGEN_COMP_GNUC && (EIGEN_ARCH_i386_OR_x86_64 || EIGEN_ARCH_ARM_OR_ARM64)
533  #define EIGEN_ASM_COMMENT(X) __asm__("#" X)
534  #else
535  #define EIGEN_ASM_COMMENT(X)
536  #endif
537 #endif
538 
539 
540 //------------------------------------------------------------------------------------------
541 // Static and dynamic alignment control
542 //
543 // The main purpose of this section is to define EIGEN_MAX_ALIGN_BYTES and EIGEN_MAX_STATIC_ALIGN_BYTES
544 // as the maximal boundary in bytes on which dynamically and statically allocated data may be alignment respectively.
545 // The values of EIGEN_MAX_ALIGN_BYTES and EIGEN_MAX_STATIC_ALIGN_BYTES can be specified by the user. If not,
546 // a default value is automatically computed based on architecture, compiler, and OS.
547 //
548 // This section also defines macros EIGEN_ALIGN_TO_BOUNDARY(N) and the shortcuts EIGEN_ALIGN{8,16,32,_MAX}
549 // to be used to declare statically aligned buffers.
550 //------------------------------------------------------------------------------------------
551 
552 
553 /* EIGEN_ALIGN_TO_BOUNDARY(n) forces data to be n-byte aligned. This is used to satisfy SIMD requirements.
554  * However, we do that EVEN if vectorization (EIGEN_VECTORIZE) is disabled,
555  * so that vectorization doesn't affect binary compatibility.
556  *
557  * If we made alignment depend on whether or not EIGEN_VECTORIZE is defined, it would be impossible to link
558  * vectorized and non-vectorized code.
559  */
560 #if (defined __CUDACC__)
561  #define EIGEN_ALIGN_TO_BOUNDARY(n) __align__(n)
562 #elif EIGEN_COMP_GNUC || EIGEN_COMP_PGI || EIGEN_COMP_IBM || EIGEN_COMP_ARM
563  #define EIGEN_ALIGN_TO_BOUNDARY(n) __attribute__((aligned(n)))
564 #elif EIGEN_COMP_MSVC
565  #define EIGEN_ALIGN_TO_BOUNDARY(n) __declspec(align(n))
566 #elif EIGEN_COMP_SUNCC
567  // FIXME not sure about this one:
568  #define EIGEN_ALIGN_TO_BOUNDARY(n) __attribute__((aligned(n)))
569 #else
570  #error Please tell me what is the equivalent of __attribute__((aligned(n))) for your compiler
571 #endif
572 
573 // If the user explicitly disable vectorization, then we also disable alignment
574 #if defined(EIGEN_DONT_VECTORIZE)
575  #define EIGEN_IDEAL_MAX_ALIGN_BYTES 0
576 #elif defined(__AVX__)
577  // 32 bytes static alignmeent is preferred only if really required
578  #define EIGEN_IDEAL_MAX_ALIGN_BYTES 32
579 #else
580  #define EIGEN_IDEAL_MAX_ALIGN_BYTES 16
581 #endif
582 
583 
584 // EIGEN_MIN_ALIGN_BYTES defines the minimal value for which the notion of explicit alignment makes sense
585 #define EIGEN_MIN_ALIGN_BYTES 16
586 
587 // Defined the boundary (in bytes) on which the data needs to be aligned. Note
588 // that unless EIGEN_ALIGN is defined and not equal to 0, the data may not be
589 // aligned at all regardless of the value of this #define.
590 
591 #if (defined(EIGEN_DONT_ALIGN_STATICALLY) || defined(EIGEN_DONT_ALIGN)) && defined(EIGEN_MAX_STATIC_ALIGN_BYTES) && EIGEN_MAX_STATIC_ALIGN_BYTES>0
592 #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.
593 #endif
594 
595 // EIGEN_DONT_ALIGN_STATICALLY and EIGEN_DONT_ALIGN are deprectated
596 // They imply EIGEN_MAX_STATIC_ALIGN_BYTES=0
597 #if defined(EIGEN_DONT_ALIGN_STATICALLY) || defined(EIGEN_DONT_ALIGN)
598  #ifdef EIGEN_MAX_STATIC_ALIGN_BYTES
599  #undef EIGEN_MAX_STATIC_ALIGN_BYTES
600  #endif
601  #define EIGEN_MAX_STATIC_ALIGN_BYTES 0
602 #endif
603 
604 #ifndef EIGEN_MAX_STATIC_ALIGN_BYTES
605 
606  // Try to automatically guess what is the best default value for EIGEN_MAX_STATIC_ALIGN_BYTES
607 
608  // 16 byte alignment is only useful for vectorization. Since it affects the ABI, we need to enable
609  // 16 byte alignment on all platforms where vectorization might be enabled. In theory we could always
610  // enable alignment, but it can be a cause of problems on some platforms, so we just disable it in
611  // certain common platform (compiler+architecture combinations) to avoid these problems.
612  // Only static alignment is really problematic (relies on nonstandard compiler extensions that don't
613  // work everywhere, for example don't work on GCC/ARM), try to keep heap alignment even
614  // when we have to disable static alignment.
615  #if EIGEN_COMP_GNUC && !(EIGEN_ARCH_i386_OR_x86_64 || EIGEN_ARCH_PPC || EIGEN_ARCH_IA64)
616  #define EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT 1
617  #else
618  #define EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT 0
619  #endif
620 
621  // static alignment is completely disabled with GCC 3, Sun Studio, and QCC/QNX
622  #if !EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT \
623  && !EIGEN_GCC3_OR_OLDER \
624  && !EIGEN_COMP_SUNCC \
625  && !EIGEN_OS_QNX
626  #define EIGEN_ARCH_WANTS_STACK_ALIGNMENT 1
627  #else
628  #define EIGEN_ARCH_WANTS_STACK_ALIGNMENT 0
629  #endif
630 
631  #if EIGEN_ARCH_WANTS_STACK_ALIGNMENT
632  #define EIGEN_MAX_STATIC_ALIGN_BYTES EIGEN_IDEAL_MAX_ALIGN_BYTES
633  #else
634  #define EIGEN_MAX_STATIC_ALIGN_BYTES 0
635  #endif
636 
637 #endif
638 
639 // If EIGEN_MAX_ALIGN_BYTES is defined, then it is considered as an upper bound for EIGEN_MAX_ALIGN_BYTES
640 #if defined(EIGEN_MAX_ALIGN_BYTES) && EIGEN_MAX_ALIGN_BYTES<EIGEN_MAX_STATIC_ALIGN_BYTES
641 #undef EIGEN_MAX_STATIC_ALIGN_BYTES
642 #define EIGEN_MAX_STATIC_ALIGN_BYTES EIGEN_MAX_ALIGN_BYTES
643 #endif
644 
645 #if EIGEN_MAX_STATIC_ALIGN_BYTES==0 && !defined(EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT)
646  #define EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT
647 #endif
648 
649 // At this stage, EIGEN_MAX_STATIC_ALIGN_BYTES>0 is the true test whether we want to align arrays on the stack or not.
650 // It takes into account both the user choice to explicitly enable/disable alignment (by settting EIGEN_MAX_STATIC_ALIGN_BYTES)
651 // and the architecture config (EIGEN_ARCH_WANTS_STACK_ALIGNMENT).
652 // Henceforth, only EIGEN_MAX_STATIC_ALIGN_BYTES should be used.
653 
654 
655 // Shortcuts to EIGEN_ALIGN_TO_BOUNDARY
656 #define EIGEN_ALIGN8 EIGEN_ALIGN_TO_BOUNDARY(8)
657 #define EIGEN_ALIGN16 EIGEN_ALIGN_TO_BOUNDARY(16)
658 #define EIGEN_ALIGN32 EIGEN_ALIGN_TO_BOUNDARY(32)
659 #define EIGEN_ALIGN64 EIGEN_ALIGN_TO_BOUNDARY(64)
660 #if EIGEN_MAX_STATIC_ALIGN_BYTES>0
661 #define EIGEN_ALIGN_MAX EIGEN_ALIGN_TO_BOUNDARY(EIGEN_MAX_STATIC_ALIGN_BYTES)
662 #else
663 #define EIGEN_ALIGN_MAX
664 #endif
665 
666 
667 // Dynamic alignment control
668 
669 #if defined(EIGEN_DONT_ALIGN) && defined(EIGEN_MAX_ALIGN_BYTES) && EIGEN_MAX_ALIGN_BYTES>0
670 #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.
671 #endif
672 
673 #ifdef EIGEN_DONT_ALIGN
674  #ifdef EIGEN_MAX_ALIGN_BYTES
675  #undef EIGEN_MAX_ALIGN_BYTES
676  #endif
677  #define EIGEN_MAX_ALIGN_BYTES 0
678 #elif !defined(EIGEN_MAX_ALIGN_BYTES)
679  #define EIGEN_MAX_ALIGN_BYTES EIGEN_IDEAL_MAX_ALIGN_BYTES
680 #endif
681 
682 #if EIGEN_IDEAL_MAX_ALIGN_BYTES > EIGEN_MAX_ALIGN_BYTES
683 #define EIGEN_DEFAULT_ALIGN_BYTES EIGEN_IDEAL_MAX_ALIGN_BYTES
684 #else
685 #define EIGEN_DEFAULT_ALIGN_BYTES EIGEN_MAX_ALIGN_BYTES
686 #endif
687 
688 //----------------------------------------------------------------------
689 
690 
691 #ifdef EIGEN_DONT_USE_RESTRICT_KEYWORD
692  #define EIGEN_RESTRICT
693 #endif
694 #ifndef EIGEN_RESTRICT
695  #define EIGEN_RESTRICT __restrict
696 #endif
697 
698 #ifndef EIGEN_STACK_ALLOCATION_LIMIT
699 // 131072 == 128 KB
700 #define EIGEN_STACK_ALLOCATION_LIMIT 131072
701 #endif
702 
703 #ifndef EIGEN_DEFAULT_IO_FORMAT
704 #ifdef EIGEN_MAKING_DOCS
705 // format used in Eigen's documentation
706 // needed to define it here as escaping characters in CMake add_definition's argument seems very problematic.
707 #define EIGEN_DEFAULT_IO_FORMAT Eigen::IOFormat(3, 0, " ", "\n", "", "")
708 #else
709 #define EIGEN_DEFAULT_IO_FORMAT Eigen::IOFormat()
710 #endif
711 #endif
712 
713 // just an empty macro !
714 #define EIGEN_EMPTY
715 
716 #if EIGEN_COMP_MSVC_STRICT && EIGEN_COMP_MSVC < 1900 // for older MSVC versions using the base operator is sufficient (cf Bug 1000)
717  #define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
718  using Base::operator =;
719 #elif EIGEN_COMP_CLANG // workaround clang bug (see http://forum.kde.org/viewtopic.php?f=74&t=102653)
720  #define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
721  using Base::operator =; \
722  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const Derived& other) { Base::operator=(other); return *this; } \
723  template <typename OtherDerived> \
724  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const DenseBase<OtherDerived>& other) { Base::operator=(other.derived()); return *this; }
725 #else
726  #define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
727  using Base::operator =; \
728  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const Derived& other) \
729  { \
730  Base::operator=(other); \
731  return *this; \
732  }
733 #endif
734 
735 
740 #define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived) EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived)
741 
750 // TODO The EIGEN_DENSE_PUBLIC_INTERFACE should not exists anymore
751 
752 #define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived) \
753  typedef typename Eigen::internal::traits<Derived>::Scalar Scalar; \
754  typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; \
755  typedef typename Base::CoeffReturnType CoeffReturnType; \
756  typedef typename Eigen::internal::ref_selector<Derived>::type Nested; \
757  typedef typename Eigen::internal::traits<Derived>::StorageKind StorageKind; \
758  typedef typename Eigen::internal::traits<Derived>::StorageIndex StorageIndex; \
759  enum { RowsAtCompileTime = Eigen::internal::traits<Derived>::RowsAtCompileTime, \
760  ColsAtCompileTime = Eigen::internal::traits<Derived>::ColsAtCompileTime, \
761  Flags = Eigen::internal::traits<Derived>::Flags, \
762  SizeAtCompileTime = Base::SizeAtCompileTime, \
763  MaxSizeAtCompileTime = Base::MaxSizeAtCompileTime, \
764  IsVectorAtCompileTime = Base::IsVectorAtCompileTime };
765 
766 
767 #define EIGEN_DENSE_PUBLIC_INTERFACE(Derived) \
768  EIGEN_GENERIC_PUBLIC_INTERFACE(Derived) \
769  typedef typename Base::PacketScalar PacketScalar; \
770  enum { MaxRowsAtCompileTime = Eigen::internal::traits<Derived>::MaxRowsAtCompileTime, \
771  MaxColsAtCompileTime = Eigen::internal::traits<Derived>::MaxColsAtCompileTime}; \
772  using Base::derived; \
773  using Base::const_cast_derived;
774 
775 #define EIGEN_PLAIN_ENUM_MIN(a,b) (((int)a <= (int)b) ? (int)a : (int)b)
776 #define EIGEN_PLAIN_ENUM_MAX(a,b) (((int)a >= (int)b) ? (int)a : (int)b)
777 
778 // EIGEN_SIZE_MIN_PREFER_DYNAMIC gives the min between compile-time sizes. 0 has absolute priority, followed by 1,
779 // followed by Dynamic, followed by other finite values. The reason for giving Dynamic the priority over
780 // finite values is that min(3, Dynamic) should be Dynamic, since that could be anything between 0 and 3.
781 #define EIGEN_SIZE_MIN_PREFER_DYNAMIC(a,b) (((int)a == 0 || (int)b == 0) ? 0 \
782  : ((int)a == 1 || (int)b == 1) ? 1 \
783  : ((int)a == Dynamic || (int)b == Dynamic) ? Dynamic \
784  : ((int)a <= (int)b) ? (int)a : (int)b)
785 
786 // EIGEN_SIZE_MIN_PREFER_FIXED is a variant of EIGEN_SIZE_MIN_PREFER_DYNAMIC comparing MaxSizes. The difference is that finite values
787 // now have priority over Dynamic, so that min(3, Dynamic) gives 3. Indeed, whatever the actual value is
788 // (between 0 and 3), it is not more than 3.
789 #define EIGEN_SIZE_MIN_PREFER_FIXED(a,b) (((int)a == 0 || (int)b == 0) ? 0 \
790  : ((int)a == 1 || (int)b == 1) ? 1 \
791  : ((int)a == Dynamic && (int)b == Dynamic) ? Dynamic \
792  : ((int)a == Dynamic) ? (int)b \
793  : ((int)b == Dynamic) ? (int)a \
794  : ((int)a <= (int)b) ? (int)a : (int)b)
795 
796 // see EIGEN_SIZE_MIN_PREFER_DYNAMIC. No need for a separate variant for MaxSizes here.
797 #define EIGEN_SIZE_MAX(a,b) (((int)a == Dynamic || (int)b == Dynamic) ? Dynamic \
798  : ((int)a >= (int)b) ? (int)a : (int)b)
799 
800 #define EIGEN_LOGICAL_XOR(a,b) (((a) || (b)) && !((a) && (b)))
801 
802 #define EIGEN_IMPLIES(a,b) (!(a) || (b))
803 
804 #define EIGEN_MAKE_CWISE_BINARY_OP(METHOD,FUNCTOR) \
805  template<typename OtherDerived> \
806  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseBinaryOp<FUNCTOR<Scalar>, const Derived, const OtherDerived> \
807  (METHOD)(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const \
808  { \
809  return CwiseBinaryOp<FUNCTOR<Scalar>, const Derived, const OtherDerived>(derived(), other.derived()); \
810  }
811 
812 // the expression type of a cwise product
813 #define EIGEN_CWISE_PRODUCT_RETURN_TYPE(LHS,RHS) \
814  CwiseBinaryOp< \
815  internal::scalar_product_op< \
816  typename internal::traits<LHS>::Scalar, \
817  typename internal::traits<RHS>::Scalar \
818  >, \
819  const LHS, \
820  const RHS \
821  >
822 
823 #ifdef EIGEN_EXCEPTIONS
824 # define EIGEN_THROW_X(X) throw X
825 # define EIGEN_THROW throw
826 # define EIGEN_TRY try
827 # define EIGEN_CATCH(X) catch (X)
828 #else
829 # ifdef __CUDA_ARCH__
830 # define EIGEN_THROW_X(X) asm("trap;") return {}
831 # define EIGEN_THROW asm("trap;"); return {}
832 # else
833 # define EIGEN_THROW_X(X) std::abort()
834 # define EIGEN_THROW std::abort()
835 # endif
836 # define EIGEN_TRY if (true)
837 # define EIGEN_CATCH(X) else
838 #endif
839 
840 #endif // EIGEN_MACROS_H
Definition: LDLT.h:16
Definition: Eigen_Colamd.h:54