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//------------------------------------------------------------------------------------------
15// Eigen version and basic defaults
16//------------------------------------------------------------------------------------------
17
18#define EIGEN_WORLD_VERSION 3
19#define EIGEN_MAJOR_VERSION 4
20#define EIGEN_MINOR_VERSION 1
21
22#define EIGEN_VERSION_AT_LEAST(x,y,z) (EIGEN_WORLD_VERSION>x || (EIGEN_WORLD_VERSION>=x && \
23 (EIGEN_MAJOR_VERSION>y || (EIGEN_MAJOR_VERSION>=y && \
24 EIGEN_MINOR_VERSION>=z))))
25
26#ifdef EIGEN_DEFAULT_TO_ROW_MAJOR
27#define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION Eigen::RowMajor
28#else
29#define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION Eigen::ColMajor
30#endif
31
32#ifndef EIGEN_DEFAULT_DENSE_INDEX_TYPE
33#define EIGEN_DEFAULT_DENSE_INDEX_TYPE std::ptrdiff_t
34#endif
35
36// Upperbound on the C++ version to use.
37// Expected values are 03, 11, 14, 17, etc.
38// By default, let's use an arbitrarily large C++ version.
39#ifndef EIGEN_MAX_CPP_VER
40#define EIGEN_MAX_CPP_VER 99
41#endif
42
48#ifndef EIGEN_FAST_MATH
49#define EIGEN_FAST_MATH 1
50#endif
51
52#ifndef EIGEN_STACK_ALLOCATION_LIMIT
53// 131072 == 128 KB
54#define EIGEN_STACK_ALLOCATION_LIMIT 131072
55#endif
56
57//------------------------------------------------------------------------------------------
58// Compiler identification, EIGEN_COMP_*
59//------------------------------------------------------------------------------------------
60
62#ifdef __GNUC__
63 #define EIGEN_COMP_GNUC (__GNUC__*10+__GNUC_MINOR__)
64#else
65 #define EIGEN_COMP_GNUC 0
66#endif
67
69#if defined(__clang__)
70 #define EIGEN_COMP_CLANG (__clang_major__*100+__clang_minor__)
71#else
72 #define EIGEN_COMP_CLANG 0
73#endif
74
76#if defined(__castxml__)
77 #define EIGEN_COMP_CASTXML 1
78#else
79 #define EIGEN_COMP_CASTXML 0
80#endif
81
83#if defined(__llvm__)
84 #define EIGEN_COMP_LLVM 1
85#else
86 #define EIGEN_COMP_LLVM 0
87#endif
88
90#if defined(__INTEL_COMPILER)
91 #define EIGEN_COMP_ICC __INTEL_COMPILER
92#else
93 #define EIGEN_COMP_ICC 0
94#endif
95
97#if defined(__MINGW32__)
98 #define EIGEN_COMP_MINGW 1
99#else
100 #define EIGEN_COMP_MINGW 0
101#endif
102
104#if defined(__SUNPRO_CC)
105 #define EIGEN_COMP_SUNCC 1
106#else
107 #define EIGEN_COMP_SUNCC 0
108#endif
109
111#if defined(_MSC_VER)
112 #define EIGEN_COMP_MSVC _MSC_VER
113#else
114 #define EIGEN_COMP_MSVC 0
115#endif
116
117#if defined(__NVCC__)
118#if defined(__CUDACC_VER_MAJOR__) && (__CUDACC_VER_MAJOR__ >= 9)
119 #define EIGEN_COMP_NVCC ((__CUDACC_VER_MAJOR__ * 10000) + (__CUDACC_VER_MINOR__ * 100))
120#elif defined(__CUDACC_VER__)
121 #define EIGEN_COMP_NVCC __CUDACC_VER__
122#else
123 #error "NVCC did not define compiler version."
124#endif
125#else
126 #define EIGEN_COMP_NVCC 0
127#endif
128
129// For the record, here is a table summarizing the possible values for EIGEN_COMP_MSVC:
130// name ver MSC_VER
131// 2008 9 1500
132// 2010 10 1600
133// 2012 11 1700
134// 2013 12 1800
135// 2015 14 1900
136// "15" 15 1900
137// 2017-14.1 15.0 1910
138// 2017-14.11 15.3 1911
139// 2017-14.12 15.5 1912
140// 2017-14.13 15.6 1913
141// 2017-14.14 15.7 1914
142
144#if defined(_MSVC_LANG)
145 #define EIGEN_COMP_MSVC_LANG _MSVC_LANG
146#else
147 #define EIGEN_COMP_MSVC_LANG 0
148#endif
149
150// For the record, here is a table summarizing the possible values for EIGEN_COMP_MSVC_LANG:
151// MSVC option Standard MSVC_LANG
152// /std:c++14 (default as of VS 2019) C++14 201402L
153// /std:c++17 C++17 201703L
154// /std:c++latest >C++17 >201703L
155
157#if EIGEN_COMP_MSVC && !(EIGEN_COMP_ICC || EIGEN_COMP_LLVM || EIGEN_COMP_CLANG)
158 #define EIGEN_COMP_MSVC_STRICT _MSC_VER
159#else
160 #define EIGEN_COMP_MSVC_STRICT 0
161#endif
162
164// XLC version
165// 3.1 0x0301
166// 4.5 0x0405
167// 5.0 0x0500
168// 12.1 0x0C01
169#if defined(__IBMCPP__) || defined(__xlc__) || defined(__ibmxl__)
170 #define EIGEN_COMP_IBM __xlC__
171#else
172 #define EIGEN_COMP_IBM 0
173#endif
174
176#if defined(__PGI)
177 #define EIGEN_COMP_PGI (__PGIC__*100+__PGIC_MINOR__)
178#else
179 #define EIGEN_COMP_PGI 0
180#endif
181
183#if defined(__NVCOMPILER)
184#define EIGEN_COMP_NVHPC (__NVCOMPILER_MAJOR__ * 100 + __NVCOMPILER_MINOR__)
185#else
186#define EIGEN_COMP_NVHPC 0
187#endif
188
190#if defined(__CC_ARM) || defined(__ARMCC_VERSION)
191 #define EIGEN_COMP_ARM 1
192#else
193 #define EIGEN_COMP_ARM 0
194#endif
195
197#if defined(__EMSCRIPTEN__)
198 #define EIGEN_COMP_EMSCRIPTEN 1
199#else
200 #define EIGEN_COMP_EMSCRIPTEN 0
201#endif
202
203
205#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)
206 #define EIGEN_COMP_GNUC_STRICT 1
207#else
208 #define EIGEN_COMP_GNUC_STRICT 0
209#endif
210
211
212#if EIGEN_COMP_GNUC
213 #define EIGEN_GNUC_AT_LEAST(x,y) ((__GNUC__==x && __GNUC_MINOR__>=y) || __GNUC__>x)
214 #define EIGEN_GNUC_AT_MOST(x,y) ((__GNUC__==x && __GNUC_MINOR__<=y) || __GNUC__<x)
215 #define EIGEN_GNUC_AT(x,y) ( __GNUC__==x && __GNUC_MINOR__==y )
216#else
217 #define EIGEN_GNUC_AT_LEAST(x,y) 0
218 #define EIGEN_GNUC_AT_MOST(x,y) 0
219 #define EIGEN_GNUC_AT(x,y) 0
220#endif
221
222// FIXME: could probably be removed as we do not support gcc 3.x anymore
223#if EIGEN_COMP_GNUC && (__GNUC__ <= 3)
224#define EIGEN_GCC3_OR_OLDER 1
225#else
226#define EIGEN_GCC3_OR_OLDER 0
227#endif
228
229
230
231//------------------------------------------------------------------------------------------
232// Architecture identification, EIGEN_ARCH_*
233//------------------------------------------------------------------------------------------
234
235
236#if defined(__x86_64__) || (defined(_M_X64) && !defined(_M_ARM64EC)) || defined(__amd64)
237 #define EIGEN_ARCH_x86_64 1
238#else
239 #define EIGEN_ARCH_x86_64 0
240#endif
241
242#if defined(__i386__) || defined(_M_IX86) || defined(_X86_) || defined(__i386)
243 #define EIGEN_ARCH_i386 1
244#else
245 #define EIGEN_ARCH_i386 0
246#endif
247
248#if EIGEN_ARCH_x86_64 || EIGEN_ARCH_i386
249 #define EIGEN_ARCH_i386_OR_x86_64 1
250#else
251 #define EIGEN_ARCH_i386_OR_x86_64 0
252#endif
253
255#if defined(__arm__)
256 #define EIGEN_ARCH_ARM 1
257#else
258 #define EIGEN_ARCH_ARM 0
259#endif
260
262#if defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
263 #define EIGEN_ARCH_ARM64 1
264#else
265 #define EIGEN_ARCH_ARM64 0
266#endif
267
269#if EIGEN_ARCH_ARM || EIGEN_ARCH_ARM64
270 #define EIGEN_ARCH_ARM_OR_ARM64 1
271#else
272 #define EIGEN_ARCH_ARM_OR_ARM64 0
273#endif
274
276#if EIGEN_ARCH_ARM_OR_ARM64 && defined(__ARM_ARCH) && __ARM_ARCH >= 8
277#define EIGEN_ARCH_ARMV8 1
278#else
279#define EIGEN_ARCH_ARMV8 0
280#endif
281
282
285#if EIGEN_ARCH_ARM_OR_ARM64
286 #ifndef EIGEN_HAS_ARM64_FP16
287 #if defined(__ARM_FP16_FORMAT_IEEE)
288 #define EIGEN_HAS_ARM64_FP16 1
289 #else
290 #define EIGEN_HAS_ARM64_FP16 0
291 #endif
292 #endif
293#endif
294
297#if EIGEN_ARCH_ARM_OR_ARM64
298 #ifndef EIGEN_HAS_ARM64_FP16_VECTOR_ARITHMETIC
299 #if defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
300 #define EIGEN_HAS_ARM64_FP16_VECTOR_ARITHMETIC 1
301 #else
302 #define EIGEN_HAS_ARM64_FP16_VECTOR_ARITHMETIC 0
303 #endif
304 #endif
305#endif
306
309#if EIGEN_ARCH_ARM_OR_ARM64
310 #ifndef EIGEN_HAS_ARM64_FP16_SCALAR_ARITHMETIC
311 #if defined(__ARM_FEATURE_FP16_SCALAR_ARITHMETIC)
312 #define EIGEN_HAS_ARM64_FP16_SCALAR_ARITHMETIC 1
313 #endif
314 #endif
315#endif
316
318#if defined(__mips__) || defined(__mips)
319 #define EIGEN_ARCH_MIPS 1
320#else
321 #define EIGEN_ARCH_MIPS 0
322#endif
323
325#if defined(__sparc__) || defined(__sparc)
326 #define EIGEN_ARCH_SPARC 1
327#else
328 #define EIGEN_ARCH_SPARC 0
329#endif
330
332#if defined(__ia64__)
333 #define EIGEN_ARCH_IA64 1
334#else
335 #define EIGEN_ARCH_IA64 0
336#endif
337
339#if defined(__powerpc__) || defined(__ppc__) || defined(_M_PPC) || defined(__POWERPC__)
340 #define EIGEN_ARCH_PPC 1
341#else
342 #define EIGEN_ARCH_PPC 0
343#endif
344
345
346
347//------------------------------------------------------------------------------------------
348// Operating system identification, EIGEN_OS_*
349//------------------------------------------------------------------------------------------
350
352#if defined(__unix__) || defined(__unix)
353 #define EIGEN_OS_UNIX 1
354#else
355 #define EIGEN_OS_UNIX 0
356#endif
357
359#if defined(__linux__)
360 #define EIGEN_OS_LINUX 1
361#else
362 #define EIGEN_OS_LINUX 0
363#endif
364
366// note: ANDROID is defined when using ndk_build, __ANDROID__ is defined when using a standalone toolchain.
367#if defined(__ANDROID__) || defined(ANDROID)
368 #define EIGEN_OS_ANDROID 1
369#else
370 #define EIGEN_OS_ANDROID 0
371#endif
372
374#if defined(__gnu_linux__) && !(EIGEN_OS_ANDROID)
375 #define EIGEN_OS_GNULINUX 1
376#else
377 #define EIGEN_OS_GNULINUX 0
378#endif
379
381#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__)
382 #define EIGEN_OS_BSD 1
383#else
384 #define EIGEN_OS_BSD 0
385#endif
386
388#if defined(__APPLE__)
389 #define EIGEN_OS_MAC 1
390#else
391 #define EIGEN_OS_MAC 0
392#endif
393
395#if defined(__QNX__)
396 #define EIGEN_OS_QNX 1
397#else
398 #define EIGEN_OS_QNX 0
399#endif
400
402#if defined(_WIN32)
403 #define EIGEN_OS_WIN 1
404#else
405 #define EIGEN_OS_WIN 0
406#endif
407
409#if defined(_WIN64)
410 #define EIGEN_OS_WIN64 1
411#else
412 #define EIGEN_OS_WIN64 0
413#endif
414
416#if defined(_WIN32_WCE)
417 #define EIGEN_OS_WINCE 1
418#else
419 #define EIGEN_OS_WINCE 0
420#endif
421
423#if defined(__CYGWIN__)
424 #define EIGEN_OS_CYGWIN 1
425#else
426 #define EIGEN_OS_CYGWIN 0
427#endif
428
430#if EIGEN_OS_WIN && !( EIGEN_OS_WINCE || EIGEN_OS_CYGWIN )
431 #define EIGEN_OS_WIN_STRICT 1
432#else
433 #define EIGEN_OS_WIN_STRICT 0
434#endif
435
437// compiler solaris __SUNPRO_C
438// version studio
439// 5.7 10 0x570
440// 5.8 11 0x580
441// 5.9 12 0x590
442// 5.10 12.1 0x5100
443// 5.11 12.2 0x5110
444// 5.12 12.3 0x5120
445#if (defined(sun) || defined(__sun)) && !(defined(__SVR4) || defined(__svr4__))
446 #define EIGEN_OS_SUN __SUNPRO_C
447#else
448 #define EIGEN_OS_SUN 0
449#endif
450
452#if (defined(sun) || defined(__sun)) && (defined(__SVR4) || defined(__svr4__))
453 #define EIGEN_OS_SOLARIS 1
454#else
455 #define EIGEN_OS_SOLARIS 0
456#endif
457
458
459//------------------------------------------------------------------------------------------
460// Detect GPU compilers and architectures
461//------------------------------------------------------------------------------------------
462
463// NVCC is not supported as the target platform for HIPCC
464// Note that this also makes EIGEN_CUDACC and EIGEN_HIPCC mutually exclusive
465#if defined(__NVCC__) && defined(__HIPCC__)
466 #error "NVCC as the target platform for HIPCC is currently not supported."
467#endif
468
469#if defined(__CUDACC__) && !defined(EIGEN_NO_CUDA)
470 // Means the compiler is either nvcc or clang with CUDA enabled
471 #define EIGEN_CUDACC __CUDACC__
472#endif
473
474#if defined(__CUDA_ARCH__) && !defined(EIGEN_NO_CUDA)
475 // Means we are generating code for the device
476 #define EIGEN_CUDA_ARCH __CUDA_ARCH__
477#endif
478
479#if defined(EIGEN_CUDACC)
480#include <cuda.h>
481 #define EIGEN_CUDA_SDK_VER (CUDA_VERSION * 10)
482#else
483 #define EIGEN_CUDA_SDK_VER 0
484#endif
485
486#if defined(__HIPCC__) && !defined(EIGEN_NO_HIP)
487 // Means the compiler is HIPCC (analogous to EIGEN_CUDACC, but for HIP)
488 #define EIGEN_HIPCC __HIPCC__
489
490 // We need to include hip_runtime.h here because it pulls in
491 // ++ hip_common.h which contains the define for __HIP_DEVICE_COMPILE__
492 // ++ host_defines.h which contains the defines for the __host__ and __device__ macros
493 #include <hip/hip_runtime.h>
494
495 #if defined(__HIP_DEVICE_COMPILE__)
496 // analogous to EIGEN_CUDA_ARCH, but for HIP
497 #define EIGEN_HIP_DEVICE_COMPILE __HIP_DEVICE_COMPILE__
498 #endif
499
500 // For HIP (ROCm 3.5 and higher), we need to explicitly set the launch_bounds attribute
501 // value to 1024. The compiler assigns a default value of 256 when the attribute is not
502 // specified. This results in failures on the HIP platform, for cases when a GPU kernel
503 // without an explicit launch_bounds attribute is called with a threads_per_block value
504 // greater than 256.
505 //
506 // This is a regression in functioanlity and is expected to be fixed within the next
507 // couple of ROCm releases (compiler will go back to using 1024 value as the default)
508 //
509 // In the meantime, we will use a "only enabled for HIP" macro to set the launch_bounds
510 // attribute.
511
512 #define EIGEN_HIP_LAUNCH_BOUNDS_1024 __launch_bounds__(1024)
513
514#endif
515
516#if !defined(EIGEN_HIP_LAUNCH_BOUNDS_1024)
517#define EIGEN_HIP_LAUNCH_BOUNDS_1024
518#endif // !defined(EIGEN_HIP_LAUNCH_BOUNDS_1024)
519
520// Unify CUDA/HIPCC
521
522#if defined(EIGEN_CUDACC) || defined(EIGEN_HIPCC)
523//
524// If either EIGEN_CUDACC or EIGEN_HIPCC is defined, then define EIGEN_GPUCC
525//
526#define EIGEN_GPUCC
527//
528// EIGEN_HIPCC implies the HIP compiler and is used to tweak Eigen code for use in HIP kernels
529// EIGEN_CUDACC implies the CUDA compiler and is used to tweak Eigen code for use in CUDA kernels
530//
531// In most cases the same tweaks are required to the Eigen code to enable in both the HIP and CUDA kernels.
532// For those cases, the corresponding code should be guarded with
533// #if defined(EIGEN_GPUCC)
534// instead of
535// #if defined(EIGEN_CUDACC) || defined(EIGEN_HIPCC)
536//
537// For cases where the tweak is specific to HIP, the code should be guarded with
538// #if defined(EIGEN_HIPCC)
539//
540// For cases where the tweak is specific to CUDA, the code should be guarded with
541// #if defined(EIGEN_CUDACC)
542//
543#endif
544
545#if defined(EIGEN_CUDA_ARCH) || defined(EIGEN_HIP_DEVICE_COMPILE)
546//
547// If either EIGEN_CUDA_ARCH or EIGEN_HIP_DEVICE_COMPILE is defined, then define EIGEN_GPU_COMPILE_PHASE
548//
549#define EIGEN_GPU_COMPILE_PHASE
550//
551// GPU compilers (HIPCC, NVCC) typically do two passes over the source code,
552// + one to compile the source for the "host" (ie CPU)
553// + another to compile the source for the "device" (ie. GPU)
554//
555// Code that needs to enabled only during the either the "host" or "device" compilation phase
556// needs to be guarded with a macro that indicates the current compilation phase
557//
558// EIGEN_HIP_DEVICE_COMPILE implies the device compilation phase in HIP
559// EIGEN_CUDA_ARCH implies the device compilation phase in CUDA
560//
561// In most cases, the "host" / "device" specific code is the same for both HIP and CUDA
562// For those cases, the code should be guarded with
563// #if defined(EIGEN_GPU_COMPILE_PHASE)
564// instead of
565// #if defined(EIGEN_CUDA_ARCH) || defined(EIGEN_HIP_DEVICE_COMPILE)
566//
567// For cases where the tweak is specific to HIP, the code should be guarded with
568// #if defined(EIGEN_HIP_DEVICE_COMPILE)
569//
570// For cases where the tweak is specific to CUDA, the code should be guarded with
571// #if defined(EIGEN_CUDA_ARCH)
572//
573#endif
574
577#if EIGEN_ARCH_ARM64
578 #ifndef EIGEN_HAS_ARM64_FP16_VECTOR_ARITHMETIC
579 // Clang only supports FP16 on aarch64, and not all intrinsics are available
580 // on A32 anyways even in GCC (e.g. vdiv_f16, vsqrt_f16).
581 #if EIGEN_ARCH_ARM64 && defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) && !defined(EIGEN_GPU_COMPILE_PHASE)
582 #define EIGEN_HAS_ARM64_FP16_VECTOR_ARITHMETIC 1
583 #else
584 #define EIGEN_HAS_ARM64_FP16_VECTOR_ARITHMETIC 0
585 #endif
586 #endif
587#endif
588
591#if EIGEN_ARCH_ARM64
592 #ifndef EIGEN_HAS_ARM64_FP16_SCALAR_ARITHMETIC
593 // Clang only supports FP16 on aarch64, and not all intrinsics are available
594 // on A32 anyways, even in GCC (e.g. vceqh_f16).
595 #if EIGEN_ARCH_ARM64 && defined(__ARM_FEATURE_FP16_SCALAR_ARITHMETIC) && !defined(EIGEN_GPU_COMPILE_PHASE)
596 #define EIGEN_HAS_ARM64_FP16_SCALAR_ARITHMETIC 1
597 #endif
598 #endif
599#endif
600
601#if defined(EIGEN_USE_SYCL) && defined(__SYCL_DEVICE_ONLY__)
602// EIGEN_USE_SYCL is a user-defined macro while __SYCL_DEVICE_ONLY__ is a compiler-defined macro.
603// In most cases we want to check if both macros are defined which can be done using the define below.
604#define SYCL_DEVICE_ONLY
605#endif
606
607//------------------------------------------------------------------------------------------
608// Detect Compiler/Architecture/OS specific features
609//------------------------------------------------------------------------------------------
610
611#if EIGEN_GNUC_AT_MOST(4,3) && !EIGEN_COMP_CLANG
612 // see bug 89
613 #define EIGEN_SAFE_TO_USE_STANDARD_ASSERT_MACRO 0
614#else
615 #define EIGEN_SAFE_TO_USE_STANDARD_ASSERT_MACRO 1
616#endif
617
618// Cross compiler wrapper around LLVM's __has_builtin
619#ifdef __has_builtin
620# define EIGEN_HAS_BUILTIN(x) __has_builtin(x)
621#else
622# define EIGEN_HAS_BUILTIN(x) 0
623#endif
624
625// A Clang feature extension to determine compiler features.
626// We use it to determine 'cxx_rvalue_references'
627#ifndef __has_feature
628# define __has_feature(x) 0
629#endif
630
631// Some old compilers do not support template specializations like:
632// template<typename T,int N> void foo(const T x[N]);
633#if !( EIGEN_COMP_CLANG && ( (EIGEN_COMP_CLANG<309) \
634 || (defined(__apple_build_version__) && (__apple_build_version__ < 9000000))) \
635 || EIGEN_COMP_GNUC_STRICT && EIGEN_COMP_GNUC<49)
636#define EIGEN_HAS_STATIC_ARRAY_TEMPLATE 1
637#else
638#define EIGEN_HAS_STATIC_ARRAY_TEMPLATE 0
639#endif
640
641// The macro EIGEN_CPLUSPLUS is a replacement for __cplusplus/_MSVC_LANG that
642// works for both platforms, indicating the C++ standard version number.
643//
644// With MSVC, without defining /Zc:__cplusplus, the __cplusplus macro will
645// report 199711L regardless of the language standard specified via /std.
646// We need to rely on _MSVC_LANG instead, which is only available after
647// VS2015.3.
648#if EIGEN_COMP_MSVC_LANG > 0
649#define EIGEN_CPLUSPLUS EIGEN_COMP_MSVC_LANG
650#elif EIGEN_COMP_MSVC >= 1900
651#define EIGEN_CPLUSPLUS 201103L
652#elif defined(__cplusplus)
653#define EIGEN_CPLUSPLUS __cplusplus
654#else
655#define EIGEN_CPLUSPLUS 0
656#endif
657
658// The macro EIGEN_COMP_CXXVER defines the c++ verson expected by the compiler.
659// For instance, if compiling with gcc and -std=c++17, then EIGEN_COMP_CXXVER
660// is defined to 17.
661#if EIGEN_CPLUSPLUS > 201703L
662 #define EIGEN_COMP_CXXVER 20
663#elif EIGEN_CPLUSPLUS > 201402L
664 #define EIGEN_COMP_CXXVER 17
665#elif EIGEN_CPLUSPLUS > 201103L
666 #define EIGEN_COMP_CXXVER 14
667#elif EIGEN_CPLUSPLUS >= 201103L
668 #define EIGEN_COMP_CXXVER 11
669#else
670 #define EIGEN_COMP_CXXVER 03
671#endif
672
673#ifndef EIGEN_HAS_CXX14_VARIABLE_TEMPLATES
674 #if defined(__cpp_variable_templates) && __cpp_variable_templates >= 201304 && EIGEN_MAX_CPP_VER>=14
675 #define EIGEN_HAS_CXX14_VARIABLE_TEMPLATES 1
676 #else
677 #define EIGEN_HAS_CXX14_VARIABLE_TEMPLATES 0
678 #endif
679#endif
680
681
682// The macros EIGEN_HAS_CXX?? defines a rough estimate of available c++ features
683// but in practice we should not rely on them but rather on the availabilty of
684// individual features as defined later.
685// This is why there is no EIGEN_HAS_CXX17.
686// FIXME: get rid of EIGEN_HAS_CXX14 and maybe even EIGEN_HAS_CXX11.
687#if EIGEN_MAX_CPP_VER>=11 && EIGEN_COMP_CXXVER>=11
688#define EIGEN_HAS_CXX11 1
689#else
690#define EIGEN_HAS_CXX11 0
691#endif
692
693#if EIGEN_MAX_CPP_VER>=14 && EIGEN_COMP_CXXVER>=14
694#define EIGEN_HAS_CXX14 1
695#else
696#define EIGEN_HAS_CXX14 0
697#endif
698
699// Do we support r-value references?
700#ifndef EIGEN_HAS_RVALUE_REFERENCES
701#if EIGEN_MAX_CPP_VER>=11 && \
702 (__has_feature(cxx_rvalue_references) || \
703 (EIGEN_COMP_CXXVER >= 11) || (EIGEN_COMP_MSVC >= 1600))
704 #define EIGEN_HAS_RVALUE_REFERENCES 1
705#else
706 #define EIGEN_HAS_RVALUE_REFERENCES 0
707#endif
708#endif
709
710// Does the compiler support C99?
711// Need to include <cmath> to make sure _GLIBCXX_USE_C99 gets defined
712#include <cmath>
713#ifndef EIGEN_HAS_C99_MATH
714#if EIGEN_MAX_CPP_VER>=11 && \
715 ((defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)) \
716 || (defined(__GNUC__) && defined(_GLIBCXX_USE_C99)) \
717 || (defined(_LIBCPP_VERSION) && !defined(_MSC_VER)) \
718 || (EIGEN_COMP_MSVC >= 1900) || defined(SYCL_DEVICE_ONLY))
719 #define EIGEN_HAS_C99_MATH 1
720#else
721 #define EIGEN_HAS_C99_MATH 0
722#endif
723#endif
724
725// Does the compiler support result_of?
726// result_of was deprecated in c++17 and removed in c++ 20
727#ifndef EIGEN_HAS_STD_RESULT_OF
728#if EIGEN_HAS_CXX11 && EIGEN_COMP_CXXVER < 17
729#define EIGEN_HAS_STD_RESULT_OF 1
730#else
731#define EIGEN_HAS_STD_RESULT_OF 0
732#endif
733#endif
734
735// Does the compiler support std::hash?
736#ifndef EIGEN_HAS_STD_HASH
737// The std::hash struct is defined in C++11 but is not labelled as a __device__
738// function and is not constexpr, so cannot be used on device.
739#if EIGEN_HAS_CXX11 && !defined(EIGEN_GPU_COMPILE_PHASE)
740#define EIGEN_HAS_STD_HASH 1
741#else
742#define EIGEN_HAS_STD_HASH 0
743#endif
744#endif // EIGEN_HAS_STD_HASH
745
746#ifndef EIGEN_HAS_STD_INVOKE_RESULT
747#if EIGEN_MAX_CPP_VER >= 17 && EIGEN_COMP_CXXVER >= 17
748#define EIGEN_HAS_STD_INVOKE_RESULT 1
749#else
750#define EIGEN_HAS_STD_INVOKE_RESULT 0
751#endif
752#endif
753
754#ifndef EIGEN_HAS_ALIGNAS
755#if EIGEN_MAX_CPP_VER>=11 && EIGEN_HAS_CXX11 && \
756 ( __has_feature(cxx_alignas) \
757 || EIGEN_HAS_CXX14 \
758 || (EIGEN_COMP_MSVC >= 1800) \
759 || (EIGEN_GNUC_AT_LEAST(4,8)) \
760 || (EIGEN_COMP_CLANG>=305) \
761 || (EIGEN_COMP_ICC>=1500) \
762 || (EIGEN_COMP_PGI>=1500) \
763 || (EIGEN_COMP_SUNCC>=0x5130))
764#define EIGEN_HAS_ALIGNAS 1
765#else
766#define EIGEN_HAS_ALIGNAS 0
767#endif
768#endif
769
770// Does the compiler support type_traits?
771// - full support of type traits was added only to GCC 5.1.0.
772// - 20150626 corresponds to the last release of 4.x libstdc++
773#ifndef EIGEN_HAS_TYPE_TRAITS
774#if EIGEN_MAX_CPP_VER>=11 && (EIGEN_HAS_CXX11 || EIGEN_COMP_MSVC >= 1700) \
775 && ((!EIGEN_COMP_GNUC_STRICT) || EIGEN_GNUC_AT_LEAST(5, 1)) \
776 && ((!defined(__GLIBCXX__)) || __GLIBCXX__ > 20150626)
777#define EIGEN_HAS_TYPE_TRAITS 1
778#define EIGEN_INCLUDE_TYPE_TRAITS
779#else
780#define EIGEN_HAS_TYPE_TRAITS 0
781#endif
782#endif
783
784// Does the compiler support variadic templates?
785#ifndef EIGEN_HAS_VARIADIC_TEMPLATES
786#if EIGEN_MAX_CPP_VER>=11 && (EIGEN_COMP_CXXVER >= 11) \
787 && (!defined(__NVCC__) || !EIGEN_ARCH_ARM_OR_ARM64 || (EIGEN_COMP_NVCC >= 80000) )
788 // ^^ Disable the use of variadic templates when compiling with versions of nvcc older than 8.0 on ARM devices:
789 // this prevents nvcc from crashing when compiling Eigen on Tegra X1
790#define EIGEN_HAS_VARIADIC_TEMPLATES 1
791#elif EIGEN_MAX_CPP_VER>=11 && (EIGEN_COMP_CXXVER >= 11) && defined(SYCL_DEVICE_ONLY)
792#define EIGEN_HAS_VARIADIC_TEMPLATES 1
793#else
794#define EIGEN_HAS_VARIADIC_TEMPLATES 0
795#endif
796#endif
797
798// Does the compiler fully support const expressions? (as in c++14)
799#ifndef EIGEN_HAS_CONSTEXPR
800 #if defined(EIGEN_CUDACC)
801 // Const expressions are supported provided that c++11 is enabled and we're using either clang or nvcc 7.5 or above
802 #if EIGEN_MAX_CPP_VER>=14 && (EIGEN_COMP_CXXVER >= 11 && (EIGEN_COMP_CLANG || EIGEN_COMP_NVCC >= 70500))
803 #define EIGEN_HAS_CONSTEXPR 1
804 #endif
805 #elif EIGEN_MAX_CPP_VER>=14 && (__has_feature(cxx_relaxed_constexpr) || (EIGEN_COMP_CXXVER >= 14) || \
806 (EIGEN_GNUC_AT_LEAST(4,8) && (EIGEN_COMP_CXXVER >= 11)) || \
807 (EIGEN_COMP_CLANG >= 306 && (EIGEN_COMP_CXXVER >= 11)))
808 #define EIGEN_HAS_CONSTEXPR 1
809 #endif
810
811 #ifndef EIGEN_HAS_CONSTEXPR
812 #define EIGEN_HAS_CONSTEXPR 0
813 #endif
814
815#endif // EIGEN_HAS_CONSTEXPR
816
817#if EIGEN_HAS_CONSTEXPR
818#define EIGEN_CONSTEXPR constexpr
819#else
820#define EIGEN_CONSTEXPR
821#endif
822
823// Does the compiler support C++11 math?
824// Let's be conservative and enable the default C++11 implementation only if we are sure it exists
825#ifndef EIGEN_HAS_CXX11_MATH
826 #if EIGEN_MAX_CPP_VER>=11 && ((EIGEN_COMP_CXXVER > 11) || (EIGEN_COMP_CXXVER == 11) && (EIGEN_COMP_GNUC_STRICT || EIGEN_COMP_CLANG || EIGEN_COMP_MSVC || EIGEN_COMP_ICC) \
827 && (EIGEN_ARCH_i386_OR_x86_64) && (EIGEN_OS_GNULINUX || EIGEN_OS_WIN_STRICT || EIGEN_OS_MAC))
828 #define EIGEN_HAS_CXX11_MATH 1
829 #else
830 #define EIGEN_HAS_CXX11_MATH 0
831 #endif
832#endif
833
834// Does the compiler support proper C++11 containers?
835#ifndef EIGEN_HAS_CXX11_CONTAINERS
836 #if EIGEN_MAX_CPP_VER>=11 && \
837 ((EIGEN_COMP_CXXVER > 11) \
838 || ((EIGEN_COMP_CXXVER == 11) && (EIGEN_COMP_GNUC_STRICT || EIGEN_COMP_CLANG || EIGEN_COMP_MSVC || EIGEN_COMP_ICC>=1400)))
839 #define EIGEN_HAS_CXX11_CONTAINERS 1
840 #else
841 #define EIGEN_HAS_CXX11_CONTAINERS 0
842 #endif
843#endif
844
845// Does the compiler support C++11 noexcept?
846#ifndef EIGEN_HAS_CXX11_NOEXCEPT
847 #if EIGEN_MAX_CPP_VER>=11 && \
848 (__has_feature(cxx_noexcept) \
849 || (EIGEN_COMP_CXXVER > 11) \
850 || ((EIGEN_COMP_CXXVER == 11) && (EIGEN_COMP_GNUC_STRICT || EIGEN_COMP_CLANG || EIGEN_COMP_MSVC || EIGEN_COMP_ICC>=1400)))
851 #define EIGEN_HAS_CXX11_NOEXCEPT 1
852 #else
853 #define EIGEN_HAS_CXX11_NOEXCEPT 0
854 #endif
855#endif
856
857#ifndef EIGEN_HAS_CXX11_ATOMIC
858 #if EIGEN_MAX_CPP_VER>=11 && \
859 (__has_feature(cxx_atomic) \
860 || (EIGEN_COMP_CXXVER > 11) \
861 || ((EIGEN_COMP_CXXVER == 11) && (EIGEN_COMP_MSVC==0 || EIGEN_COMP_MSVC >= 1700)))
862 #define EIGEN_HAS_CXX11_ATOMIC 1
863 #else
864 #define EIGEN_HAS_CXX11_ATOMIC 0
865 #endif
866#endif
867
868#ifndef EIGEN_HAS_CXX11_OVERRIDE_FINAL
869 #if EIGEN_MAX_CPP_VER>=11 && \
870 (EIGEN_COMP_CXXVER >= 11 || EIGEN_COMP_MSVC >= 1700)
871 #define EIGEN_HAS_CXX11_OVERRIDE_FINAL 1
872 #else
873 #define EIGEN_HAS_CXX11_OVERRIDE_FINAL 0
874 #endif
875#endif
876
877// NOTE: the required Apple's clang version is very conservative
878// and it could be that XCode 9 works just fine.
879// NOTE: the MSVC version is based on https://en.cppreference.com/w/cpp/compiler_support
880// and not tested.
881#ifndef EIGEN_HAS_CXX17_OVERALIGN
882#if EIGEN_MAX_CPP_VER>=17 && EIGEN_COMP_CXXVER>=17 && ( \
883 (EIGEN_COMP_MSVC >= 1912) \
884 || (EIGEN_GNUC_AT_LEAST(7,0)) \
885 || ((!defined(__apple_build_version__)) && (EIGEN_COMP_CLANG>=500)) \
886 || (( defined(__apple_build_version__)) && (__apple_build_version__>=10000000)) \
887 )
888#define EIGEN_HAS_CXX17_OVERALIGN 1
889#else
890#define EIGEN_HAS_CXX17_OVERALIGN 0
891#endif
892#endif
893
894#if defined(EIGEN_CUDACC) && EIGEN_HAS_CONSTEXPR
895 // While available already with c++11, this is useful mostly starting with c++14 and relaxed constexpr rules
896 #if defined(__NVCC__)
897 // nvcc considers constexpr functions as __host__ __device__ with the option --expt-relaxed-constexpr
898 #ifdef __CUDACC_RELAXED_CONSTEXPR__
899 #define EIGEN_CONSTEXPR_ARE_DEVICE_FUNC
900 #endif
901 #elif defined(__clang__) && defined(__CUDA__) && __has_feature(cxx_relaxed_constexpr)
902 // clang++ always considers constexpr functions as implicitly __host__ __device__
903 #define EIGEN_CONSTEXPR_ARE_DEVICE_FUNC
904 #endif
905#endif
906
907// Does the compiler support the __int128 and __uint128_t extensions for 128-bit
908// integer arithmetic?
909//
910// Clang and GCC define __SIZEOF_INT128__ when these extensions are supported,
911// but we avoid using them in certain cases:
912//
913// * Building using Clang for Windows, where the Clang runtime library has
914// 128-bit support only on LP64 architectures, but Windows is LLP64.
915#ifndef EIGEN_HAS_BUILTIN_INT128
916#if defined(__SIZEOF_INT128__) && !(EIGEN_OS_WIN && EIGEN_COMP_CLANG)
917#define EIGEN_HAS_BUILTIN_INT128 1
918#else
919#define EIGEN_HAS_BUILTIN_INT128 0
920#endif
921#endif
922
923//------------------------------------------------------------------------------------------
924// Preprocessor programming helpers
925//------------------------------------------------------------------------------------------
926
927// This macro can be used to prevent from macro expansion, e.g.:
928// std::max EIGEN_NOT_A_MACRO(a,b)
929#define EIGEN_NOT_A_MACRO
930
931#define EIGEN_DEBUG_VAR(x) std::cerr << #x << " = " << x << std::endl;
932
933// concatenate two tokens
934#define EIGEN_CAT2(a,b) a ## b
935#define EIGEN_CAT(a,b) EIGEN_CAT2(a,b)
936
937#define EIGEN_COMMA ,
938
939// convert a token to a string
940#define EIGEN_MAKESTRING2(a) #a
941#define EIGEN_MAKESTRING(a) EIGEN_MAKESTRING2(a)
942
943// EIGEN_STRONG_INLINE is a stronger version of the inline, using __forceinline on MSVC,
944// but it still doesn't use GCC's always_inline. This is useful in (common) situations where MSVC needs forceinline
945// but GCC is still doing fine with just inline.
946#ifndef EIGEN_STRONG_INLINE
947#if (EIGEN_COMP_MSVC || EIGEN_COMP_ICC) && !defined(EIGEN_GPUCC)
948#define EIGEN_STRONG_INLINE __forceinline
949#else
950#define EIGEN_STRONG_INLINE inline
951#endif
952#endif
953
954// EIGEN_ALWAYS_INLINE is the stronget, it has the effect of making the function inline and adding every possible
955// attribute to maximize inlining. This should only be used when really necessary: in particular,
956// it uses __attribute__((always_inline)) on GCC, which most of the time is useless and can severely harm compile times.
957// FIXME with the always_inline attribute,
958// gcc 3.4.x and 4.1 reports the following compilation error:
959// Eval.h:91: sorry, unimplemented: inlining failed in call to 'const Eigen::Eval<Derived> Eigen::MatrixBase<Scalar, Derived>::eval() const'
960// : function body not available
961// See also bug 1367
962#if EIGEN_GNUC_AT_LEAST(4,2) && !defined(SYCL_DEVICE_ONLY)
963#define EIGEN_ALWAYS_INLINE __attribute__((always_inline)) inline
964#else
965#define EIGEN_ALWAYS_INLINE EIGEN_STRONG_INLINE
966#endif
967
968#if EIGEN_COMP_GNUC
969#define EIGEN_DONT_INLINE __attribute__((noinline))
970#elif EIGEN_COMP_MSVC
971#define EIGEN_DONT_INLINE __declspec(noinline)
972#else
973#define EIGEN_DONT_INLINE
974#endif
975
976#if EIGEN_COMP_GNUC
977#define EIGEN_PERMISSIVE_EXPR __extension__
978#else
979#define EIGEN_PERMISSIVE_EXPR
980#endif
981
982// GPU stuff
983
984// Disable some features when compiling with GPU compilers (NVCC/clang-cuda/SYCL/HIPCC)
985#if defined(EIGEN_CUDACC) || defined(SYCL_DEVICE_ONLY) || defined(EIGEN_HIPCC)
986 // Do not try asserts on device code
987 #ifndef EIGEN_NO_DEBUG
988 #define EIGEN_NO_DEBUG
989 #endif
990
991 #ifdef EIGEN_INTERNAL_DEBUGGING
992 #undef EIGEN_INTERNAL_DEBUGGING
993 #endif
994
995 #ifdef EIGEN_EXCEPTIONS
996 #undef EIGEN_EXCEPTIONS
997 #endif
998#endif
999
1000#if defined(SYCL_DEVICE_ONLY)
1001 #ifndef EIGEN_DONT_VECTORIZE
1002 #define EIGEN_DONT_VECTORIZE
1003 #endif
1004 #define EIGEN_DEVICE_FUNC __attribute__((flatten)) __attribute__((always_inline))
1005// All functions callable from CUDA/HIP code must be qualified with __device__
1006#elif defined(EIGEN_GPUCC)
1007 #define EIGEN_DEVICE_FUNC __host__ __device__
1008#else
1009 #define EIGEN_DEVICE_FUNC
1010#endif
1011
1012
1013// this macro allows to get rid of linking errors about multiply defined functions.
1014// - static is not very good because it prevents definitions from different object files to be merged.
1015// So static causes the resulting linked executable to be bloated with multiple copies of the same function.
1016// - inline is not perfect either as it unwantedly hints the compiler toward inlining the function.
1017#define EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_DEVICE_FUNC
1018#define EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_DEVICE_FUNC inline
1019
1020#ifdef NDEBUG
1021# ifndef EIGEN_NO_DEBUG
1022# define EIGEN_NO_DEBUG
1023# endif
1024#endif
1025
1026// eigen_plain_assert is where we implement the workaround for the assert() bug in GCC <= 4.3, see bug 89
1027#ifdef EIGEN_NO_DEBUG
1028 #ifdef SYCL_DEVICE_ONLY // used to silence the warning on SYCL device
1029 #define eigen_plain_assert(x) EIGEN_UNUSED_VARIABLE(x)
1030 #else
1031 #define eigen_plain_assert(x)
1032 #endif
1033#else
1034 #if EIGEN_SAFE_TO_USE_STANDARD_ASSERT_MACRO
1035 namespace Eigen {
1036 namespace internal {
1037 inline bool copy_bool(bool b) { return b; }
1038 }
1039 }
1040 #define eigen_plain_assert(x) assert(x)
1041 #else
1042 // work around bug 89
1043 #include <cstdlib> // for abort
1044 #include <iostream> // for std::cerr
1045
1046 namespace Eigen {
1047 namespace internal {
1048 // trivial function copying a bool. Must be EIGEN_DONT_INLINE, so we implement it after including Eigen headers.
1049 // see bug 89.
1050 namespace {
1051 EIGEN_DONT_INLINE bool copy_bool(bool b) { return b; }
1052 }
1053 inline void assert_fail(const char *condition, const char *function, const char *file, int line)
1054 {
1055 std::cerr << "assertion failed: " << condition << " in function " << function << " at " << file << ":" << line << std::endl;
1056 abort();
1057 }
1058 }
1059 }
1060 #define eigen_plain_assert(x) \
1061 do { \
1062 if(!Eigen::internal::copy_bool(x)) \
1063 Eigen::internal::assert_fail(EIGEN_MAKESTRING(x), __PRETTY_FUNCTION__, __FILE__, __LINE__); \
1064 } while(false)
1065 #endif
1066#endif
1067
1068// eigen_assert can be overridden
1069#ifndef eigen_assert
1070#define eigen_assert(x) eigen_plain_assert(x)
1071#endif
1072
1073#ifdef EIGEN_INTERNAL_DEBUGGING
1074#define eigen_internal_assert(x) eigen_assert(x)
1075#else
1076#define eigen_internal_assert(x)
1077#endif
1078
1079#ifdef EIGEN_NO_DEBUG
1080#define EIGEN_ONLY_USED_FOR_DEBUG(x) EIGEN_UNUSED_VARIABLE(x)
1081#else
1082#define EIGEN_ONLY_USED_FOR_DEBUG(x)
1083#endif
1084
1085#ifndef EIGEN_NO_DEPRECATED_WARNING
1086 #if EIGEN_COMP_GNUC
1087 #define EIGEN_DEPRECATED __attribute__((deprecated))
1088 #elif EIGEN_COMP_MSVC
1089 #define EIGEN_DEPRECATED __declspec(deprecated)
1090 #else
1091 #define EIGEN_DEPRECATED
1092 #endif
1093#else
1094 #define EIGEN_DEPRECATED
1095#endif
1096
1097#if EIGEN_COMP_GNUC
1098#define EIGEN_UNUSED __attribute__((unused))
1099#else
1100#define EIGEN_UNUSED
1101#endif
1102
1103// Suppresses 'unused variable' warnings.
1104namespace Eigen {
1105 namespace internal {
1106 template<typename T> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void ignore_unused_variable(const T&) {}
1107 }
1108}
1109#define EIGEN_UNUSED_VARIABLE(var) Eigen::internal::ignore_unused_variable(var);
1110
1111#if !defined(EIGEN_ASM_COMMENT)
1112 #if EIGEN_COMP_GNUC && (EIGEN_ARCH_i386_OR_x86_64 || EIGEN_ARCH_ARM_OR_ARM64)
1113 #define EIGEN_ASM_COMMENT(X) __asm__("#" X)
1114 #else
1115 #define EIGEN_ASM_COMMENT(X)
1116 #endif
1117#endif
1118
1119
1120// Acts as a barrier preventing operations involving `X` from crossing. This
1121// occurs, for example, in the fast rounding trick where a magic constant is
1122// added then subtracted, which is otherwise compiled away with -ffast-math.
1123//
1124// See bug 1674
1125#if !defined(EIGEN_OPTIMIZATION_BARRIER)
1126 #if EIGEN_COMP_GNUC
1127 // According to https://gcc.gnu.org/onlinedocs/gcc/Constraints.html:
1128 // X: Any operand whatsoever.
1129 // r: A register operand is allowed provided that it is in a general
1130 // register.
1131 // g: Any register, memory or immediate integer operand is allowed, except
1132 // for registers that are not general registers.
1133 // w: (AArch32/AArch64) Floating point register, Advanced SIMD vector
1134 // register or SVE vector register.
1135 // x: (SSE) Any SSE register.
1136 // (AArch64) Like w, but restricted to registers 0 to 15 inclusive.
1137 // v: (PowerPC) An Altivec vector register.
1138 // wa:(PowerPC) A VSX register.
1139 //
1140 // "X" (uppercase) should work for all cases, though this seems to fail for
1141 // some versions of GCC for arm/aarch64 with
1142 // "error: inconsistent operand constraints in an 'asm'"
1143 // Clang x86_64/arm/aarch64 seems to require "g" to support both scalars and
1144 // vectors, otherwise
1145 // "error: non-trivial scalar-to-vector conversion, possible invalid
1146 // constraint for vector type"
1147 //
1148 // GCC for ppc64le generates an internal compiler error with x/X/g.
1149 // GCC for AVX generates an internal compiler error with X.
1150 //
1151 // Tested on icc/gcc/clang for sse, avx, avx2, avx512dq
1152 // gcc for arm, aarch64,
1153 // gcc for ppc64le,
1154 // both vectors and scalars.
1155 //
1156 // Note that this is restricted to plain types - this will not work
1157 // directly for std::complex<T>, Eigen::half, Eigen::bfloat16. For these,
1158 // you will need to apply to the underlying POD type.
1159 #if EIGEN_ARCH_PPC && EIGEN_COMP_GNUC_STRICT
1160 // This seems to be broken on clang. Packet4f is loaded into a single
1161 // register rather than a vector, zeroing out some entries. Integer
1162 // types also generate a compile error.
1163 #if EIGEN_OS_MAC
1164 // General, Altivec for Apple (VSX were added in ISA v2.06):
1165 #define EIGEN_OPTIMIZATION_BARRIER(X) __asm__ ("" : "+r,v" (X));
1166 #else
1167 // General, Altivec, VSX otherwise:
1168 #define EIGEN_OPTIMIZATION_BARRIER(X) __asm__ ("" : "+r,v,wa" (X));
1169 #endif
1170 #elif EIGEN_ARCH_ARM_OR_ARM64
1171 // General, NEON.
1172 // Clang doesn't like "r",
1173 // error: non-trivial scalar-to-vector conversion, possible invalid
1174 // constraint for vector type
1175 // GCC < 5 doesn't like "g",
1176 // error: 'asm' operand requires impossible reload
1177 #if EIGEN_COMP_GNUC_STRICT && EIGEN_GNUC_AT_MOST(5, 0)
1178 #define EIGEN_OPTIMIZATION_BARRIER(X) __asm__ ("" : "+r,w" (X));
1179 #else
1180 #define EIGEN_OPTIMIZATION_BARRIER(X) __asm__ ("" : "+g,w" (X));
1181 #endif
1182 #elif EIGEN_ARCH_i386_OR_x86_64
1183 // General, SSE.
1184 #define EIGEN_OPTIMIZATION_BARRIER(X) __asm__ ("" : "+g,x" (X));
1185 #else
1186 // Not implemented for other architectures.
1187 #define EIGEN_OPTIMIZATION_BARRIER(X)
1188 #endif
1189 #else
1190 // Not implemented for other compilers.
1191 #define EIGEN_OPTIMIZATION_BARRIER(X)
1192 #endif
1193#endif
1194
1195#if EIGEN_COMP_MSVC
1196 // NOTE MSVC often gives C4127 warnings with compiletime if statements. See bug 1362.
1197 // This workaround is ugly, but it does the job.
1198# define EIGEN_CONST_CONDITIONAL(cond) (void)0, cond
1199#else
1200# define EIGEN_CONST_CONDITIONAL(cond) cond
1201#endif
1202
1203#ifdef EIGEN_DONT_USE_RESTRICT_KEYWORD
1204 #define EIGEN_RESTRICT
1205#endif
1206#ifndef EIGEN_RESTRICT
1207 #define EIGEN_RESTRICT __restrict
1208#endif
1209
1210
1211#ifndef EIGEN_DEFAULT_IO_FORMAT
1212#ifdef EIGEN_MAKING_DOCS
1213// format used in Eigen's documentation
1214// needed to define it here as escaping characters in CMake add_definition's argument seems very problematic.
1215#define EIGEN_DEFAULT_IO_FORMAT Eigen::IOFormat(3, 0, " ", "\n", "", "")
1216#else
1217#define EIGEN_DEFAULT_IO_FORMAT Eigen::IOFormat()
1218#endif
1219#endif
1220
1221// just an empty macro !
1222#define EIGEN_EMPTY
1223
1224
1225// When compiling CUDA/HIP device code with NVCC or HIPCC
1226// pull in math functions from the global namespace.
1227// In host mode, and when device code is compiled with clang,
1228// use the std versions.
1229#if (defined(EIGEN_CUDA_ARCH) && defined(__NVCC__)) || defined(EIGEN_HIP_DEVICE_COMPILE)
1230 #define EIGEN_USING_STD(FUNC) using ::FUNC;
1231#else
1232 #define EIGEN_USING_STD(FUNC) using std::FUNC;
1233#endif
1234
1235#if EIGEN_COMP_MSVC_STRICT && (EIGEN_COMP_MSVC < 1916 || (EIGEN_COMP_MSVC == 1916 && EIGEN_COMP_NVCC))
1236 // For older MSVC versions, as well as 1900 && CUDA 8, using the base operator is necessary,
1237 // otherwise we get duplicate definition errors
1238 // For later MSVC versions, we require explicit operator= definition, otherwise we get
1239 // use of implicitly deleted operator errors.
1240 // (cf Bugs 920, 1000, 1324, 2291)
1241 #define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
1242 using Base::operator =;
1243#elif EIGEN_COMP_CLANG // workaround clang bug (see http://forum.kde.org/viewtopic.php?f=74&t=102653)
1244 #define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
1245 using Base::operator =; \
1246 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const Derived& other) { Base::operator=(other); return *this; } \
1247 template <typename OtherDerived> \
1248 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const DenseBase<OtherDerived>& other) { Base::operator=(other.derived()); return *this; }
1249#else
1250 #define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
1251 using Base::operator =; \
1252 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const Derived& other) \
1253 { \
1254 Base::operator=(other); \
1255 return *this; \
1256 }
1257#endif
1258
1259
1265#if EIGEN_HAS_CXX11
1266#define EIGEN_DEFAULT_COPY_CONSTRUCTOR(CLASS) EIGEN_DEVICE_FUNC CLASS(const CLASS&) = default;
1267#else
1268#define EIGEN_DEFAULT_COPY_CONSTRUCTOR(CLASS)
1269#endif
1270
1271
1272
1278#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived) \
1279 EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
1280 EIGEN_DEFAULT_COPY_CONSTRUCTOR(Derived)
1281
1289#if EIGEN_HAS_CXX11
1290#define EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(Derived) \
1291 EIGEN_DEVICE_FUNC Derived() = default; \
1292 EIGEN_DEVICE_FUNC ~Derived() = default;
1293#else
1294#define EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(Derived) \
1295 EIGEN_DEVICE_FUNC Derived() {}; \
1296 /* EIGEN_DEVICE_FUNC ~Derived() {}; */
1297#endif
1298
1299
1300
1301
1302
1311#define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived) \
1312 typedef typename Eigen::internal::traits<Derived>::Scalar Scalar; \
1313 typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; \
1314 typedef typename Base::CoeffReturnType CoeffReturnType; \
1315 typedef typename Eigen::internal::ref_selector<Derived>::type Nested; \
1316 typedef typename Eigen::internal::traits<Derived>::StorageKind StorageKind; \
1317 typedef typename Eigen::internal::traits<Derived>::StorageIndex StorageIndex; \
1318 enum CompileTimeTraits \
1319 { RowsAtCompileTime = Eigen::internal::traits<Derived>::RowsAtCompileTime, \
1320 ColsAtCompileTime = Eigen::internal::traits<Derived>::ColsAtCompileTime, \
1321 Flags = Eigen::internal::traits<Derived>::Flags, \
1322 SizeAtCompileTime = Base::SizeAtCompileTime, \
1323 MaxSizeAtCompileTime = Base::MaxSizeAtCompileTime, \
1324 IsVectorAtCompileTime = Base::IsVectorAtCompileTime }; \
1325 using Base::derived; \
1326 using Base::const_cast_derived;
1327
1328
1329// FIXME Maybe the EIGEN_DENSE_PUBLIC_INTERFACE could be removed as importing PacketScalar is rarely needed
1330#define EIGEN_DENSE_PUBLIC_INTERFACE(Derived) \
1331 EIGEN_GENERIC_PUBLIC_INTERFACE(Derived) \
1332 typedef typename Base::PacketScalar PacketScalar;
1333
1334
1335#define EIGEN_PLAIN_ENUM_MIN(a,b) (((int)a <= (int)b) ? (int)a : (int)b)
1336#define EIGEN_PLAIN_ENUM_MAX(a,b) (((int)a >= (int)b) ? (int)a : (int)b)
1337
1338// EIGEN_SIZE_MIN_PREFER_DYNAMIC gives the min between compile-time sizes. 0 has absolute priority, followed by 1,
1339// followed by Dynamic, followed by other finite values. The reason for giving Dynamic the priority over
1340// finite values is that min(3, Dynamic) should be Dynamic, since that could be anything between 0 and 3.
1341#define EIGEN_SIZE_MIN_PREFER_DYNAMIC(a,b) (((int)a == 0 || (int)b == 0) ? 0 \
1342 : ((int)a == 1 || (int)b == 1) ? 1 \
1343 : ((int)a == Dynamic || (int)b == Dynamic) ? Dynamic \
1344 : ((int)a <= (int)b) ? (int)a : (int)b)
1345
1346// EIGEN_SIZE_MIN_PREFER_FIXED is a variant of EIGEN_SIZE_MIN_PREFER_DYNAMIC comparing MaxSizes. The difference is that finite values
1347// now have priority over Dynamic, so that min(3, Dynamic) gives 3. Indeed, whatever the actual value is
1348// (between 0 and 3), it is not more than 3.
1349#define EIGEN_SIZE_MIN_PREFER_FIXED(a,b) (((int)a == 0 || (int)b == 0) ? 0 \
1350 : ((int)a == 1 || (int)b == 1) ? 1 \
1351 : ((int)a == Dynamic && (int)b == Dynamic) ? Dynamic \
1352 : ((int)a == Dynamic) ? (int)b \
1353 : ((int)b == Dynamic) ? (int)a \
1354 : ((int)a <= (int)b) ? (int)a : (int)b)
1355
1356// see EIGEN_SIZE_MIN_PREFER_DYNAMIC. No need for a separate variant for MaxSizes here.
1357#define EIGEN_SIZE_MAX(a,b) (((int)a == Dynamic || (int)b == Dynamic) ? Dynamic \
1358 : ((int)a >= (int)b) ? (int)a : (int)b)
1359
1360#define EIGEN_LOGICAL_XOR(a,b) (((a) || (b)) && !((a) && (b)))
1361
1362#define EIGEN_IMPLIES(a,b) (!(a) || (b))
1363
1364#if EIGEN_HAS_BUILTIN(__builtin_expect) || EIGEN_COMP_GNUC
1365#define EIGEN_PREDICT_FALSE(x) (__builtin_expect(x, false))
1366#define EIGEN_PREDICT_TRUE(x) (__builtin_expect(false || (x), true))
1367#else
1368#define EIGEN_PREDICT_FALSE(x) (x)
1369#define EIGEN_PREDICT_TRUE(x) (x)
1370#endif
1371
1372// the expression type of a standard coefficient wise binary operation
1373#define EIGEN_CWISE_BINARY_RETURN_TYPE(LHS,RHS,OPNAME) \
1374 CwiseBinaryOp< \
1375 EIGEN_CAT(EIGEN_CAT(internal::scalar_,OPNAME),_op)< \
1376 typename internal::traits<LHS>::Scalar, \
1377 typename internal::traits<RHS>::Scalar \
1378 >, \
1379 const LHS, \
1380 const RHS \
1381 >
1382
1383#define EIGEN_MAKE_CWISE_BINARY_OP(METHOD,OPNAME) \
1384 template<typename OtherDerived> \
1385 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const EIGEN_CWISE_BINARY_RETURN_TYPE(Derived,OtherDerived,OPNAME) \
1386 (METHOD)(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const \
1387 { \
1388 return EIGEN_CWISE_BINARY_RETURN_TYPE(Derived,OtherDerived,OPNAME)(derived(), other.derived()); \
1389 }
1390
1391#define EIGEN_SCALAR_BINARY_SUPPORTED(OPNAME,TYPEA,TYPEB) \
1392 (Eigen::internal::has_ReturnType<Eigen::ScalarBinaryOpTraits<TYPEA,TYPEB,EIGEN_CAT(EIGEN_CAT(Eigen::internal::scalar_,OPNAME),_op)<TYPEA,TYPEB> > >::value)
1393
1394#define EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(EXPR,SCALAR,OPNAME) \
1395 CwiseBinaryOp<EIGEN_CAT(EIGEN_CAT(internal::scalar_,OPNAME),_op)<typename internal::traits<EXPR>::Scalar,SCALAR>, const EXPR, \
1396 const typename internal::plain_constant_type<EXPR,SCALAR>::type>
1397
1398#define EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(SCALAR,EXPR,OPNAME) \
1399 CwiseBinaryOp<EIGEN_CAT(EIGEN_CAT(internal::scalar_,OPNAME),_op)<SCALAR,typename internal::traits<EXPR>::Scalar>, \
1400 const typename internal::plain_constant_type<EXPR,SCALAR>::type, const EXPR>
1401
1402// Workaround for MSVC 2010 (see ML thread "patch with compile for for MSVC 2010")
1403#if EIGEN_COMP_MSVC_STRICT && (EIGEN_COMP_MSVC_STRICT<=1600)
1404#define EIGEN_MSVC10_WORKAROUND_BINARYOP_RETURN_TYPE(X) typename internal::enable_if<true,X>::type
1405#else
1406#define EIGEN_MSVC10_WORKAROUND_BINARYOP_RETURN_TYPE(X) X
1407#endif
1408
1409#define EIGEN_MAKE_SCALAR_BINARY_OP_ONTHERIGHT(METHOD,OPNAME) \
1410 template <typename T> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE \
1411 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))\
1412 (METHOD)(const T& scalar) const { \
1413 typedef typename internal::promote_scalar_arg<Scalar,T,EIGEN_SCALAR_BINARY_SUPPORTED(OPNAME,Scalar,T)>::type PromotedT; \
1414 return EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(Derived,PromotedT,OPNAME)(derived(), \
1415 typename internal::plain_constant_type<Derived,PromotedT>::type(derived().rows(), derived().cols(), internal::scalar_constant_op<PromotedT>(scalar))); \
1416 }
1417
1418#define EIGEN_MAKE_SCALAR_BINARY_OP_ONTHELEFT(METHOD,OPNAME) \
1419 template <typename T> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE friend \
1420 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)) \
1421 (METHOD)(const T& scalar, const StorageBaseType& matrix) { \
1422 typedef typename internal::promote_scalar_arg<Scalar,T,EIGEN_SCALAR_BINARY_SUPPORTED(OPNAME,T,Scalar)>::type PromotedT; \
1423 return EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(PromotedT,Derived,OPNAME)( \
1424 typename internal::plain_constant_type<Derived,PromotedT>::type(matrix.derived().rows(), matrix.derived().cols(), internal::scalar_constant_op<PromotedT>(scalar)), matrix.derived()); \
1425 }
1426
1427#define EIGEN_MAKE_SCALAR_BINARY_OP(METHOD,OPNAME) \
1428 EIGEN_MAKE_SCALAR_BINARY_OP_ONTHELEFT(METHOD,OPNAME) \
1429 EIGEN_MAKE_SCALAR_BINARY_OP_ONTHERIGHT(METHOD,OPNAME)
1430
1431
1432#if (defined(_CPPUNWIND) || defined(__EXCEPTIONS)) && !defined(EIGEN_CUDA_ARCH) && !defined(EIGEN_EXCEPTIONS) && !defined(EIGEN_USE_SYCL) && !defined(EIGEN_HIP_DEVICE_COMPILE)
1433 #define EIGEN_EXCEPTIONS
1434#endif
1435
1436
1437#ifdef EIGEN_EXCEPTIONS
1438# define EIGEN_THROW_X(X) throw X
1439# define EIGEN_THROW throw
1440# define EIGEN_TRY try
1441# define EIGEN_CATCH(X) catch (X)
1442#else
1443# if defined(EIGEN_CUDA_ARCH)
1444# define EIGEN_THROW_X(X) asm("trap;")
1445# define EIGEN_THROW asm("trap;")
1446# elif defined(EIGEN_HIP_DEVICE_COMPILE)
1447# define EIGEN_THROW_X(X) asm("s_trap 0")
1448# define EIGEN_THROW asm("s_trap 0")
1449# else
1450# define EIGEN_THROW_X(X) std::abort()
1451# define EIGEN_THROW std::abort()
1452# endif
1453# define EIGEN_TRY if (true)
1454# define EIGEN_CATCH(X) else
1455#endif
1456
1457
1458#if EIGEN_HAS_CXX11_NOEXCEPT
1459# define EIGEN_INCLUDE_TYPE_TRAITS
1460# define EIGEN_NOEXCEPT noexcept
1461# define EIGEN_NOEXCEPT_IF(x) noexcept(x)
1462# define EIGEN_NO_THROW noexcept(true)
1463# define EIGEN_EXCEPTION_SPEC(X) noexcept(false)
1464#else
1465# define EIGEN_NOEXCEPT
1466# define EIGEN_NOEXCEPT_IF(x)
1467# define EIGEN_NO_THROW throw()
1468# if EIGEN_COMP_MSVC || EIGEN_COMP_CXXVER>=17
1469 // MSVC does not support exception specifications (warning C4290),
1470 // and they are deprecated in c++11 anyway. This is even an error in c++17.
1471# define EIGEN_EXCEPTION_SPEC(X) throw()
1472# else
1473# define EIGEN_EXCEPTION_SPEC(X) throw(X)
1474# endif
1475#endif
1476
1477#if EIGEN_HAS_VARIADIC_TEMPLATES
1478// The all function is used to enable a variadic version of eigen_assert which can take a parameter pack as its input.
1479namespace Eigen {
1480namespace internal {
1481
1482inline bool all(){ return true; }
1483
1484template<typename T, typename ...Ts>
1485bool all(T t, Ts ... ts){ return t && all(ts...); }
1486
1487}
1488}
1489#endif
1490
1491#if EIGEN_HAS_CXX11_OVERRIDE_FINAL
1492// provide override and final specifiers if they are available:
1493# define EIGEN_OVERRIDE override
1494# define EIGEN_FINAL final
1495#else
1496# define EIGEN_OVERRIDE
1497# define EIGEN_FINAL
1498#endif
1499
1500// Wrapping #pragma unroll in a macro since it is required for SYCL
1501#if defined(SYCL_DEVICE_ONLY)
1502 #if defined(_MSC_VER)
1503 #define EIGEN_UNROLL_LOOP __pragma(unroll)
1504 #else
1505 #define EIGEN_UNROLL_LOOP _Pragma("unroll")
1506 #endif
1507#else
1508 #define EIGEN_UNROLL_LOOP
1509#endif
1510
1511#endif // EIGEN_MACROS_H
Namespace containing all symbols from the Eigen library.
Definition LDLT.h:16