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 3 16 #define EIGEN_MINOR_VERSION 9 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 24 /// \internal EIGEN_COMP_GNUC set to 1 for all compilers compatible with GCC 25 #ifdef __GNUC__ 26 #define EIGEN_COMP_GNUC 1 27 #else 28 #define EIGEN_COMP_GNUC 0 29 #endif 30 31 /// \internal EIGEN_COMP_CLANG set to major+minor version (e.g., 307 for clang 3.7) if the compiler is clang 32 #if defined(__clang__) 33 #define EIGEN_COMP_CLANG (__clang_major__*100+__clang_minor__) 34 #else 35 #define EIGEN_COMP_CLANG 0 36 #endif 37 38 39 /// \internal EIGEN_COMP_LLVM set to 1 if the compiler backend is llvm 40 #if defined(__llvm__) 41 #define EIGEN_COMP_LLVM 1 42 #else 43 #define EIGEN_COMP_LLVM 0 44 #endif 45 46 /// \internal EIGEN_COMP_ICC set to __INTEL_COMPILER if the compiler is Intel compiler, 0 otherwise 47 #if defined(__INTEL_COMPILER) 48 #define EIGEN_COMP_ICC __INTEL_COMPILER 49 #else 50 #define EIGEN_COMP_ICC 0 51 #endif 52 53 /// \internal EIGEN_COMP_MINGW set to 1 if the compiler is mingw 54 #if defined(__MINGW32__) 55 #define EIGEN_COMP_MINGW 1 56 #else 57 #define EIGEN_COMP_MINGW 0 58 #endif 59 60 /// \internal EIGEN_COMP_SUNCC set to 1 if the compiler is Solaris Studio 61 #if defined(__SUNPRO_CC) 62 #define EIGEN_COMP_SUNCC 1 63 #else 64 #define EIGEN_COMP_SUNCC 0 65 #endif 66 67 /// \internal EIGEN_COMP_MSVC set to _MSC_VER if the compiler is Microsoft Visual C++, 0 otherwise. 68 #if defined(_MSC_VER) 69 #define EIGEN_COMP_MSVC _MSC_VER 70 #else 71 #define EIGEN_COMP_MSVC 0 72 #endif 73 74 // For the record, here is a table summarizing the possible values for EIGEN_COMP_MSVC: 75 // name ver MSC_VER 76 // 2008 9 1500 77 // 2010 10 1600 78 // 2012 11 1700 79 // 2013 12 1800 80 // 2015 14 1900 81 // "15" 15 1900 82 83 /// \internal EIGEN_COMP_MSVC_STRICT set to 1 if the compiler is really Microsoft Visual C++ and not ,e.g., ICC or clang-cl 84 #if EIGEN_COMP_MSVC && !(EIGEN_COMP_ICC || EIGEN_COMP_LLVM || EIGEN_COMP_CLANG) 85 #define EIGEN_COMP_MSVC_STRICT _MSC_VER 86 #else 87 #define EIGEN_COMP_MSVC_STRICT 0 88 #endif 89 90 /// \internal EIGEN_COMP_IBM set to 1 if the compiler is IBM XL C++ 91 #if defined(__IBMCPP__) || defined(__xlc__) 92 #define EIGEN_COMP_IBM 1 93 #else 94 #define EIGEN_COMP_IBM 0 95 #endif 96 97 /// \internal EIGEN_COMP_PGI set to 1 if the compiler is Portland Group Compiler 98 #if defined(__PGI) 99 #define EIGEN_COMP_PGI 1 100 #else 101 #define EIGEN_COMP_PGI 0 102 #endif 103 104 /// \internal EIGEN_COMP_ARM set to 1 if the compiler is ARM Compiler 105 #if defined(__CC_ARM) || defined(__ARMCC_VERSION) 106 #define EIGEN_COMP_ARM 1 107 #else 108 #define EIGEN_COMP_ARM 0 109 #endif 110 111 /// \internal EIGEN_COMP_ARM set to 1 if the compiler is ARM Compiler 112 #if defined(__EMSCRIPTEN__) 113 #define EIGEN_COMP_EMSCRIPTEN 1 114 #else 115 #define EIGEN_COMP_EMSCRIPTEN 0 116 #endif 117 118 119 /// \internal EIGEN_GNUC_STRICT set to 1 if the compiler is really GCC and not a compatible compiler (e.g., ICC, clang, mingw, etc.) 120 #if EIGEN_COMP_GNUC && !(EIGEN_COMP_CLANG || EIGEN_COMP_ICC || EIGEN_COMP_MINGW || EIGEN_COMP_PGI || EIGEN_COMP_IBM || EIGEN_COMP_ARM || EIGEN_COMP_EMSCRIPTEN) 121 #define EIGEN_COMP_GNUC_STRICT 1 122 #else 123 #define EIGEN_COMP_GNUC_STRICT 0 124 #endif 125 126 127 #if EIGEN_COMP_GNUC 128 #define EIGEN_GNUC_AT_LEAST(x,y) ((__GNUC__==x && __GNUC_MINOR__>=y) || __GNUC__>x) 129 #define EIGEN_GNUC_AT_MOST(x,y) ((__GNUC__==x && __GNUC_MINOR__<=y) || __GNUC__<x) 130 #define EIGEN_GNUC_AT(x,y) ( __GNUC__==x && __GNUC_MINOR__==y ) 131 #else 132 #define EIGEN_GNUC_AT_LEAST(x,y) 0 133 #define EIGEN_GNUC_AT_MOST(x,y) 0 134 #define EIGEN_GNUC_AT(x,y) 0 135 #endif 136 137 // FIXME: could probably be removed as we do not support gcc 3.x anymore 138 #if EIGEN_COMP_GNUC && (__GNUC__ <= 3) 139 #define EIGEN_GCC3_OR_OLDER 1 140 #else 141 #define EIGEN_GCC3_OR_OLDER 0 142 #endif 143 144 145 // Architecture identification, EIGEN_ARCH_* 146 147 #if defined(__x86_64__) || defined(_M_X64) || defined(__amd64) 148 #define EIGEN_ARCH_x86_64 1 149 #else 150 #define EIGEN_ARCH_x86_64 0 151 #endif 152 153 #if defined(__i386__) || defined(_M_IX86) || defined(_X86_) || defined(__i386) 154 #define EIGEN_ARCH_i386 1 155 #else 156 #define EIGEN_ARCH_i386 0 157 #endif 158 159 #if EIGEN_ARCH_x86_64 || EIGEN_ARCH_i386 160 #define EIGEN_ARCH_i386_OR_x86_64 1 161 #else 162 #define EIGEN_ARCH_i386_OR_x86_64 0 163 #endif 164 165 /// \internal EIGEN_ARCH_ARM set to 1 if the architecture is ARM 166 #if defined(__arm__) 167 #define EIGEN_ARCH_ARM 1 168 #else 169 #define EIGEN_ARCH_ARM 0 170 #endif 171 172 /// \internal EIGEN_ARCH_ARM64 set to 1 if the architecture is ARM64 173 #if defined(__aarch64__) 174 #define EIGEN_ARCH_ARM64 1 175 #else 176 #define EIGEN_ARCH_ARM64 0 177 #endif 178 179 #if EIGEN_ARCH_ARM || EIGEN_ARCH_ARM64 180 #define EIGEN_ARCH_ARM_OR_ARM64 1 181 #else 182 #define EIGEN_ARCH_ARM_OR_ARM64 0 183 #endif 184 185 /// \internal EIGEN_ARCH_MIPS set to 1 if the architecture is MIPS 186 #if defined(__mips__) || defined(__mips) 187 #define EIGEN_ARCH_MIPS 1 188 #else 189 #define EIGEN_ARCH_MIPS 0 190 #endif 191 192 /// \internal EIGEN_ARCH_SPARC set to 1 if the architecture is SPARC 193 #if defined(__sparc__) || defined(__sparc) 194 #define EIGEN_ARCH_SPARC 1 195 #else 196 #define EIGEN_ARCH_SPARC 0 197 #endif 198 199 /// \internal EIGEN_ARCH_IA64 set to 1 if the architecture is Intel Itanium 200 #if defined(__ia64__) 201 #define EIGEN_ARCH_IA64 1 202 #else 203 #define EIGEN_ARCH_IA64 0 204 #endif 205 206 /// \internal EIGEN_ARCH_PPC set to 1 if the architecture is PowerPC 207 #if defined(__powerpc__) || defined(__ppc__) || defined(_M_PPC) 208 #define EIGEN_ARCH_PPC 1 209 #else 210 #define EIGEN_ARCH_PPC 0 211 #endif 212 213 214 215 // Operating system identification, EIGEN_OS_* 216 217 /// \internal EIGEN_OS_UNIX set to 1 if the OS is a unix variant 218 #if defined(__unix__) || defined(__unix) 219 #define EIGEN_OS_UNIX 1 220 #else 221 #define EIGEN_OS_UNIX 0 222 #endif 223 224 /// \internal EIGEN_OS_LINUX set to 1 if the OS is based on Linux kernel 225 #if defined(__linux__) 226 #define EIGEN_OS_LINUX 1 227 #else 228 #define EIGEN_OS_LINUX 0 229 #endif 230 231 /// \internal EIGEN_OS_ANDROID set to 1 if the OS is Android 232 // note: ANDROID is defined when using ndk_build, __ANDROID__ is defined when using a standalone toolchain. 233 #if defined(__ANDROID__) || defined(ANDROID) 234 #define EIGEN_OS_ANDROID 1 235 #else 236 #define EIGEN_OS_ANDROID 0 237 #endif 238 239 /// \internal EIGEN_OS_GNULINUX set to 1 if the OS is GNU Linux and not Linux-based OS (e.g., not android) 240 #if defined(__gnu_linux__) && !(EIGEN_OS_ANDROID) 241 #define EIGEN_OS_GNULINUX 1 242 #else 243 #define EIGEN_OS_GNULINUX 0 244 #endif 245 246 /// \internal EIGEN_OS_BSD set to 1 if the OS is a BSD variant 247 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) 248 #define EIGEN_OS_BSD 1 249 #else 250 #define EIGEN_OS_BSD 0 251 #endif 252 253 /// \internal EIGEN_OS_MAC set to 1 if the OS is MacOS 254 #if defined(__APPLE__) 255 #define EIGEN_OS_MAC 1 256 #else 257 #define EIGEN_OS_MAC 0 258 #endif 259 260 /// \internal EIGEN_OS_QNX set to 1 if the OS is QNX 261 #if defined(__QNX__) 262 #define EIGEN_OS_QNX 1 263 #else 264 #define EIGEN_OS_QNX 0 265 #endif 266 267 /// \internal EIGEN_OS_WIN set to 1 if the OS is Windows based 268 #if defined(_WIN32) 269 #define EIGEN_OS_WIN 1 270 #else 271 #define EIGEN_OS_WIN 0 272 #endif 273 274 /// \internal EIGEN_OS_WIN64 set to 1 if the OS is Windows 64bits 275 #if defined(_WIN64) 276 #define EIGEN_OS_WIN64 1 277 #else 278 #define EIGEN_OS_WIN64 0 279 #endif 280 281 /// \internal EIGEN_OS_WINCE set to 1 if the OS is Windows CE 282 #if defined(_WIN32_WCE) 283 #define EIGEN_OS_WINCE 1 284 #else 285 #define EIGEN_OS_WINCE 0 286 #endif 287 288 /// \internal EIGEN_OS_CYGWIN set to 1 if the OS is Windows/Cygwin 289 #if defined(__CYGWIN__) 290 #define EIGEN_OS_CYGWIN 1 291 #else 292 #define EIGEN_OS_CYGWIN 0 293 #endif 294 295 /// \internal EIGEN_OS_WIN_STRICT set to 1 if the OS is really Windows and not some variants 296 #if EIGEN_OS_WIN && !( EIGEN_OS_WINCE || EIGEN_OS_CYGWIN ) 297 #define EIGEN_OS_WIN_STRICT 1 298 #else 299 #define EIGEN_OS_WIN_STRICT 0 300 #endif 301 302 /// \internal EIGEN_OS_SUN set to 1 if the OS is SUN 303 #if (defined(sun) || defined(__sun)) && !(defined(__SVR4) || defined(__svr4__)) 304 #define EIGEN_OS_SUN 1 305 #else 306 #define EIGEN_OS_SUN 0 307 #endif 308 309 /// \internal EIGEN_OS_SOLARIS set to 1 if the OS is Solaris 310 #if (defined(sun) || defined(__sun)) && (defined(__SVR4) || defined(__svr4__)) 311 #define EIGEN_OS_SOLARIS 1 312 #else 313 #define EIGEN_OS_SOLARIS 0 314 #endif 315 316 317 318 #if EIGEN_GNUC_AT_MOST(4,3) && !EIGEN_COMP_CLANG 319 // see bug 89 320 #define EIGEN_SAFE_TO_USE_STANDARD_ASSERT_MACRO 0 321 #else 322 #define EIGEN_SAFE_TO_USE_STANDARD_ASSERT_MACRO 1 323 #endif 324 325 // This macro can be used to prevent from macro expansion, e.g.: 326 // std::max EIGEN_NOT_A_MACRO(a,b) 327 #define EIGEN_NOT_A_MACRO 328 329 #ifdef EIGEN_DEFAULT_TO_ROW_MAJOR 330 #define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION Eigen::RowMajor 331 #else 332 #define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION Eigen::ColMajor 333 #endif 334 335 #ifndef EIGEN_DEFAULT_DENSE_INDEX_TYPE 336 #define EIGEN_DEFAULT_DENSE_INDEX_TYPE std::ptrdiff_t 337 #endif 338 339 // Cross compiler wrapper around LLVM's __has_builtin 340 #ifdef __has_builtin 341 # define EIGEN_HAS_BUILTIN(x) __has_builtin(x) 342 #else 343 # define EIGEN_HAS_BUILTIN(x) 0 344 #endif 345 346 // A Clang feature extension to determine compiler features. 347 // We use it to determine 'cxx_rvalue_references' 348 #ifndef __has_feature 349 # define __has_feature(x) 0 350 #endif 351 352 // Upperbound on the C++ version to use. 353 // Expected values are 03, 11, 14, 17, etc. 354 // By default, let's use an arbitrarily large C++ version. 355 #ifndef EIGEN_MAX_CPP_VER 356 #define EIGEN_MAX_CPP_VER 99 357 #endif 358 359 #if EIGEN_MAX_CPP_VER>=11 && (defined(__cplusplus) && (__cplusplus >= 201103L) || EIGEN_COMP_MSVC >= 1900) 360 #define EIGEN_HAS_CXX11 1 361 #else 362 #define EIGEN_HAS_CXX11 0 363 #endif 364 365 366 // Do we support r-value references? 367 #ifndef EIGEN_HAS_RVALUE_REFERENCES 368 #if EIGEN_MAX_CPP_VER>=11 && \ 369 (__has_feature(cxx_rvalue_references) || \ 370 (defined(__cplusplus) && __cplusplus >= 201103L) || \ 371 (EIGEN_COMP_MSVC >= 1600)) 372 #define EIGEN_HAS_RVALUE_REFERENCES 1 373 #else 374 #define EIGEN_HAS_RVALUE_REFERENCES 0 375 #endif 376 #endif 377 378 // Does the compiler support C99? 379 #ifndef EIGEN_HAS_C99_MATH 380 #if EIGEN_MAX_CPP_VER>=11 && \ 381 ((defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)) \ 382 || (defined(__GNUC__) && defined(_GLIBCXX_USE_C99)) \ 383 || (defined(_LIBCPP_VERSION) && !defined(_MSC_VER)) \ 384 || (EIGEN_COMP_MSVC >= 1900) ) 385 #define EIGEN_HAS_C99_MATH 1 386 #else 387 #define EIGEN_HAS_C99_MATH 0 388 #endif 389 #endif 390 391 // Does the compiler support result_of? 392 #ifndef EIGEN_HAS_STD_RESULT_OF 393 #if EIGEN_MAX_CPP_VER>=11 && ((__has_feature(cxx_lambdas) || (defined(__cplusplus) && __cplusplus >= 201103L))) 394 #define EIGEN_HAS_STD_RESULT_OF 1 395 #else 396 #define EIGEN_HAS_STD_RESULT_OF 0 397 #endif 398 #endif 399 400 // Does the compiler support type_traits? 401 // - full support of type traits was added only to GCC 5.1.0. 402 // - 20150626 corresponds to the last release of 4.x libstdc++ 403 #ifndef EIGEN_HAS_TYPE_TRAITS 404 #if EIGEN_MAX_CPP_VER>=11 && (EIGEN_HAS_CXX11 || EIGEN_COMP_MSVC >= 1700) \ 405 && ((!EIGEN_COMP_GNUC_STRICT) || EIGEN_GNUC_AT_LEAST(5, 1)) \ 406 && ((!defined(__GLIBCXX__)) || __GLIBCXX__ > 20150626) 407 #define EIGEN_HAS_TYPE_TRAITS 1 408 #define EIGEN_INCLUDE_TYPE_TRAITS 409 #else 410 #define EIGEN_HAS_TYPE_TRAITS 0 411 #endif 412 #endif 413 414 // Does the compiler support variadic templates? 415 #ifndef EIGEN_HAS_VARIADIC_TEMPLATES 416 #if EIGEN_MAX_CPP_VER>=11 && (__cplusplus > 199711L || EIGEN_COMP_MSVC >= 1900) \ 417 && (!defined(__NVCC__) || !EIGEN_ARCH_ARM_OR_ARM64 || (EIGEN_CUDACC_VER >= 80000) ) 418 // ^^ Disable the use of variadic templates when compiling with versions of nvcc older than 8.0 on ARM devices: 419 // this prevents nvcc from crashing when compiling Eigen on Tegra X1 420 #define EIGEN_HAS_VARIADIC_TEMPLATES 1 421 #else 422 #define EIGEN_HAS_VARIADIC_TEMPLATES 0 423 #endif 424 #endif 425 426 // Does the compiler fully support const expressions? (as in c++14) 427 #ifndef EIGEN_HAS_CONSTEXPR 428 429 #ifdef __CUDACC__ 430 // Const expressions are supported provided that c++11 is enabled and we're using either clang or nvcc 7.5 or above 431 #if EIGEN_MAX_CPP_VER>=14 && (__cplusplus > 199711L && (EIGEN_COMP_CLANG || EIGEN_CUDACC_VER >= 70500)) 432 #define EIGEN_HAS_CONSTEXPR 1 433 #endif 434 #elif EIGEN_MAX_CPP_VER>=14 && (__has_feature(cxx_relaxed_constexpr) || (defined(__cplusplus) && __cplusplus >= 201402L) || \ 435 (EIGEN_GNUC_AT_LEAST(4,8) && (__cplusplus > 199711L))) 436 #define EIGEN_HAS_CONSTEXPR 1 437 #endif 438 439 #ifndef EIGEN_HAS_CONSTEXPR 440 #define EIGEN_HAS_CONSTEXPR 0 441 #endif 442 443 #endif 444 445 // Does the compiler support C++11 math? 446 // Let's be conservative and enable the default C++11 implementation only if we are sure it exists 447 #ifndef EIGEN_HAS_CXX11_MATH 448 #if EIGEN_MAX_CPP_VER>=11 && ((__cplusplus > 201103L) || (__cplusplus >= 201103L) && (EIGEN_COMP_GNUC_STRICT || EIGEN_COMP_CLANG || EIGEN_COMP_MSVC || EIGEN_COMP_ICC) \ 449 && (EIGEN_ARCH_i386_OR_x86_64) && (EIGEN_OS_GNULINUX || EIGEN_OS_WIN_STRICT || EIGEN_OS_MAC)) 450 #define EIGEN_HAS_CXX11_MATH 1 451 #else 452 #define EIGEN_HAS_CXX11_MATH 0 453 #endif 454 #endif 455 456 // Does the compiler support proper C++11 containers? 457 #ifndef EIGEN_HAS_CXX11_CONTAINERS 458 #if EIGEN_MAX_CPP_VER>=11 && \ 459 ((__cplusplus > 201103L) \ 460 || ((__cplusplus >= 201103L) && (EIGEN_COMP_GNUC_STRICT || EIGEN_COMP_CLANG || EIGEN_COMP_ICC>=1400)) \ 461 || EIGEN_COMP_MSVC >= 1900) 462 #define EIGEN_HAS_CXX11_CONTAINERS 1 463 #else 464 #define EIGEN_HAS_CXX11_CONTAINERS 0 465 #endif 466 #endif 467 468 // Does the compiler support C++11 noexcept? 469 #ifndef EIGEN_HAS_CXX11_NOEXCEPT 470 #if EIGEN_MAX_CPP_VER>=11 && \ 471 (__has_feature(cxx_noexcept) \ 472 || (__cplusplus > 201103L) \ 473 || ((__cplusplus >= 201103L) && (EIGEN_COMP_GNUC_STRICT || EIGEN_COMP_CLANG || EIGEN_COMP_ICC>=1400)) \ 474 || EIGEN_COMP_MSVC >= 1900) 475 #define EIGEN_HAS_CXX11_NOEXCEPT 1 476 #else 477 #define EIGEN_HAS_CXX11_NOEXCEPT 0 478 #endif 479 #endif 480 481 /** Allows to disable some optimizations which might affect the accuracy of the result. 482 * Such optimization are enabled by default, and set EIGEN_FAST_MATH to 0 to disable them. 483 * They currently include: 484 * - single precision ArrayBase::sin() and ArrayBase::cos() for SSE and AVX vectorization. 485 */ 486 #ifndef EIGEN_FAST_MATH 487 #define EIGEN_FAST_MATH 1 488 #endif 489 490 #define EIGEN_DEBUG_VAR(x) std::cerr << #x << " = " << x << std::endl; 491 492 // concatenate two tokens 493 #define EIGEN_CAT2(a,b) a ## b 494 #define EIGEN_CAT(a,b) EIGEN_CAT2(a,b) 495 496 #define EIGEN_COMMA , 497 498 // convert a token to a string 499 #define EIGEN_MAKESTRING2(a) #a 500 #define EIGEN_MAKESTRING(a) EIGEN_MAKESTRING2(a) 501 502 // EIGEN_STRONG_INLINE is a stronger version of the inline, using __forceinline on MSVC, 503 // but it still doesn't use GCC's always_inline. This is useful in (common) situations where MSVC needs forceinline 504 // but GCC is still doing fine with just inline. 505 #ifndef EIGEN_STRONG_INLINE 506 #if EIGEN_COMP_MSVC || EIGEN_COMP_ICC 507 #define EIGEN_STRONG_INLINE __forceinline 508 #else 509 #define EIGEN_STRONG_INLINE inline 510 #endif 511 #endif 512 513 // EIGEN_ALWAYS_INLINE is the stronget, it has the effect of making the function inline and adding every possible 514 // attribute to maximize inlining. This should only be used when really necessary: in particular, 515 // it uses __attribute__((always_inline)) on GCC, which most of the time is useless and can severely harm compile times. 516 // FIXME with the always_inline attribute, 517 // gcc 3.4.x and 4.1 reports the following compilation error: 518 // Eval.h:91: sorry, unimplemented: inlining failed in call to 'const Eigen::Eval<Derived> Eigen::MatrixBase<Scalar, Derived>::eval() const' 519 // : function body not available 520 // See also bug 1367 521 #if EIGEN_GNUC_AT_LEAST(4,2) 522 #define EIGEN_ALWAYS_INLINE __attribute__((always_inline)) inline 523 #else 524 #define EIGEN_ALWAYS_INLINE EIGEN_STRONG_INLINE 525 #endif 526 527 #if EIGEN_COMP_GNUC 528 #define EIGEN_DONT_INLINE __attribute__((noinline)) 529 #elif EIGEN_COMP_MSVC 530 #define EIGEN_DONT_INLINE __declspec(noinline) 531 #else 532 #define EIGEN_DONT_INLINE 533 #endif 534 535 #if EIGEN_COMP_GNUC 536 #define EIGEN_PERMISSIVE_EXPR __extension__ 537 #else 538 #define EIGEN_PERMISSIVE_EXPR 539 #endif 540 541 // this macro allows to get rid of linking errors about multiply defined functions. 542 // - static is not very good because it prevents definitions from different object files to be merged. 543 // So static causes the resulting linked executable to be bloated with multiple copies of the same function. 544 // - inline is not perfect either as it unwantedly hints the compiler toward inlining the function. 545 #define EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS 546 #define EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS inline 547 548 #ifdef NDEBUG 549 # ifndef EIGEN_NO_DEBUG 550 # define EIGEN_NO_DEBUG 551 # endif 552 #endif 553 554 // eigen_plain_assert is where we implement the workaround for the assert() bug in GCC <= 4.3, see bug 89 555 #ifdef EIGEN_NO_DEBUG 556 #define eigen_plain_assert(x) 557 #else 558 #if EIGEN_SAFE_TO_USE_STANDARD_ASSERT_MACRO 559 namespace Eigen { 560 namespace internal { copy_bool(bool b)561 inline bool copy_bool(bool b) { return b; } 562 } 563 } 564 #define eigen_plain_assert(x) assert(x) 565 #else 566 // work around bug 89 567 #include <cstdlib> // for abort 568 #include <iostream> // for std::cerr 569 570 namespace Eigen { 571 namespace internal { 572 // trivial function copying a bool. Must be EIGEN_DONT_INLINE, so we implement it after including Eigen headers. 573 // see bug 89. 574 namespace { copy_bool(bool b)575 EIGEN_DONT_INLINE bool copy_bool(bool b) { return b; } 576 } assert_fail(const char * condition,const char * function,const char * file,int line)577 inline void assert_fail(const char *condition, const char *function, const char *file, int line) 578 { 579 std::cerr << "assertion failed: " << condition << " in function " << function << " at " << file << ":" << line << std::endl; 580 abort(); 581 } 582 } 583 } 584 #define eigen_plain_assert(x) \ 585 do { \ 586 if(!Eigen::internal::copy_bool(x)) \ 587 Eigen::internal::assert_fail(EIGEN_MAKESTRING(x), __PRETTY_FUNCTION__, __FILE__, __LINE__); \ 588 } while(false) 589 #endif 590 #endif 591 592 // eigen_assert can be overridden 593 #ifndef eigen_assert 594 #define eigen_assert(x) eigen_plain_assert(x) 595 #endif 596 597 #ifdef EIGEN_INTERNAL_DEBUGGING 598 #define eigen_internal_assert(x) eigen_assert(x) 599 #else 600 #define eigen_internal_assert(x) 601 #endif 602 603 #ifdef EIGEN_NO_DEBUG 604 #define EIGEN_ONLY_USED_FOR_DEBUG(x) EIGEN_UNUSED_VARIABLE(x) 605 #else 606 #define EIGEN_ONLY_USED_FOR_DEBUG(x) 607 #endif 608 609 #ifndef EIGEN_NO_DEPRECATED_WARNING 610 #if EIGEN_COMP_GNUC 611 #define EIGEN_DEPRECATED __attribute__((deprecated)) 612 #elif EIGEN_COMP_MSVC 613 #define EIGEN_DEPRECATED __declspec(deprecated) 614 #else 615 #define EIGEN_DEPRECATED 616 #endif 617 #else 618 #define EIGEN_DEPRECATED 619 #endif 620 621 #if EIGEN_COMP_GNUC 622 #define EIGEN_UNUSED __attribute__((unused)) 623 #else 624 #define EIGEN_UNUSED 625 #endif 626 627 // Suppresses 'unused variable' warnings. 628 namespace Eigen { 629 namespace internal { ignore_unused_variable(const T &)630 template<typename T> EIGEN_DEVICE_FUNC void ignore_unused_variable(const T&) {} 631 } 632 } 633 #define EIGEN_UNUSED_VARIABLE(var) Eigen::internal::ignore_unused_variable(var); 634 635 #if !defined(EIGEN_ASM_COMMENT) 636 #if EIGEN_COMP_GNUC && (EIGEN_ARCH_i386_OR_x86_64 || EIGEN_ARCH_ARM_OR_ARM64) 637 #define EIGEN_ASM_COMMENT(X) __asm__("#" X) 638 #else 639 #define EIGEN_ASM_COMMENT(X) 640 #endif 641 #endif 642 643 644 //------------------------------------------------------------------------------------------ 645 // Static and dynamic alignment control 646 // 647 // The main purpose of this section is to define EIGEN_MAX_ALIGN_BYTES and EIGEN_MAX_STATIC_ALIGN_BYTES 648 // as the maximal boundary in bytes on which dynamically and statically allocated data may be alignment respectively. 649 // The values of EIGEN_MAX_ALIGN_BYTES and EIGEN_MAX_STATIC_ALIGN_BYTES can be specified by the user. If not, 650 // a default value is automatically computed based on architecture, compiler, and OS. 651 // 652 // This section also defines macros EIGEN_ALIGN_TO_BOUNDARY(N) and the shortcuts EIGEN_ALIGN{8,16,32,_MAX} 653 // to be used to declare statically aligned buffers. 654 //------------------------------------------------------------------------------------------ 655 656 657 /* EIGEN_ALIGN_TO_BOUNDARY(n) forces data to be n-byte aligned. This is used to satisfy SIMD requirements. 658 * However, we do that EVEN if vectorization (EIGEN_VECTORIZE) is disabled, 659 * so that vectorization doesn't affect binary compatibility. 660 * 661 * If we made alignment depend on whether or not EIGEN_VECTORIZE is defined, it would be impossible to link 662 * vectorized and non-vectorized code. 663 */ 664 #if (defined __CUDACC__) 665 #define EIGEN_ALIGN_TO_BOUNDARY(n) __align__(n) 666 #elif EIGEN_COMP_GNUC || EIGEN_COMP_PGI || EIGEN_COMP_IBM || EIGEN_COMP_ARM 667 #define EIGEN_ALIGN_TO_BOUNDARY(n) __attribute__((aligned(n))) 668 #elif EIGEN_COMP_MSVC 669 #define EIGEN_ALIGN_TO_BOUNDARY(n) __declspec(align(n)) 670 #elif EIGEN_COMP_SUNCC 671 // FIXME not sure about this one: 672 #define EIGEN_ALIGN_TO_BOUNDARY(n) __attribute__((aligned(n))) 673 #else 674 #error Please tell me what is the equivalent of __attribute__((aligned(n))) for your compiler 675 #endif 676 677 // If the user explicitly disable vectorization, then we also disable alignment 678 #if defined(EIGEN_DONT_VECTORIZE) 679 #define EIGEN_IDEAL_MAX_ALIGN_BYTES 0 680 #elif defined(EIGEN_VECTORIZE_AVX512) 681 // 64 bytes static alignmeent is preferred only if really required 682 #define EIGEN_IDEAL_MAX_ALIGN_BYTES 64 683 #elif defined(__AVX__) 684 // 32 bytes static alignmeent is preferred only if really required 685 #define EIGEN_IDEAL_MAX_ALIGN_BYTES 32 686 #else 687 #define EIGEN_IDEAL_MAX_ALIGN_BYTES 16 688 #endif 689 690 691 // EIGEN_MIN_ALIGN_BYTES defines the minimal value for which the notion of explicit alignment makes sense 692 #define EIGEN_MIN_ALIGN_BYTES 16 693 694 // Defined the boundary (in bytes) on which the data needs to be aligned. Note 695 // that unless EIGEN_ALIGN is defined and not equal to 0, the data may not be 696 // aligned at all regardless of the value of this #define. 697 698 #if (defined(EIGEN_DONT_ALIGN_STATICALLY) || defined(EIGEN_DONT_ALIGN)) && defined(EIGEN_MAX_STATIC_ALIGN_BYTES) && EIGEN_MAX_STATIC_ALIGN_BYTES>0 699 #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. 700 #endif 701 702 // EIGEN_DONT_ALIGN_STATICALLY and EIGEN_DONT_ALIGN are deprectated 703 // They imply EIGEN_MAX_STATIC_ALIGN_BYTES=0 704 #if defined(EIGEN_DONT_ALIGN_STATICALLY) || defined(EIGEN_DONT_ALIGN) 705 #ifdef EIGEN_MAX_STATIC_ALIGN_BYTES 706 #undef EIGEN_MAX_STATIC_ALIGN_BYTES 707 #endif 708 #define EIGEN_MAX_STATIC_ALIGN_BYTES 0 709 #endif 710 711 #ifndef EIGEN_MAX_STATIC_ALIGN_BYTES 712 713 // Try to automatically guess what is the best default value for EIGEN_MAX_STATIC_ALIGN_BYTES 714 715 // 16 byte alignment is only useful for vectorization. Since it affects the ABI, we need to enable 716 // 16 byte alignment on all platforms where vectorization might be enabled. In theory we could always 717 // enable alignment, but it can be a cause of problems on some platforms, so we just disable it in 718 // certain common platform (compiler+architecture combinations) to avoid these problems. 719 // Only static alignment is really problematic (relies on nonstandard compiler extensions), 720 // try to keep heap alignment even when we have to disable static alignment. 721 #if EIGEN_COMP_GNUC && !(EIGEN_ARCH_i386_OR_x86_64 || EIGEN_ARCH_ARM_OR_ARM64 || EIGEN_ARCH_PPC || EIGEN_ARCH_IA64) 722 #define EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT 1 723 #elif EIGEN_ARCH_ARM_OR_ARM64 && EIGEN_COMP_GNUC_STRICT && EIGEN_GNUC_AT_MOST(4, 6) 724 // Old versions of GCC on ARM, at least 4.4, were once seen to have buggy static alignment support. 725 // Not sure which version fixed it, hopefully it doesn't affect 4.7, which is still somewhat in use. 726 // 4.8 and newer seem definitely unaffected. 727 #define EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT 1 728 #else 729 #define EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT 0 730 #endif 731 732 // static alignment is completely disabled with GCC 3, Sun Studio, and QCC/QNX 733 #if !EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT \ 734 && !EIGEN_GCC3_OR_OLDER \ 735 && !EIGEN_COMP_SUNCC \ 736 && !EIGEN_OS_QNX 737 #define EIGEN_ARCH_WANTS_STACK_ALIGNMENT 1 738 #else 739 #define EIGEN_ARCH_WANTS_STACK_ALIGNMENT 0 740 #endif 741 742 #if EIGEN_ARCH_WANTS_STACK_ALIGNMENT 743 #define EIGEN_MAX_STATIC_ALIGN_BYTES EIGEN_IDEAL_MAX_ALIGN_BYTES 744 #else 745 #define EIGEN_MAX_STATIC_ALIGN_BYTES 0 746 #endif 747 748 #endif 749 750 // If EIGEN_MAX_ALIGN_BYTES is defined, then it is considered as an upper bound for EIGEN_MAX_ALIGN_BYTES 751 #if defined(EIGEN_MAX_ALIGN_BYTES) && EIGEN_MAX_ALIGN_BYTES<EIGEN_MAX_STATIC_ALIGN_BYTES 752 #undef EIGEN_MAX_STATIC_ALIGN_BYTES 753 #define EIGEN_MAX_STATIC_ALIGN_BYTES EIGEN_MAX_ALIGN_BYTES 754 #endif 755 756 #if EIGEN_MAX_STATIC_ALIGN_BYTES==0 && !defined(EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT) 757 #define EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT 758 #endif 759 760 // At this stage, EIGEN_MAX_STATIC_ALIGN_BYTES>0 is the true test whether we want to align arrays on the stack or not. 761 // It takes into account both the user choice to explicitly enable/disable alignment (by settting EIGEN_MAX_STATIC_ALIGN_BYTES) 762 // and the architecture config (EIGEN_ARCH_WANTS_STACK_ALIGNMENT). 763 // Henceforth, only EIGEN_MAX_STATIC_ALIGN_BYTES should be used. 764 765 766 // Shortcuts to EIGEN_ALIGN_TO_BOUNDARY 767 #define EIGEN_ALIGN8 EIGEN_ALIGN_TO_BOUNDARY(8) 768 #define EIGEN_ALIGN16 EIGEN_ALIGN_TO_BOUNDARY(16) 769 #define EIGEN_ALIGN32 EIGEN_ALIGN_TO_BOUNDARY(32) 770 #define EIGEN_ALIGN64 EIGEN_ALIGN_TO_BOUNDARY(64) 771 #if EIGEN_MAX_STATIC_ALIGN_BYTES>0 772 #define EIGEN_ALIGN_MAX EIGEN_ALIGN_TO_BOUNDARY(EIGEN_MAX_STATIC_ALIGN_BYTES) 773 #else 774 #define EIGEN_ALIGN_MAX 775 #endif 776 777 778 // Dynamic alignment control 779 780 #if defined(EIGEN_DONT_ALIGN) && defined(EIGEN_MAX_ALIGN_BYTES) && EIGEN_MAX_ALIGN_BYTES>0 781 #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. 782 #endif 783 784 #ifdef EIGEN_DONT_ALIGN 785 #ifdef EIGEN_MAX_ALIGN_BYTES 786 #undef EIGEN_MAX_ALIGN_BYTES 787 #endif 788 #define EIGEN_MAX_ALIGN_BYTES 0 789 #elif !defined(EIGEN_MAX_ALIGN_BYTES) 790 #define EIGEN_MAX_ALIGN_BYTES EIGEN_IDEAL_MAX_ALIGN_BYTES 791 #endif 792 793 #if EIGEN_IDEAL_MAX_ALIGN_BYTES > EIGEN_MAX_ALIGN_BYTES 794 #define EIGEN_DEFAULT_ALIGN_BYTES EIGEN_IDEAL_MAX_ALIGN_BYTES 795 #else 796 #define EIGEN_DEFAULT_ALIGN_BYTES EIGEN_MAX_ALIGN_BYTES 797 #endif 798 799 800 #ifndef EIGEN_UNALIGNED_VECTORIZE 801 #define EIGEN_UNALIGNED_VECTORIZE 1 802 #endif 803 804 //---------------------------------------------------------------------- 805 806 807 #ifdef EIGEN_DONT_USE_RESTRICT_KEYWORD 808 #define EIGEN_RESTRICT 809 #endif 810 #ifndef EIGEN_RESTRICT 811 #define EIGEN_RESTRICT __restrict 812 #endif 813 814 #ifndef EIGEN_STACK_ALLOCATION_LIMIT 815 // 131072 == 128 KB 816 #define EIGEN_STACK_ALLOCATION_LIMIT 131072 817 #endif 818 819 #ifndef EIGEN_DEFAULT_IO_FORMAT 820 #ifdef EIGEN_MAKING_DOCS 821 // format used in Eigen's documentation 822 // needed to define it here as escaping characters in CMake add_definition's argument seems very problematic. 823 #define EIGEN_DEFAULT_IO_FORMAT Eigen::IOFormat(3, 0, " ", "\n", "", "") 824 #else 825 #define EIGEN_DEFAULT_IO_FORMAT Eigen::IOFormat() 826 #endif 827 #endif 828 829 // just an empty macro ! 830 #define EIGEN_EMPTY 831 832 #if EIGEN_COMP_MSVC_STRICT && (EIGEN_COMP_MSVC < 1900 || EIGEN_CUDACC_VER>0) 833 // for older MSVC versions, as well as 1900 && CUDA 8, using the base operator is sufficient (cf Bugs 1000, 1324) 834 #define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \ 835 using Base::operator =; 836 #elif EIGEN_COMP_CLANG // workaround clang bug (see http://forum.kde.org/viewtopic.php?f=74&t=102653) 837 #define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \ 838 using Base::operator =; \ 839 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const Derived& other) { Base::operator=(other); return *this; } \ 840 template <typename OtherDerived> \ 841 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const DenseBase<OtherDerived>& other) { Base::operator=(other.derived()); return *this; } 842 #else 843 #define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \ 844 using Base::operator =; \ 845 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const Derived& other) \ 846 { \ 847 Base::operator=(other); \ 848 return *this; \ 849 } 850 #endif 851 852 853 /** 854 * \internal 855 * \brief Macro to explicitly define the default copy constructor. 856 * This is necessary, because the implicit definition is deprecated if the copy-assignment is overridden. 857 */ 858 #if EIGEN_HAS_CXX11 859 #define EIGEN_DEFAULT_COPY_CONSTRUCTOR(CLASS) EIGEN_DEVICE_FUNC CLASS(const CLASS&) = default; 860 #else 861 #define EIGEN_DEFAULT_COPY_CONSTRUCTOR(CLASS) 862 #endif 863 864 865 866 /** \internal 867 * \brief Macro to manually inherit assignment operators. 868 * This is necessary, because the implicitly defined assignment operator gets deleted when a custom operator= is defined. 869 * With C++11 or later this also default-implements the copy-constructor 870 */ 871 #define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived) \ 872 EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \ 873 EIGEN_DEFAULT_COPY_CONSTRUCTOR(Derived) 874 875 /** \internal 876 * \brief Macro to manually define default constructors and destructors. 877 * This is necessary when the copy constructor is re-defined. 878 * For empty helper classes this should usually be protected, to avoid accidentally creating empty objects. 879 * 880 * Hiding the default destructor lead to problems in C++03 mode together with boost::multiprecision 881 */ 882 #if EIGEN_HAS_CXX11 883 #define EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(Derived) \ 884 EIGEN_DEVICE_FUNC Derived() = default; \ 885 EIGEN_DEVICE_FUNC ~Derived() = default; 886 #else 887 #define EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(Derived) \ 888 EIGEN_DEVICE_FUNC Derived() {}; \ 889 /* EIGEN_DEVICE_FUNC ~Derived() {}; */ 890 #endif 891 892 893 894 895 896 /** 897 * Just a side note. Commenting within defines works only by documenting 898 * behind the object (via '!<'). Comments cannot be multi-line and thus 899 * we have these extra long lines. What is confusing doxygen over here is 900 * that we use '\' and basically have a bunch of typedefs with their 901 * documentation in a single line. 902 **/ 903 904 #define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived) \ 905 typedef typename Eigen::internal::traits<Derived>::Scalar Scalar; /*!< \brief Numeric type, e.g. float, double, int or std::complex<float>. */ \ 906 typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; /*!< \brief The underlying numeric type for composed scalar types. \details In cases where Scalar is e.g. std::complex<T>, T were corresponding to RealScalar. */ \ 907 typedef typename Base::CoeffReturnType CoeffReturnType; /*!< \brief The return type for coefficient access. \details Depending on whether the object allows direct coefficient access (e.g. for a MatrixXd), this type is either 'const Scalar&' or simply 'Scalar' for objects that do not allow direct coefficient access. */ \ 908 typedef typename Eigen::internal::ref_selector<Derived>::type Nested; \ 909 typedef typename Eigen::internal::traits<Derived>::StorageKind StorageKind; \ 910 typedef typename Eigen::internal::traits<Derived>::StorageIndex StorageIndex; \ 911 enum { RowsAtCompileTime = Eigen::internal::traits<Derived>::RowsAtCompileTime, \ 912 ColsAtCompileTime = Eigen::internal::traits<Derived>::ColsAtCompileTime, \ 913 Flags = Eigen::internal::traits<Derived>::Flags, \ 914 SizeAtCompileTime = Base::SizeAtCompileTime, \ 915 MaxSizeAtCompileTime = Base::MaxSizeAtCompileTime, \ 916 IsVectorAtCompileTime = Base::IsVectorAtCompileTime }; \ 917 using Base::derived; \ 918 using Base::const_cast_derived; 919 920 921 // FIXME Maybe the EIGEN_DENSE_PUBLIC_INTERFACE could be removed as importing PacketScalar is rarely needed 922 #define EIGEN_DENSE_PUBLIC_INTERFACE(Derived) \ 923 EIGEN_GENERIC_PUBLIC_INTERFACE(Derived) \ 924 typedef typename Base::PacketScalar PacketScalar; 925 926 927 #define EIGEN_PLAIN_ENUM_MIN(a,b) (((int)a <= (int)b) ? (int)a : (int)b) 928 #define EIGEN_PLAIN_ENUM_MAX(a,b) (((int)a >= (int)b) ? (int)a : (int)b) 929 930 // EIGEN_SIZE_MIN_PREFER_DYNAMIC gives the min between compile-time sizes. 0 has absolute priority, followed by 1, 931 // followed by Dynamic, followed by other finite values. The reason for giving Dynamic the priority over 932 // finite values is that min(3, Dynamic) should be Dynamic, since that could be anything between 0 and 3. 933 #define EIGEN_SIZE_MIN_PREFER_DYNAMIC(a,b) (((int)a == 0 || (int)b == 0) ? 0 \ 934 : ((int)a == 1 || (int)b == 1) ? 1 \ 935 : ((int)a == Dynamic || (int)b == Dynamic) ? Dynamic \ 936 : ((int)a <= (int)b) ? (int)a : (int)b) 937 938 // EIGEN_SIZE_MIN_PREFER_FIXED is a variant of EIGEN_SIZE_MIN_PREFER_DYNAMIC comparing MaxSizes. The difference is that finite values 939 // now have priority over Dynamic, so that min(3, Dynamic) gives 3. Indeed, whatever the actual value is 940 // (between 0 and 3), it is not more than 3. 941 #define EIGEN_SIZE_MIN_PREFER_FIXED(a,b) (((int)a == 0 || (int)b == 0) ? 0 \ 942 : ((int)a == 1 || (int)b == 1) ? 1 \ 943 : ((int)a == Dynamic && (int)b == Dynamic) ? Dynamic \ 944 : ((int)a == Dynamic) ? (int)b \ 945 : ((int)b == Dynamic) ? (int)a \ 946 : ((int)a <= (int)b) ? (int)a : (int)b) 947 948 // see EIGEN_SIZE_MIN_PREFER_DYNAMIC. No need for a separate variant for MaxSizes here. 949 #define EIGEN_SIZE_MAX(a,b) (((int)a == Dynamic || (int)b == Dynamic) ? Dynamic \ 950 : ((int)a >= (int)b) ? (int)a : (int)b) 951 952 #define EIGEN_LOGICAL_XOR(a,b) (((a) || (b)) && !((a) && (b))) 953 954 #define EIGEN_IMPLIES(a,b) (!(a) || (b)) 955 956 // the expression type of a standard coefficient wise binary operation 957 #define EIGEN_CWISE_BINARY_RETURN_TYPE(LHS,RHS,OPNAME) \ 958 CwiseBinaryOp< \ 959 EIGEN_CAT(EIGEN_CAT(internal::scalar_,OPNAME),_op)< \ 960 typename internal::traits<LHS>::Scalar, \ 961 typename internal::traits<RHS>::Scalar \ 962 >, \ 963 const LHS, \ 964 const RHS \ 965 > 966 967 #define EIGEN_MAKE_CWISE_BINARY_OP(METHOD,OPNAME) \ 968 template<typename OtherDerived> \ 969 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const EIGEN_CWISE_BINARY_RETURN_TYPE(Derived,OtherDerived,OPNAME) \ 970 (METHOD)(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const \ 971 { \ 972 return EIGEN_CWISE_BINARY_RETURN_TYPE(Derived,OtherDerived,OPNAME)(derived(), other.derived()); \ 973 } 974 975 #define EIGEN_SCALAR_BINARY_SUPPORTED(OPNAME,TYPEA,TYPEB) \ 976 (Eigen::internal::has_ReturnType<Eigen::ScalarBinaryOpTraits<TYPEA,TYPEB,EIGEN_CAT(EIGEN_CAT(Eigen::internal::scalar_,OPNAME),_op)<TYPEA,TYPEB> > >::value) 977 978 #define EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(EXPR,SCALAR,OPNAME) \ 979 CwiseBinaryOp<EIGEN_CAT(EIGEN_CAT(internal::scalar_,OPNAME),_op)<typename internal::traits<EXPR>::Scalar,SCALAR>, const EXPR, \ 980 const typename internal::plain_constant_type<EXPR,SCALAR>::type> 981 982 #define EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(SCALAR,EXPR,OPNAME) \ 983 CwiseBinaryOp<EIGEN_CAT(EIGEN_CAT(internal::scalar_,OPNAME),_op)<SCALAR,typename internal::traits<EXPR>::Scalar>, \ 984 const typename internal::plain_constant_type<EXPR,SCALAR>::type, const EXPR> 985 986 // Workaround for MSVC 2010 (see ML thread "patch with compile for for MSVC 2010") 987 #if EIGEN_COMP_MSVC_STRICT<=1600 988 #define EIGEN_MSVC10_WORKAROUND_BINARYOP_RETURN_TYPE(X) typename internal::enable_if<true,X>::type 989 #else 990 #define EIGEN_MSVC10_WORKAROUND_BINARYOP_RETURN_TYPE(X) X 991 #endif 992 993 #define EIGEN_MAKE_SCALAR_BINARY_OP_ONTHERIGHT(METHOD,OPNAME) \ 994 template <typename T> EIGEN_DEVICE_FUNC inline \ 995 EIGEN_MSVC10_WORKAROUND_BINARYOP_RETURN_TYPE(const EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(Derived,typename internal::promote_scalar_arg<Scalar EIGEN_COMMA T EIGEN_COMMA EIGEN_SCALAR_BINARY_SUPPORTED(OPNAME,Scalar,T)>::type,OPNAME))\ 996 (METHOD)(const T& scalar) const { \ 997 typedef typename internal::promote_scalar_arg<Scalar,T,EIGEN_SCALAR_BINARY_SUPPORTED(OPNAME,Scalar,T)>::type PromotedT; \ 998 return EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(Derived,PromotedT,OPNAME)(derived(), \ 999 typename internal::plain_constant_type<Derived,PromotedT>::type(derived().rows(), derived().cols(), internal::scalar_constant_op<PromotedT>(scalar))); \ 1000 } 1001 1002 #define EIGEN_MAKE_SCALAR_BINARY_OP_ONTHELEFT(METHOD,OPNAME) \ 1003 template <typename T> EIGEN_DEVICE_FUNC inline friend \ 1004 EIGEN_MSVC10_WORKAROUND_BINARYOP_RETURN_TYPE(const EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(typename internal::promote_scalar_arg<Scalar EIGEN_COMMA T EIGEN_COMMA EIGEN_SCALAR_BINARY_SUPPORTED(OPNAME,T,Scalar)>::type,Derived,OPNAME)) \ 1005 (METHOD)(const T& scalar, const StorageBaseType& matrix) { \ 1006 typedef typename internal::promote_scalar_arg<Scalar,T,EIGEN_SCALAR_BINARY_SUPPORTED(OPNAME,T,Scalar)>::type PromotedT; \ 1007 return EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(PromotedT,Derived,OPNAME)( \ 1008 typename internal::plain_constant_type<Derived,PromotedT>::type(matrix.derived().rows(), matrix.derived().cols(), internal::scalar_constant_op<PromotedT>(scalar)), matrix.derived()); \ 1009 } 1010 1011 #define EIGEN_MAKE_SCALAR_BINARY_OP(METHOD,OPNAME) \ 1012 EIGEN_MAKE_SCALAR_BINARY_OP_ONTHELEFT(METHOD,OPNAME) \ 1013 EIGEN_MAKE_SCALAR_BINARY_OP_ONTHERIGHT(METHOD,OPNAME) 1014 1015 1016 #ifdef EIGEN_EXCEPTIONS 1017 # define EIGEN_THROW_X(X) throw X 1018 # define EIGEN_THROW throw 1019 # define EIGEN_TRY try 1020 # define EIGEN_CATCH(X) catch (X) 1021 #else 1022 # ifdef __CUDA_ARCH__ 1023 # define EIGEN_THROW_X(X) asm("trap;") 1024 # define EIGEN_THROW asm("trap;") 1025 # else 1026 # define EIGEN_THROW_X(X) std::abort() 1027 # define EIGEN_THROW std::abort() 1028 # endif 1029 # define EIGEN_TRY if (true) 1030 # define EIGEN_CATCH(X) else 1031 #endif 1032 1033 1034 #if EIGEN_HAS_CXX11_NOEXCEPT 1035 # define EIGEN_INCLUDE_TYPE_TRAITS 1036 # define EIGEN_NOEXCEPT noexcept 1037 # define EIGEN_NOEXCEPT_IF(x) noexcept(x) 1038 # define EIGEN_NO_THROW noexcept(true) 1039 # define EIGEN_EXCEPTION_SPEC(X) noexcept(false) 1040 #else 1041 # define EIGEN_NOEXCEPT 1042 # define EIGEN_NOEXCEPT_IF(x) 1043 # define EIGEN_NO_THROW throw() 1044 # if EIGEN_COMP_MSVC 1045 // MSVC does not support exception specifications (warning C4290), 1046 // and they are deprecated in c++11 anyway. 1047 # define EIGEN_EXCEPTION_SPEC(X) throw() 1048 # else 1049 # define EIGEN_EXCEPTION_SPEC(X) throw(X) 1050 # endif 1051 #endif 1052 1053 #endif // EIGEN_MACROS_H 1054