Eigen  3.2.10
 
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-2010 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 10
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
23// Compiler identification, EIGEN_COMP_*
24
26#ifdef __GNUC__
27 #define EIGEN_COMP_GNUC 1
28#else
29 #define EIGEN_COMP_GNUC 0
30#endif
31
33#if defined(__clang__)
34 #define EIGEN_COMP_CLANG 1
35#else
36 #define EIGEN_COMP_CLANG 0
37#endif
38
39
41#if defined(__llvm__)
42 #define EIGEN_COMP_LLVM 1
43#else
44 #define EIGEN_COMP_LLVM 0
45#endif
46
48#if defined(__INTEL_COMPILER)
49 #define EIGEN_COMP_ICC __INTEL_COMPILER
50#else
51 #define EIGEN_COMP_ICC 0
52#endif
53
55#if defined(__MINGW32__)
56 #define EIGEN_COMP_MINGW 1
57#else
58 #define EIGEN_COMP_MINGW 0
59#endif
60
62#if defined(__SUNPRO_CC)
63 #define EIGEN_COMP_SUNCC 1
64#else
65 #define EIGEN_COMP_SUNCC 0
66#endif
67
69#if defined(_MSC_VER)
70 #define EIGEN_COMP_MSVC _MSC_VER
71#else
72 #define EIGEN_COMP_MSVC 0
73#endif
74
76#if EIGEN_COMP_MSVC && !(EIGEN_COMP_ICC)
77 #define EIGEN_COMP_MSVC_STRICT _MSC_VER
78#else
79 #define EIGEN_COMP_MSVC_STRICT 0
80#endif
81
83#if defined(__IBMCPP__) || defined(__xlc__)
84 #define EIGEN_COMP_IBM 1
85#else
86 #define EIGEN_COMP_IBM 0
87#endif
88
90#if defined(__PGI)
91 #define EIGEN_COMP_PGI 1
92#else
93 #define EIGEN_COMP_PGI 0
94#endif
95
97#if defined(__CC_ARM) || defined(__ARMCC_VERSION)
98 #define EIGEN_COMP_ARM 1
99#else
100 #define EIGEN_COMP_ARM 0
101#endif
102
103
105#if EIGEN_COMP_GNUC && !(EIGEN_COMP_CLANG || EIGEN_COMP_ICC || EIGEN_COMP_MINGW || EIGEN_COMP_PGI || EIGEN_COMP_IBM || EIGEN_COMP_ARM )
106 #define EIGEN_COMP_GNUC_STRICT 1
107#else
108 #define EIGEN_COMP_GNUC_STRICT 0
109#endif
110
111
112#if EIGEN_COMP_GNUC
113 #define EIGEN_GNUC_AT_LEAST(x,y) ((__GNUC__==x && __GNUC_MINOR__>=y) || __GNUC__>x)
114 #define EIGEN_GNUC_AT_MOST(x,y) ((__GNUC__==x && __GNUC_MINOR__<=y) || __GNUC__<x)
115 #define EIGEN_GNUC_AT(x,y) ( __GNUC__==x && __GNUC_MINOR__==y )
116#else
117 #define EIGEN_GNUC_AT_LEAST(x,y) 0
118 #define EIGEN_GNUC_AT_MOST(x,y) 0
119 #define EIGEN_GNUC_AT(x,y) 0
120#endif
121
122// FIXME: could probably be removed as we do not support gcc 3.x anymore
123#if EIGEN_COMP_GNUC && (__GNUC__ <= 3)
124#define EIGEN_GCC3_OR_OLDER 1
125#else
126#define EIGEN_GCC3_OR_OLDER 0
127#endif
128
129
130// Architecture identification, EIGEN_ARCH_*
131
132#if defined(__x86_64__) || defined(_M_X64) || defined(__amd64)
133 #define EIGEN_ARCH_x86_64 1
134#else
135 #define EIGEN_ARCH_x86_64 0
136#endif
137
138#if defined(__i386__) || defined(_M_IX86) || defined(_X86_) || defined(__i386)
139 #define EIGEN_ARCH_i386 1
140#else
141 #define EIGEN_ARCH_i386 0
142#endif
143
144#if EIGEN_ARCH_x86_64 || EIGEN_ARCH_i386
145 #define EIGEN_ARCH_i386_OR_x86_64 1
146#else
147 #define EIGEN_ARCH_i386_OR_x86_64 0
148#endif
149
151#if defined(__arm__)
152 #define EIGEN_ARCH_ARM 1
153#else
154 #define EIGEN_ARCH_ARM 0
155#endif
156
158#if defined(__aarch64__)
159 #define EIGEN_ARCH_ARM64 1
160#else
161 #define EIGEN_ARCH_ARM64 0
162#endif
163
164#if EIGEN_ARCH_ARM || EIGEN_ARCH_ARM64
165 #define EIGEN_ARCH_ARM_OR_ARM64 1
166#else
167 #define EIGEN_ARCH_ARM_OR_ARM64 0
168#endif
169
171#if defined(__mips__) || defined(__mips)
172 #define EIGEN_ARCH_MIPS 1
173#else
174 #define EIGEN_ARCH_MIPS 0
175#endif
176
178#if defined(__sparc__) || defined(__sparc)
179 #define EIGEN_ARCH_SPARC 1
180#else
181 #define EIGEN_ARCH_SPARC 0
182#endif
183
185#if defined(__ia64__)
186 #define EIGEN_ARCH_IA64 1
187#else
188 #define EIGEN_ARCH_IA64 0
189#endif
190
192#if defined(__powerpc__) || defined(__ppc__) || defined(_M_PPC)
193 #define EIGEN_ARCH_PPC 1
194#else
195 #define EIGEN_ARCH_PPC 0
196#endif
197
198
199
200// Operating system identification, EIGEN_OS_*
201
203#if defined(__unix__) || defined(__unix)
204 #define EIGEN_OS_UNIX 1
205#else
206 #define EIGEN_OS_UNIX 0
207#endif
208
210#if defined(__linux__)
211 #define EIGEN_OS_LINUX 1
212#else
213 #define EIGEN_OS_LINUX 0
214#endif
215
217// note: ANDROID is defined when using ndk_build, __ANDROID__ is defined when using a standalone toolchain.
218#if defined(__ANDROID__) || defined(ANDROID)
219 #define EIGEN_OS_ANDROID 1
220#else
221 #define EIGEN_OS_ANDROID 0
222#endif
223
225#if defined(__gnu_linux__) && !(EIGEN_OS_ANDROID)
226 #define EIGEN_OS_GNULINUX 1
227#else
228 #define EIGEN_OS_GNULINUX 0
229#endif
230
232#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__)
233 #define EIGEN_OS_BSD 1
234#else
235 #define EIGEN_OS_BSD 0
236#endif
237
239#if defined(__APPLE__)
240 #define EIGEN_OS_MAC 1
241#else
242 #define EIGEN_OS_MAC 0
243#endif
244
246#if defined(__QNX__)
247 #define EIGEN_OS_QNX 1
248#else
249 #define EIGEN_OS_QNX 0
250#endif
251
253#if defined(_WIN32)
254 #define EIGEN_OS_WIN 1
255#else
256 #define EIGEN_OS_WIN 0
257#endif
258
260#if defined(_WIN64)
261 #define EIGEN_OS_WIN64 1
262#else
263 #define EIGEN_OS_WIN64 0
264#endif
265
267#if defined(_WIN32_WCE)
268 #define EIGEN_OS_WINCE 1
269#else
270 #define EIGEN_OS_WINCE 0
271#endif
272
274#if defined(__CYGWIN__)
275 #define EIGEN_OS_CYGWIN 1
276#else
277 #define EIGEN_OS_CYGWIN 0
278#endif
279
281#if EIGEN_OS_WIN && !( EIGEN_OS_WINCE || EIGEN_OS_CYGWIN )
282 #define EIGEN_OS_WIN_STRICT 1
283#else
284 #define EIGEN_OS_WIN_STRICT 0
285#endif
286
288#if (defined(sun) || defined(__sun)) && !(defined(__SVR4) || defined(__svr4__))
289 #define EIGEN_OS_SUN 1
290#else
291 #define EIGEN_OS_SUN 0
292#endif
293
295#if (defined(sun) || defined(__sun)) && (defined(__SVR4) || defined(__svr4__))
296 #define EIGEN_OS_SOLARIS 1
297#else
298 #define EIGEN_OS_SOLARIS 0
299#endif
300
301
302#if EIGEN_GNUC_AT_MOST(4,3) && !defined(__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// 16 byte alignment is only useful for vectorization. Since it affects the ABI, we need to enable
310// 16 byte alignment on all platforms where vectorization might be enabled. In theory we could always
311// enable alignment, but it can be a cause of problems on some platforms, so we just disable it in
312// certain common platform (compiler+architecture combinations) to avoid these problems.
313// Only static alignment is really problematic (relies on nonstandard compiler extensions that don't
314// work everywhere, for example don't work on GCC/ARM), try to keep heap alignment even
315// when we have to disable static alignment.
316#if defined(__GNUC__) && !(defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) || defined(__ppc__) || defined(__ia64__))
317#define EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT 1
318#else
319#define EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT 0
320#endif
321
322// static alignment is completely disabled with GCC 3, Sun Studio, and QCC/QNX
323#if !EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT \
324 && !EIGEN_GCC3_OR_OLDER \
325 && !defined(__SUNPRO_CC) \
326 && !defined(__QNXNTO__)
327 #define EIGEN_ARCH_WANTS_STACK_ALIGNMENT 1
328#else
329 #define EIGEN_ARCH_WANTS_STACK_ALIGNMENT 0
330#endif
331
332#ifdef EIGEN_DONT_ALIGN
333 #ifndef EIGEN_DONT_ALIGN_STATICALLY
334 #define EIGEN_DONT_ALIGN_STATICALLY
335 #endif
336 #define EIGEN_ALIGN 0
337#else
338 #define EIGEN_ALIGN 1
339#endif
340
341// EIGEN_ALIGN_STATICALLY is the true test whether we want to align arrays on the stack or not. It takes into account both the user choice to explicitly disable
342// alignment (EIGEN_DONT_ALIGN_STATICALLY) and the architecture config (EIGEN_ARCH_WANTS_STACK_ALIGNMENT). Henceforth, only EIGEN_ALIGN_STATICALLY should be used.
343#if EIGEN_ARCH_WANTS_STACK_ALIGNMENT && !defined(EIGEN_DONT_ALIGN_STATICALLY)
344 #define EIGEN_ALIGN_STATICALLY 1
345#else
346 #define EIGEN_ALIGN_STATICALLY 0
347 #ifndef EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT
348 #define EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT
349 #endif
350#endif
351
352#ifdef EIGEN_DEFAULT_TO_ROW_MAJOR
353#define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION RowMajor
354#else
355#define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION ColMajor
356#endif
357
358#ifndef EIGEN_DEFAULT_DENSE_INDEX_TYPE
359#define EIGEN_DEFAULT_DENSE_INDEX_TYPE std::ptrdiff_t
360#endif
361
362// A Clang feature extension to determine compiler features.
363// We use it to determine 'cxx_rvalue_references'
364#ifndef __has_feature
365# define __has_feature(x) 0
366#endif
367
368// Do we support r-value references?
369#if (__has_feature(cxx_rvalue_references) || \
370 (defined(__cplusplus) && __cplusplus >= 201103L) || \
371 (defined(_MSC_VER) && _MSC_VER >= 1600))
372 #define EIGEN_HAVE_RVALUE_REFERENCES
373#endif
374
375
376// Cross compiler wrapper around LLVM's __has_builtin
377#ifdef __has_builtin
378# define EIGEN_HAS_BUILTIN(x) __has_builtin(x)
379#else
380# define EIGEN_HAS_BUILTIN(x) 0
381#endif
382
388#ifndef EIGEN_FAST_MATH
389#define EIGEN_FAST_MATH 1
390#endif
391
392#define EIGEN_DEBUG_VAR(x) std::cerr << #x << " = " << x << std::endl;
393
394// concatenate two tokens
395#define EIGEN_CAT2(a,b) a ## b
396#define EIGEN_CAT(a,b) EIGEN_CAT2(a,b)
397
398// convert a token to a string
399#define EIGEN_MAKESTRING2(a) #a
400#define EIGEN_MAKESTRING(a) EIGEN_MAKESTRING2(a)
401
402// EIGEN_STRONG_INLINE is a stronger version of the inline, using __forceinline on MSVC,
403// but it still doesn't use GCC's always_inline. This is useful in (common) situations where MSVC needs forceinline
404// but GCC is still doing fine with just inline.
405#if (defined _MSC_VER) || (defined __INTEL_COMPILER)
406#define EIGEN_STRONG_INLINE __forceinline
407#else
408#define EIGEN_STRONG_INLINE inline
409#endif
410
411// EIGEN_ALWAYS_INLINE is the stronget, it has the effect of making the function inline and adding every possible
412// attribute to maximize inlining. This should only be used when really necessary: in particular,
413// it uses __attribute__((always_inline)) on GCC, which most of the time is useless and can severely harm compile times.
414// FIXME with the always_inline attribute,
415// gcc 3.4.x and 4.1 reports the following compilation error:
416// Eval.h:91: sorry, unimplemented: inlining failed in call to 'const Eigen::Eval<Derived> Eigen::MatrixBase<Scalar, Derived>::eval() const'
417// : function body not available
418// See also bug 1367
419#if EIGEN_GNUC_AT_LEAST(4,2)
420#define EIGEN_ALWAYS_INLINE __attribute__((always_inline)) inline
421#else
422#define EIGEN_ALWAYS_INLINE EIGEN_STRONG_INLINE
423#endif
424
425#if (defined __GNUC__)
426#define EIGEN_DONT_INLINE __attribute__((noinline))
427#elif (defined _MSC_VER)
428#define EIGEN_DONT_INLINE __declspec(noinline)
429#else
430#define EIGEN_DONT_INLINE
431#endif
432
433#if (defined __GNUC__)
434#define EIGEN_PERMISSIVE_EXPR __extension__
435#else
436#define EIGEN_PERMISSIVE_EXPR
437#endif
438
439// this macro allows to get rid of linking errors about multiply defined functions.
440// - static is not very good because it prevents definitions from different object files to be merged.
441// So static causes the resulting linked executable to be bloated with multiple copies of the same function.
442// - inline is not perfect either as it unwantedly hints the compiler toward inlining the function.
443#define EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
444#define EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS inline
445
446#ifdef NDEBUG
447# ifndef EIGEN_NO_DEBUG
448# define EIGEN_NO_DEBUG
449# endif
450#endif
451
452// eigen_plain_assert is where we implement the workaround for the assert() bug in GCC <= 4.3, see bug 89
453#ifdef EIGEN_NO_DEBUG
454 #define eigen_plain_assert(x)
455#else
456 #if EIGEN_SAFE_TO_USE_STANDARD_ASSERT_MACRO
457 namespace Eigen {
458 namespace internal {
459 inline bool copy_bool(bool b) { return b; }
460 }
461 }
462 #define eigen_plain_assert(x) assert(x)
463 #else
464 // work around bug 89
465 #include <cstdlib> // for abort
466 #include <iostream> // for std::cerr
467
468 namespace Eigen {
469 namespace internal {
470 // trivial function copying a bool. Must be EIGEN_DONT_INLINE, so we implement it after including Eigen headers.
471 // see bug 89.
472 namespace {
473 EIGEN_DONT_INLINE bool copy_bool(bool b) { return b; }
474 }
475 inline void assert_fail(const char *condition, const char *function, const char *file, int line)
476 {
477 std::cerr << "assertion failed: " << condition << " in function " << function << " at " << file << ":" << line << std::endl;
478 abort();
479 }
480 }
481 }
482 #define eigen_plain_assert(x) \
483 do { \
484 if(!Eigen::internal::copy_bool(x)) \
485 Eigen::internal::assert_fail(EIGEN_MAKESTRING(x), __PRETTY_FUNCTION__, __FILE__, __LINE__); \
486 } while(false)
487 #endif
488#endif
489
490// eigen_assert can be overridden
491#ifndef eigen_assert
492#define eigen_assert(x) eigen_plain_assert(x)
493#endif
494
495#ifdef EIGEN_INTERNAL_DEBUGGING
496#define eigen_internal_assert(x) eigen_assert(x)
497#else
498#define eigen_internal_assert(x)
499#endif
500
501#ifdef EIGEN_NO_DEBUG
502#define EIGEN_ONLY_USED_FOR_DEBUG(x) (void)x
503#else
504#define EIGEN_ONLY_USED_FOR_DEBUG(x)
505#endif
506
507#ifndef EIGEN_NO_DEPRECATED_WARNING
508 #if (defined __GNUC__)
509 #define EIGEN_DEPRECATED __attribute__((deprecated))
510 #elif (defined _MSC_VER)
511 #define EIGEN_DEPRECATED __declspec(deprecated)
512 #else
513 #define EIGEN_DEPRECATED
514 #endif
515#else
516 #define EIGEN_DEPRECATED
517#endif
518
519#if (defined __GNUC__)
520#define EIGEN_UNUSED __attribute__((unused))
521#else
522#define EIGEN_UNUSED
523#endif
524
525// Suppresses 'unused variable' warnings.
526namespace Eigen {
527 namespace internal {
528 template<typename T> void ignore_unused_variable(const T&) {}
529 }
530}
531#define EIGEN_UNUSED_VARIABLE(var) Eigen::internal::ignore_unused_variable(var);
532
533#if !defined(EIGEN_ASM_COMMENT)
534 #if (defined __GNUC__) && ( defined(__i386__) || defined(__x86_64__) )
535 #define EIGEN_ASM_COMMENT(X) __asm__("#" X)
536 #else
537 #define EIGEN_ASM_COMMENT(X)
538 #endif
539#endif
540
541/* EIGEN_ALIGN_TO_BOUNDARY(n) forces data to be n-byte aligned. This is used to satisfy SIMD requirements.
542 * However, we do that EVEN if vectorization (EIGEN_VECTORIZE) is disabled,
543 * so that vectorization doesn't affect binary compatibility.
544 *
545 * If we made alignment depend on whether or not EIGEN_VECTORIZE is defined, it would be impossible to link
546 * vectorized and non-vectorized code.
547 */
548#if (defined __GNUC__) || (defined __PGI) || (defined __IBMCPP__) || (defined __ARMCC_VERSION)
549 #define EIGEN_ALIGN_TO_BOUNDARY(n) __attribute__((aligned(n)))
550#elif (defined _MSC_VER)
551 #define EIGEN_ALIGN_TO_BOUNDARY(n) __declspec(align(n))
552#elif (defined __SUNPRO_CC)
553 // FIXME not sure about this one:
554 #define EIGEN_ALIGN_TO_BOUNDARY(n) __attribute__((aligned(n)))
555#else
556 #error Please tell me what is the equivalent of __attribute__((aligned(n))) for your compiler
557#endif
558
559#define EIGEN_ALIGN8 EIGEN_ALIGN_TO_BOUNDARY(8)
560#define EIGEN_ALIGN16 EIGEN_ALIGN_TO_BOUNDARY(16)
561
562#if EIGEN_ALIGN_STATICALLY
563#define EIGEN_USER_ALIGN_TO_BOUNDARY(n) EIGEN_ALIGN_TO_BOUNDARY(n)
564#define EIGEN_USER_ALIGN16 EIGEN_ALIGN16
565#else
566#define EIGEN_USER_ALIGN_TO_BOUNDARY(n)
567#define EIGEN_USER_ALIGN16
568#endif
569
570#ifdef EIGEN_DONT_USE_RESTRICT_KEYWORD
571 #define EIGEN_RESTRICT
572#endif
573#ifndef EIGEN_RESTRICT
574 #define EIGEN_RESTRICT __restrict
575#endif
576
577#ifndef EIGEN_STACK_ALLOCATION_LIMIT
578// 131072 == 128 KB
579#define EIGEN_STACK_ALLOCATION_LIMIT 131072
580#endif
581
582#ifndef EIGEN_DEFAULT_IO_FORMAT
583#ifdef EIGEN_MAKING_DOCS
584// format used in Eigen's documentation
585// needed to define it here as escaping characters in CMake add_definition's argument seems very problematic.
586#define EIGEN_DEFAULT_IO_FORMAT Eigen::IOFormat(3, 0, " ", "\n", "", "")
587#else
588#define EIGEN_DEFAULT_IO_FORMAT Eigen::IOFormat()
589#endif
590#endif
591
592// just an empty macro !
593#define EIGEN_EMPTY
594
595#if defined(_MSC_VER) && (_MSC_VER < 1900) && (!defined(__INTEL_COMPILER))
596#define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
597 using Base::operator =;
598#elif defined(__clang__) // workaround clang bug (see http://forum.kde.org/viewtopic.php?f=74&t=102653)
599#define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
600 using Base::operator =; \
601 EIGEN_STRONG_INLINE Derived& operator=(const Derived& other) { Base::operator=(other); return *this; } \
602 template <typename OtherDerived> \
603 EIGEN_STRONG_INLINE Derived& operator=(const DenseBase<OtherDerived>& other) { Base::operator=(other.derived()); return *this; }
604#else
605#define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
606 using Base::operator =; \
607 EIGEN_STRONG_INLINE Derived& operator=(const Derived& other) \
608 { \
609 Base::operator=(other); \
610 return *this; \
611 }
612#endif
613
618#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived) EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived)
619
627
628#define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived) \
629 typedef typename Eigen::internal::traits<Derived>::Scalar Scalar; \
630 typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; \
631 typedef typename Base::CoeffReturnType CoeffReturnType; \
632 typedef typename Eigen::internal::nested<Derived>::type Nested; \
633 typedef typename Eigen::internal::traits<Derived>::StorageKind StorageKind; \
634 typedef typename Eigen::internal::traits<Derived>::Index Index; \
635 enum { RowsAtCompileTime = Eigen::internal::traits<Derived>::RowsAtCompileTime, \
636 ColsAtCompileTime = Eigen::internal::traits<Derived>::ColsAtCompileTime, \
637 Flags = Eigen::internal::traits<Derived>::Flags, \
638 CoeffReadCost = Eigen::internal::traits<Derived>::CoeffReadCost, \
639 SizeAtCompileTime = Base::SizeAtCompileTime, \
640 MaxSizeAtCompileTime = Base::MaxSizeAtCompileTime, \
641 IsVectorAtCompileTime = Base::IsVectorAtCompileTime };
642
643
644#define EIGEN_DENSE_PUBLIC_INTERFACE(Derived) \
645 typedef typename Eigen::internal::traits<Derived>::Scalar Scalar; \
646 typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; \
647 typedef typename Base::PacketScalar PacketScalar; \
648 typedef typename Base::CoeffReturnType CoeffReturnType; \
649 typedef typename Eigen::internal::nested<Derived>::type Nested; \
650 typedef typename Eigen::internal::traits<Derived>::StorageKind StorageKind; \
651 typedef typename Eigen::internal::traits<Derived>::Index Index; \
652 enum { RowsAtCompileTime = Eigen::internal::traits<Derived>::RowsAtCompileTime, \
653 ColsAtCompileTime = Eigen::internal::traits<Derived>::ColsAtCompileTime, \
654 MaxRowsAtCompileTime = Eigen::internal::traits<Derived>::MaxRowsAtCompileTime, \
655 MaxColsAtCompileTime = Eigen::internal::traits<Derived>::MaxColsAtCompileTime, \
656 Flags = Eigen::internal::traits<Derived>::Flags, \
657 CoeffReadCost = Eigen::internal::traits<Derived>::CoeffReadCost, \
658 SizeAtCompileTime = Base::SizeAtCompileTime, \
659 MaxSizeAtCompileTime = Base::MaxSizeAtCompileTime, \
660 IsVectorAtCompileTime = Base::IsVectorAtCompileTime }; \
661 using Base::derived; \
662 using Base::const_cast_derived;
663
664
665#define EIGEN_PLAIN_ENUM_MIN(a,b) (((int)a <= (int)b) ? (int)a : (int)b)
666#define EIGEN_PLAIN_ENUM_MAX(a,b) (((int)a >= (int)b) ? (int)a : (int)b)
667
668// EIGEN_SIZE_MIN_PREFER_DYNAMIC gives the min between compile-time sizes. 0 has absolute priority, followed by 1,
669// followed by Dynamic, followed by other finite values. The reason for giving Dynamic the priority over
670// finite values is that min(3, Dynamic) should be Dynamic, since that could be anything between 0 and 3.
671#define EIGEN_SIZE_MIN_PREFER_DYNAMIC(a,b) (((int)a == 0 || (int)b == 0) ? 0 \
672 : ((int)a == 1 || (int)b == 1) ? 1 \
673 : ((int)a == Dynamic || (int)b == Dynamic) ? Dynamic \
674 : ((int)a <= (int)b) ? (int)a : (int)b)
675
676// EIGEN_SIZE_MIN_PREFER_FIXED is a variant of EIGEN_SIZE_MIN_PREFER_DYNAMIC comparing MaxSizes. The difference is that finite values
677// now have priority over Dynamic, so that min(3, Dynamic) gives 3. Indeed, whatever the actual value is
678// (between 0 and 3), it is not more than 3.
679#define EIGEN_SIZE_MIN_PREFER_FIXED(a,b) (((int)a == 0 || (int)b == 0) ? 0 \
680 : ((int)a == 1 || (int)b == 1) ? 1 \
681 : ((int)a == Dynamic && (int)b == Dynamic) ? Dynamic \
682 : ((int)a == Dynamic) ? (int)b \
683 : ((int)b == Dynamic) ? (int)a \
684 : ((int)a <= (int)b) ? (int)a : (int)b)
685
686// see EIGEN_SIZE_MIN_PREFER_DYNAMIC. No need for a separate variant for MaxSizes here.
687#define EIGEN_SIZE_MAX(a,b) (((int)a == Dynamic || (int)b == Dynamic) ? Dynamic \
688 : ((int)a >= (int)b) ? (int)a : (int)b)
689
690#define EIGEN_ADD_COST(a,b) int(a)==Dynamic || int(b)==Dynamic ? Dynamic : int(a)+int(b)
691
692#define EIGEN_LOGICAL_XOR(a,b) (((a) || (b)) && !((a) && (b)))
693
694#define EIGEN_IMPLIES(a,b) (!(a) || (b))
695
696#define EIGEN_MAKE_CWISE_BINARY_OP(METHOD,FUNCTOR) \
697 template<typename OtherDerived> \
698 EIGEN_STRONG_INLINE const CwiseBinaryOp<FUNCTOR<Scalar>, const Derived, const OtherDerived> \
699 (METHOD)(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const \
700 { \
701 return CwiseBinaryOp<FUNCTOR<Scalar>, const Derived, const OtherDerived>(derived(), other.derived()); \
702 }
703
704// the expression type of a cwise product
705#define EIGEN_CWISE_PRODUCT_RETURN_TYPE(LHS,RHS) \
706 CwiseBinaryOp< \
707 internal::scalar_product_op< \
708 typename internal::traits<LHS>::Scalar, \
709 typename internal::traits<RHS>::Scalar \
710 >, \
711 const LHS, \
712 const RHS \
713 >
714
715#endif // EIGEN_MACROS_H
Definition LDLT.h:18