Macros.h
Go to the documentation of this file.
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 #include "../InternalHeaderCheck.h"
14 
15 //------------------------------------------------------------------------------------------
16 // Eigen version and basic defaults
17 //------------------------------------------------------------------------------------------
18 
19 #define EIGEN_WORLD_VERSION 3
20 #define EIGEN_MAJOR_VERSION 4
21 #define EIGEN_MINOR_VERSION 90
22 
23 #define EIGEN_VERSION_AT_LEAST(x,y,z) (EIGEN_WORLD_VERSION>x || (EIGEN_WORLD_VERSION>=x && \
24  (EIGEN_MAJOR_VERSION>y || (EIGEN_MAJOR_VERSION>=y && \
25  EIGEN_MINOR_VERSION>=z))))
26 
27 #ifdef EIGEN_DEFAULT_TO_ROW_MAJOR
28 #define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION Eigen::RowMajor
29 #else
30 #define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION Eigen::ColMajor
31 #endif
32 
33 #ifndef EIGEN_DEFAULT_DENSE_INDEX_TYPE
34 #define EIGEN_DEFAULT_DENSE_INDEX_TYPE std::ptrdiff_t
35 #endif
36 
37 // Upperbound on the C++ version to use.
38 // Expected values are 03, 11, 14, 17, etc.
39 // By default, let's use an arbitrarily large C++ version.
40 #ifndef EIGEN_MAX_CPP_VER
41 #define EIGEN_MAX_CPP_VER 99
42 #endif
43 
49 #ifndef EIGEN_FAST_MATH
50 #define EIGEN_FAST_MATH 1
51 #endif
52 
53 #ifndef EIGEN_STACK_ALLOCATION_LIMIT
54 // 131072 == 128 KB
55 #define EIGEN_STACK_ALLOCATION_LIMIT 131072
56 #endif
57 
58 //------------------------------------------------------------------------------------------
59 // Compiler identification, EIGEN_COMP_*
60 //------------------------------------------------------------------------------------------
61 
63 #ifdef __GNUC__
64  #define EIGEN_COMP_GNUC (__GNUC__*100+__GNUC_MINOR__*10+__GNUC_PATCHLEVEL__)
65 #else
66  #define EIGEN_COMP_GNUC 0
67 #endif
68 
70 #if defined(__clang__)
71  #define EIGEN_COMP_CLANG (__clang_major__*100+__clang_minor__*10+__clang_patchlevel__)
72 #else
73  #define EIGEN_COMP_CLANG 0
74 #endif
75 
77 #if defined(__clang__) && defined(__apple_build_version__)
78  #define EIGEN_COMP_CLANGAPPLE __apple_build_version__
79 #else
80  #define EIGEN_COMP_CLANGAPPLE 0
81 #endif
82 
84 #if defined(__castxml__)
85  #define EIGEN_COMP_CASTXML 1
86 #else
87  #define EIGEN_COMP_CASTXML 0
88 #endif
89 
91 #if defined(__llvm__)
92  #define EIGEN_COMP_LLVM 1
93 #else
94  #define EIGEN_COMP_LLVM 0
95 #endif
96 
98 #if defined(__INTEL_COMPILER)
99  #define EIGEN_COMP_ICC __INTEL_COMPILER
100 #else
101  #define EIGEN_COMP_ICC 0
102 #endif
103 
105 #if defined(__INTEL_CLANG_COMPILER)
106  #define EIGEN_COMP_CLANGICC __INTEL_CLANG_COMPILER
107 #else
108  #define EIGEN_COMP_CLANGICC 0
109 #endif
110 
112 #if defined(__MINGW32__)
113  #define EIGEN_COMP_MINGW 1
114 #else
115  #define EIGEN_COMP_MINGW 0
116 #endif
117 
119 #if defined(__SUNPRO_CC)
120  #define EIGEN_COMP_SUNCC 1
121 #else
122  #define EIGEN_COMP_SUNCC 0
123 #endif
124 
126 #if defined(_MSC_VER)
127  #define EIGEN_COMP_MSVC _MSC_VER
128 #else
129  #define EIGEN_COMP_MSVC 0
130 #endif
131 
132 #if defined(__NVCC__)
133 #if defined(__CUDACC_VER_MAJOR__) && (__CUDACC_VER_MAJOR__ >= 9)
134  #define EIGEN_COMP_NVCC ((__CUDACC_VER_MAJOR__ * 10000) + (__CUDACC_VER_MINOR__ * 100))
135 #elif defined(__CUDACC_VER__)
136  #define EIGEN_COMP_NVCC __CUDACC_VER__
137 #else
138  #error "NVCC did not define compiler version."
139 #endif
140 #else
141  #define EIGEN_COMP_NVCC 0
142 #endif
143 
144 // For the record, here is a table summarizing the possible values for EIGEN_COMP_MSVC:
145 // name ver MSC_VER
146 // 2015 14 1900
147 // "15" 15 1900
148 // 2017-14.1 15.0 1910
149 // 2017-14.11 15.3 1911
150 // 2017-14.12 15.5 1912
151 // 2017-14.13 15.6 1913
152 // 2017-14.14 15.7 1914
153 // 2017 15.8 1915
154 // 2017 15.9 1916
155 // 2019 RTW 16.0 1920
156 
158 #if defined(_MSVC_LANG)
159  #define EIGEN_COMP_MSVC_LANG _MSVC_LANG
160 #else
161  #define EIGEN_COMP_MSVC_LANG 0
162 #endif
163 
164 // For the record, here is a table summarizing the possible values for EIGEN_COMP_MSVC_LANG:
165 // MSVC option Standard MSVC_LANG
166 // /std:c++14 (default as of VS 2019) C++14 201402L
167 // /std:c++17 C++17 201703L
168 // /std:c++latest >C++17 >201703L
169 
171 #if EIGEN_COMP_MSVC && !(EIGEN_COMP_ICC || EIGEN_COMP_LLVM || EIGEN_COMP_CLANG)
172  #define EIGEN_COMP_MSVC_STRICT _MSC_VER
173 #else
174  #define EIGEN_COMP_MSVC_STRICT 0
175 #endif
176 
178 // XLC version
179 // 3.1 0x0301
180 // 4.5 0x0405
181 // 5.0 0x0500
182 // 12.1 0x0C01
183 #if defined(__IBMCPP__) || defined(__xlc__) || defined(__ibmxl__)
184  #define EIGEN_COMP_IBM __xlC__
185 #else
186  #define EIGEN_COMP_IBM 0
187 #endif
188 
190 #if defined(__PGI)
191  #define EIGEN_COMP_PGI (__PGIC__*100+__PGIC_MINOR__)
192 #else
193  #define EIGEN_COMP_PGI 0
194 #endif
195 
197 #if defined(__CC_ARM) || defined(__ARMCC_VERSION)
198  #define EIGEN_COMP_ARM 1
199 #else
200  #define EIGEN_COMP_ARM 0
201 #endif
202 
204 #if defined(__EMSCRIPTEN__)
205  #define EIGEN_COMP_EMSCRIPTEN 1
206 #else
207  #define EIGEN_COMP_EMSCRIPTEN 0
208 #endif
209 
213 #if defined(__FUJITSU)
214  #define EIGEN_COMP_FCC (__FCC_major__*100+__FCC_minor__*10+__FCC_patchlevel__)
215 #else
216  #define EIGEN_COMP_FCC 0
217 #endif
218 
222 #if defined(__CLANG_FUJITSU)
223  #define EIGEN_COMP_CLANGFCC (__FCC_major__*100+__FCC_minor__*10+__FCC_patchlevel__)
224 #else
225  #define EIGEN_COMP_CLANGFCC 0
226 #endif
227 
231 #if defined(_CRAYC) && !defined(__clang__)
232  #define EIGEN_COMP_CPE (_RELEASE_MAJOR*100+_RELEASE_MINOR*10+_RELEASE_PATCHLEVEL)
233 #else
234  #define EIGEN_COMP_CPE 0
235 #endif
236 
240 #if defined(_CRAYC) && defined(__clang__)
241  #define EIGEN_COMP_CLANGCPE (_RELEASE_MAJOR*100+_RELEASE_MINOR*10+_RELEASE_PATCHLEVEL)
242 #else
243  #define EIGEN_COMP_CLANGCPE 0
244 #endif
245 
247 #if defined(__LCC__) && defined(__MCST__)
248  #define EIGEN_COMP_LCC (__LCC__*100+__LCC_MINOR__)
249 #else
250  #define EIGEN_COMP_LCC 0
251 #endif
252 
253 
255 #if EIGEN_COMP_GNUC && !(EIGEN_COMP_CLANG || EIGEN_COMP_ICC || EIGEN_COMP_CLANGICC || EIGEN_COMP_MINGW || EIGEN_COMP_PGI || EIGEN_COMP_IBM || EIGEN_COMP_ARM || EIGEN_COMP_EMSCRIPTEN || EIGEN_COMP_FCC || EIGEN_COMP_CLANGFCC || EIGEN_COMP_CPE || EIGEN_COMP_CLANGCPE || EIGEN_COMP_LCC)
256  #define EIGEN_COMP_GNUC_STRICT 1
257 #else
258  #define EIGEN_COMP_GNUC_STRICT 0
259 #endif
260 
261 // GCC, and compilers that pretend to be it, have different version schemes, so this only makes sense to use with the real GCC.
262 #if EIGEN_COMP_GNUC_STRICT
263  #define EIGEN_GNUC_STRICT_AT_LEAST(x,y,z) ((__GNUC__ > x) || \
264  (__GNUC__ == x && __GNUC_MINOR__ > y) || \
265  (__GNUC__ == x && __GNUC_MINOR__ == y && __GNUC_PATCHLEVEL__ >= z))
266  #define EIGEN_GNUC_STRICT_LESS_THAN(x,y,z) ((__GNUC__ < x) || \
267  (__GNUC__ == x && __GNUC_MINOR__ < y) || \
268  (__GNUC__ == x && __GNUC_MINOR__ == y && __GNUC_PATCHLEVEL__ < z))
269 #else
270  #define EIGEN_GNUC_STRICT_AT_LEAST(x,y,z) 0
271  #define EIGEN_GNUC_STRICT_LESS_THAN(x,y,z) 0
272 #endif
273 
274 
275 
277 #if EIGEN_COMP_CLANG && !(EIGEN_COMP_CLANGAPPLE || EIGEN_COMP_CLANGICC || EIGEN_COMP_CLANGFCC || EIGEN_COMP_CLANGCPE)
278  #define EIGEN_COMP_CLANG_STRICT 1
279 #else
280  #define EIGEN_COMP_CLANG_STRICT 0
281 #endif
282 
283 // Clang, and compilers forked from it, have different version schemes, so this only makes sense to use with the real Clang.
284 #if EIGEN_COMP_CLANG_STRICT
285  #define EIGEN_CLANG_STRICT_AT_LEAST(x,y,z) ((__clang_major__ > x) || \
286  (__clang_major__ == x && __clang_minor__ > y) || \
287  (__clang_major__ == x && __clang_minor__ == y && __clang_patchlevel__ >= z))
288  #define EIGEN_CLANG_STRICT_LESS_THAN(x,y,z) ((__clang_major__ < x) || \
289  (__clang_major__ == x && __clang_minor__ < y) || \
290  (__clang_major__ == x && __clang_minor__ == y && __clang_patchlevel__ < z))
291 #else
292  #define EIGEN_CLANG_STRICT_AT_LEAST(x,y,z) 0
293  #define EIGEN_CLANG_STRICT_LESS_THAN(x,y,z) 0
294 #endif
295 
296 //------------------------------------------------------------------------------------------
297 // Architecture identification, EIGEN_ARCH_*
298 //------------------------------------------------------------------------------------------
299 
300 
301 #if defined(__x86_64__) || (defined(_M_X64) && !defined(_M_ARM64EC)) || defined(__amd64)
302  #define EIGEN_ARCH_x86_64 1
303 #else
304  #define EIGEN_ARCH_x86_64 0
305 #endif
306 
307 #if defined(__i386__) || defined(_M_IX86) || defined(_X86_) || defined(__i386)
308  #define EIGEN_ARCH_i386 1
309 #else
310  #define EIGEN_ARCH_i386 0
311 #endif
312 
313 #if EIGEN_ARCH_x86_64 || EIGEN_ARCH_i386
314  #define EIGEN_ARCH_i386_OR_x86_64 1
315 #else
316  #define EIGEN_ARCH_i386_OR_x86_64 0
317 #endif
318 
320 #if defined(__arm__)
321  #define EIGEN_ARCH_ARM 1
322 #else
323  #define EIGEN_ARCH_ARM 0
324 #endif
325 
327 #if defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
328  #define EIGEN_ARCH_ARM64 1
329 #else
330  #define EIGEN_ARCH_ARM64 0
331 #endif
332 
334 #if EIGEN_ARCH_ARM || EIGEN_ARCH_ARM64
335  #define EIGEN_ARCH_ARM_OR_ARM64 1
336 #else
337  #define EIGEN_ARCH_ARM_OR_ARM64 0
338 #endif
339 
341 #if EIGEN_ARCH_ARM_OR_ARM64 && defined(__ARM_ARCH) && __ARM_ARCH >= 8
342 #define EIGEN_ARCH_ARMV8 1
343 #else
344 #define EIGEN_ARCH_ARMV8 0
345 #endif
346 
347 
350 #if EIGEN_ARCH_ARM_OR_ARM64
351  #ifndef EIGEN_HAS_ARM64_FP16
352  #if defined(__ARM_FP16_FORMAT_IEEE)
353  #define EIGEN_HAS_ARM64_FP16 1
354  #else
355  #define EIGEN_HAS_ARM64_FP16 0
356  #endif
357  #endif
358 #endif
359 
361 #if defined(__mips__) || defined(__mips)
362  #define EIGEN_ARCH_MIPS 1
363 #else
364  #define EIGEN_ARCH_MIPS 0
365 #endif
366 
368 #if defined(__sparc__) || defined(__sparc)
369  #define EIGEN_ARCH_SPARC 1
370 #else
371  #define EIGEN_ARCH_SPARC 0
372 #endif
373 
375 #if defined(__ia64__)
376  #define EIGEN_ARCH_IA64 1
377 #else
378  #define EIGEN_ARCH_IA64 0
379 #endif
380 
382 #if defined(__powerpc__) || defined(__ppc__) || defined(_M_PPC) || defined(__POWERPC__)
383  #define EIGEN_ARCH_PPC 1
384 #else
385  #define EIGEN_ARCH_PPC 0
386 #endif
387 
388 
389 
390 //------------------------------------------------------------------------------------------
391 // Operating system identification, EIGEN_OS_*
392 //------------------------------------------------------------------------------------------
393 
395 #if defined(__unix__) || defined(__unix)
396  #define EIGEN_OS_UNIX 1
397 #else
398  #define EIGEN_OS_UNIX 0
399 #endif
400 
402 #if defined(__linux__)
403  #define EIGEN_OS_LINUX 1
404 #else
405  #define EIGEN_OS_LINUX 0
406 #endif
407 
409 // note: ANDROID is defined when using ndk_build, __ANDROID__ is defined when using a standalone toolchain.
410 #if defined(__ANDROID__) || defined(ANDROID)
411  #define EIGEN_OS_ANDROID 1
412 #else
413  #define EIGEN_OS_ANDROID 0
414 #endif
415 
417 #if defined(__gnu_linux__) && !(EIGEN_OS_ANDROID)
418  #define EIGEN_OS_GNULINUX 1
419 #else
420  #define EIGEN_OS_GNULINUX 0
421 #endif
422 
424 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__)
425  #define EIGEN_OS_BSD 1
426 #else
427  #define EIGEN_OS_BSD 0
428 #endif
429 
431 #if defined(__APPLE__)
432  #define EIGEN_OS_MAC 1
433 #else
434  #define EIGEN_OS_MAC 0
435 #endif
436 
438 #if defined(__QNX__)
439  #define EIGEN_OS_QNX 1
440 #else
441  #define EIGEN_OS_QNX 0
442 #endif
443 
445 #if defined(_WIN32)
446  #define EIGEN_OS_WIN 1
447 #else
448  #define EIGEN_OS_WIN 0
449 #endif
450 
452 #if defined(_WIN64)
453  #define EIGEN_OS_WIN64 1
454 #else
455  #define EIGEN_OS_WIN64 0
456 #endif
457 
459 #if defined(_WIN32_WCE)
460  #define EIGEN_OS_WINCE 1
461 #else
462  #define EIGEN_OS_WINCE 0
463 #endif
464 
466 #if defined(__CYGWIN__)
467  #define EIGEN_OS_CYGWIN 1
468 #else
469  #define EIGEN_OS_CYGWIN 0
470 #endif
471 
473 #if EIGEN_OS_WIN && !( EIGEN_OS_WINCE || EIGEN_OS_CYGWIN )
474  #define EIGEN_OS_WIN_STRICT 1
475 #else
476  #define EIGEN_OS_WIN_STRICT 0
477 #endif
478 
480 // compiler solaris __SUNPRO_C
481 // version studio
482 // 5.7 10 0x570
483 // 5.8 11 0x580
484 // 5.9 12 0x590
485 // 5.10 12.1 0x5100
486 // 5.11 12.2 0x5110
487 // 5.12 12.3 0x5120
488 #if (defined(sun) || defined(__sun)) && !(defined(__SVR4) || defined(__svr4__))
489  #define EIGEN_OS_SUN __SUNPRO_C
490 #else
491  #define EIGEN_OS_SUN 0
492 #endif
493 
495 #if (defined(sun) || defined(__sun)) && (defined(__SVR4) || defined(__svr4__))
496  #define EIGEN_OS_SOLARIS 1
497 #else
498  #define EIGEN_OS_SOLARIS 0
499 #endif
500 
501 
502 //------------------------------------------------------------------------------------------
503 // Detect GPU compilers and architectures
504 //------------------------------------------------------------------------------------------
505 
506 // NVCC is not supported as the target platform for HIPCC
507 // Note that this also makes EIGEN_CUDACC and EIGEN_HIPCC mutually exclusive
508 #if defined(__NVCC__) && defined(__HIPCC__)
509  #error "NVCC as the target platform for HIPCC is currently not supported."
510 #endif
511 
512 #if defined(__CUDACC__) && !defined(EIGEN_NO_CUDA) && !defined(__SYCL_DEVICE_ONLY__)
513  // Means the compiler is either nvcc or clang with CUDA enabled
514  #define EIGEN_CUDACC __CUDACC__
515 #endif
516 
517 #if defined(__CUDA_ARCH__) && !defined(EIGEN_NO_CUDA) && !defined(__SYCL_DEVICE_ONLY__)
518  // Means we are generating code for the device
519  #define EIGEN_CUDA_ARCH __CUDA_ARCH__
520 #endif
521 
522 #if defined(EIGEN_CUDACC)
523 #include <cuda.h>
524  #define EIGEN_CUDA_SDK_VER (CUDA_VERSION * 10)
525 #else
526  #define EIGEN_CUDA_SDK_VER 0
527 #endif
528 
529 #if defined(__HIPCC__) && !defined(EIGEN_NO_HIP) && !defined(__SYCL_DEVICE_ONLY__)
530  // Means the compiler is HIPCC (analogous to EIGEN_CUDACC, but for HIP)
531  #define EIGEN_HIPCC __HIPCC__
532 
533  // We need to include hip_runtime.h here because it pulls in
534  // ++ hip_common.h which contains the define for __HIP_DEVICE_COMPILE__
535  // ++ host_defines.h which contains the defines for the __host__ and __device__ macros
536  #include <hip/hip_runtime.h>
537 
538  #if defined(__HIP_DEVICE_COMPILE__) && !defined(__SYCL_DEVICE_ONLY__)
539  // analogous to EIGEN_CUDA_ARCH, but for HIP
540  #define EIGEN_HIP_DEVICE_COMPILE __HIP_DEVICE_COMPILE__
541  #endif
542 
543  // For HIP (ROCm 3.5 and higher), we need to explicitly set the launch_bounds attribute
544  // value to 1024. The compiler assigns a default value of 256 when the attribute is not
545  // specified. This results in failures on the HIP platform, for cases when a GPU kernel
546  // without an explicit launch_bounds attribute is called with a threads_per_block value
547  // greater than 256.
548  //
549  // This is a regression in functioanlity and is expected to be fixed within the next
550  // couple of ROCm releases (compiler will go back to using 1024 value as the default)
551  //
552  // In the meantime, we will use a "only enabled for HIP" macro to set the launch_bounds
553  // attribute.
554 
555  #define EIGEN_HIP_LAUNCH_BOUNDS_1024 __launch_bounds__(1024)
556 
557 #endif
558 
559 #if !defined(EIGEN_HIP_LAUNCH_BOUNDS_1024)
560 #define EIGEN_HIP_LAUNCH_BOUNDS_1024
561 #endif // !defined(EIGEN_HIP_LAUNCH_BOUNDS_1024)
562 
563 // Unify CUDA/HIPCC
564 
565 #if defined(EIGEN_CUDACC) || defined(EIGEN_HIPCC)
566 //
567 // If either EIGEN_CUDACC or EIGEN_HIPCC is defined, then define EIGEN_GPUCC
568 //
569 #define EIGEN_GPUCC
570 //
571 // EIGEN_HIPCC implies the HIP compiler and is used to tweak Eigen code for use in HIP kernels
572 // EIGEN_CUDACC implies the CUDA compiler and is used to tweak Eigen code for use in CUDA kernels
573 //
574 // In most cases the same tweaks are required to the Eigen code to enable in both the HIP and CUDA kernels.
575 // For those cases, the corresponding code should be guarded with
576 // #if defined(EIGEN_GPUCC)
577 // instead of
578 // #if defined(EIGEN_CUDACC) || defined(EIGEN_HIPCC)
579 //
580 // For cases where the tweak is specific to HIP, the code should be guarded with
581 // #if defined(EIGEN_HIPCC)
582 //
583 // For cases where the tweak is specific to CUDA, the code should be guarded with
584 // #if defined(EIGEN_CUDACC)
585 //
586 #endif
587 
588 #if defined(EIGEN_CUDA_ARCH) || defined(EIGEN_HIP_DEVICE_COMPILE)
589 //
590 // If either EIGEN_CUDA_ARCH or EIGEN_HIP_DEVICE_COMPILE is defined, then define EIGEN_GPU_COMPILE_PHASE
591 //
592 #define EIGEN_GPU_COMPILE_PHASE
593 //
594 // GPU compilers (HIPCC, NVCC) typically do two passes over the source code,
595 // + one to compile the source for the "host" (ie CPU)
596 // + another to compile the source for the "device" (ie. GPU)
597 //
598 // Code that needs to enabled only during the either the "host" or "device" compilation phase
599 // needs to be guarded with a macro that indicates the current compilation phase
600 //
601 // EIGEN_HIP_DEVICE_COMPILE implies the device compilation phase in HIP
602 // EIGEN_CUDA_ARCH implies the device compilation phase in CUDA
603 //
604 // In most cases, the "host" / "device" specific code is the same for both HIP and CUDA
605 // For those cases, the code should be guarded with
606 // #if defined(EIGEN_GPU_COMPILE_PHASE)
607 // instead of
608 // #if defined(EIGEN_CUDA_ARCH) || defined(EIGEN_HIP_DEVICE_COMPILE)
609 //
610 // For cases where the tweak is specific to HIP, the code should be guarded with
611 // #if defined(EIGEN_HIP_DEVICE_COMPILE)
612 //
613 // For cases where the tweak is specific to CUDA, the code should be guarded with
614 // #if defined(EIGEN_CUDA_ARCH)
615 //
616 #endif
617 
620 #if EIGEN_ARCH_ARM_OR_ARM64
621  #ifndef EIGEN_HAS_ARM64_FP16_VECTOR_ARITHMETIC
622  // Clang only supports FP16 on aarch64, and not all intrinsics are available
623  // on A32 anyways even in GCC (e.g. vdiv_f16, vsqrt_f16).
624  #if EIGEN_ARCH_ARM64 && defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) && !defined(EIGEN_GPU_COMPILE_PHASE)
625  #define EIGEN_HAS_ARM64_FP16_VECTOR_ARITHMETIC 1
626  #else
627  #define EIGEN_HAS_ARM64_FP16_VECTOR_ARITHMETIC 0
628  #endif
629  #endif
630 #endif
631 
634 #if EIGEN_ARCH_ARM_OR_ARM64
635  #ifndef EIGEN_HAS_ARM64_FP16_SCALAR_ARITHMETIC
636  // Clang only supports FP16 on aarch64, and not all intrinsics are available
637  // on A32 anyways, even in GCC (e.g. vceqh_f16).
638  #if EIGEN_ARCH_ARM64 && defined(__ARM_FEATURE_FP16_SCALAR_ARITHMETIC) && !defined(EIGEN_GPU_COMPILE_PHASE)
639  #define EIGEN_HAS_ARM64_FP16_SCALAR_ARITHMETIC 1
640  #endif
641  #endif
642 #endif
643 
644 #if defined(EIGEN_USE_SYCL) && defined(__SYCL_DEVICE_ONLY__)
645 // EIGEN_USE_SYCL is a user-defined macro while __SYCL_DEVICE_ONLY__ is a compiler-defined macro.
646 // In most cases we want to check if both macros are defined which can be done using the define below.
647 #define SYCL_DEVICE_ONLY
648 #endif
649 
650 //------------------------------------------------------------------------------------------
651 // Detect Compiler/Architecture/OS specific features
652 //------------------------------------------------------------------------------------------
653 
654 // Cross compiler wrapper around LLVM's __has_builtin
655 #ifdef __has_builtin
656 # define EIGEN_HAS_BUILTIN(x) __has_builtin(x)
657 #else
658 # define EIGEN_HAS_BUILTIN(x) 0
659 #endif
660 
661 // A Clang feature extension to determine compiler features.
662 // We use it to determine 'cxx_rvalue_references'
663 #ifndef __has_feature
664 # define __has_feature(x) 0
665 #endif
666 
667 // The macro EIGEN_CPLUSPLUS is a replacement for __cplusplus/_MSVC_LANG that
668 // works for both platforms, indicating the C++ standard version number.
669 //
670 // With MSVC, without defining /Zc:__cplusplus, the __cplusplus macro will
671 // report 199711L regardless of the language standard specified via /std.
672 // We need to rely on _MSVC_LANG instead, which is only available after
673 // VS2015.3.
674 #if EIGEN_COMP_MSVC_LANG > 0
675 #define EIGEN_CPLUSPLUS EIGEN_COMP_MSVC_LANG
676 #elif EIGEN_COMP_MSVC >= 1900
677 #define EIGEN_CPLUSPLUS 201103L
678 #elif defined(__cplusplus)
679 #define EIGEN_CPLUSPLUS __cplusplus
680 #else
681 #define EIGEN_CPLUSPLUS 0
682 #endif
683 
684 // The macro EIGEN_COMP_CXXVER defines the c++ version expected by the compiler.
685 // For instance, if compiling with gcc and -std=c++17, then EIGEN_COMP_CXXVER
686 // is defined to 17.
687 #if EIGEN_CPLUSPLUS >= 202002L
688  #define EIGEN_COMP_CXXVER 20
689 #elif EIGEN_CPLUSPLUS >= 201703L
690  #define EIGEN_COMP_CXXVER 17
691 #elif EIGEN_CPLUSPLUS >= 201402L
692  #define EIGEN_COMP_CXXVER 14
693 #elif EIGEN_CPLUSPLUS >= 201103L
694  #define EIGEN_COMP_CXXVER 11
695 #else
696  #define EIGEN_COMP_CXXVER 03
697 #endif
698 
699 
700 // The macros EIGEN_HAS_CXX?? defines a rough estimate of available c++ features
701 // but in practice we should not rely on them but rather on the availability of
702 // individual features as defined later.
703 // This is why there is no EIGEN_HAS_CXX17.
704 #if EIGEN_MAX_CPP_VER < 14 || EIGEN_COMP_CXXVER < 14 || \
705  (EIGEN_COMP_MSVC && EIGEN_COMP_MSVC < 1900) || \
706  (EIGEN_COMP_ICC && EIGEN_COMP_ICC < 1500) || \
707  (EIGEN_COMP_NVCC && EIGEN_COMP_NVCC < 80000) || \
708  (EIGEN_COMP_CLANG_STRICT && EIGEN_COMP_CLANG < 390) || \
709  (EIGEN_COMP_CLANGAPPLE && EIGEN_COMP_CLANGAPPLE < 9000000) || \
710  (EIGEN_COMP_GNUC_STRICT && EIGEN_COMP_GNUC < 510)
711 #error This compiler appears to be too old to be supported by Eigen
712 #endif
713 
714 // Does the compiler support C99?
715 // Need to include <cmath> to make sure _GLIBCXX_USE_C99 gets defined
716 #include <cmath>
717 #ifndef EIGEN_HAS_C99_MATH
718 #if ((defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)) \
719  || (defined(__GNUC__) && defined(_GLIBCXX_USE_C99)) \
720  || (defined(_LIBCPP_VERSION) && !defined(_MSC_VER)) \
721  || (EIGEN_COMP_MSVC) || defined(SYCL_DEVICE_ONLY))
722  #define EIGEN_HAS_C99_MATH 1
723 #else
724  #define EIGEN_HAS_C99_MATH 0
725 #endif
726 #endif
727 
728 // Does the compiler support std::hash?
729 #ifndef EIGEN_HAS_STD_HASH
730 // The std::hash struct is defined in C++11 but is not labelled as a __device__
731 // function and is not constexpr, so cannot be used on device.
732 #if !defined(EIGEN_GPU_COMPILE_PHASE)
733 #define EIGEN_HAS_STD_HASH 1
734 #else
735 #define EIGEN_HAS_STD_HASH 0
736 #endif
737 #endif // EIGEN_HAS_STD_HASH
738 
739 #ifndef EIGEN_HAS_STD_INVOKE_RESULT
740 #if EIGEN_MAX_CPP_VER >= 17 && EIGEN_COMP_CXXVER >= 17
741 #define EIGEN_HAS_STD_INVOKE_RESULT 1
742 #else
743 #define EIGEN_HAS_STD_INVOKE_RESULT 0
744 #endif
745 #endif
746 
747 #define EIGEN_CONSTEXPR constexpr
748 
749 // NOTE: the required Apple's clang version is very conservative
750 // and it could be that XCode 9 works just fine.
751 // NOTE: the MSVC version is based on https://en.cppreference.com/w/cpp/compiler_support
752 // and not tested.
753 // NOTE: Intel C++ Compiler Classic (icc) Version 19.0 and later supports dynamic allocation
754 // for over-aligned data, but not in a manner that is compatible with Eigen.
755 // See https://gitlab.com/libeigen/eigen/-/issues/2575
756 #ifndef EIGEN_HAS_CXX17_OVERALIGN
757 #if EIGEN_MAX_CPP_VER>=17 && EIGEN_COMP_CXXVER>=17 && ( \
758  (EIGEN_COMP_MSVC >= 1912) \
759  || (EIGEN_GNUC_STRICT_AT_LEAST(7,0,0)) \
760  || (EIGEN_CLANG_STRICT_AT_LEAST(5,0,0)) \
761  || (EIGEN_COMP_CLANGAPPLE && EIGEN_COMP_CLANGAPPLE >= 10000000) \
762  ) && !EIGEN_COMP_ICC
763 #define EIGEN_HAS_CXX17_OVERALIGN 1
764 #else
765 #define EIGEN_HAS_CXX17_OVERALIGN 0
766 #endif
767 #endif
768 
769 #if defined(EIGEN_CUDACC)
770  // While available already with c++11, this is useful mostly starting with c++14 and relaxed constexpr rules
771  #if defined(__NVCC__)
772  // nvcc considers constexpr functions as __host__ __device__ with the option --expt-relaxed-constexpr
773  #ifdef __CUDACC_RELAXED_CONSTEXPR__
774  #define EIGEN_CONSTEXPR_ARE_DEVICE_FUNC
775  #endif
776  #elif defined(__clang__) && defined(__CUDA__) && __has_feature(cxx_relaxed_constexpr)
777  // clang++ always considers constexpr functions as implicitly __host__ __device__
778  #define EIGEN_CONSTEXPR_ARE_DEVICE_FUNC
779  #endif
780 #endif
781 
782 // Does the compiler support the __int128 and __uint128_t extensions for 128-bit
783 // integer arithmetic?
784 //
785 // Clang and GCC define __SIZEOF_INT128__ when these extensions are supported,
786 // but we avoid using them in certain cases:
787 //
788 // * Building using Clang for Windows, where the Clang runtime library has
789 // 128-bit support only on LP64 architectures, but Windows is LLP64.
790 #ifndef EIGEN_HAS_BUILTIN_INT128
791 #if defined(__SIZEOF_INT128__) && !(EIGEN_OS_WIN && EIGEN_COMP_CLANG)
792 #define EIGEN_HAS_BUILTIN_INT128 1
793 #else
794 #define EIGEN_HAS_BUILTIN_INT128 0
795 #endif
796 #endif
797 
798 //------------------------------------------------------------------------------------------
799 // Preprocessor programming helpers
800 //------------------------------------------------------------------------------------------
801 
802 // This macro can be used to prevent from macro expansion, e.g.:
803 // std::max EIGEN_NOT_A_MACRO(a,b)
804 #define EIGEN_NOT_A_MACRO
805 
806 #define EIGEN_DEBUG_VAR(x) std::cerr << #x << " = " << x << std::endl;
807 
808 // concatenate two tokens
809 #define EIGEN_CAT2(a,b) a ## b
810 #define EIGEN_CAT(a,b) EIGEN_CAT2(a,b)
811 
812 #define EIGEN_COMMA ,
813 
814 // convert a token to a string
815 #define EIGEN_MAKESTRING2(a) #a
816 #define EIGEN_MAKESTRING(a) EIGEN_MAKESTRING2(a)
817 
818 // EIGEN_STRONG_INLINE is a stronger version of the inline, using __forceinline on MSVC,
819 // but it still doesn't use GCC's always_inline. This is useful in (common) situations where MSVC needs forceinline
820 // but GCC is still doing fine with just inline.
821 #ifndef EIGEN_STRONG_INLINE
822 #if (EIGEN_COMP_MSVC || EIGEN_COMP_ICC) && !defined(EIGEN_GPUCC)
823 #define EIGEN_STRONG_INLINE __forceinline
824 #else
825 #define EIGEN_STRONG_INLINE inline
826 #endif
827 #endif
828 
829 // EIGEN_ALWAYS_INLINE is the strongest, it has the effect of making the function inline and adding every possible
830 // attribute to maximize inlining. This should only be used when really necessary: in particular,
831 // it uses __attribute__((always_inline)) on GCC, which most of the time is useless and can severely harm compile times.
832 // FIXME with the always_inline attribute,
833 #if EIGEN_COMP_GNUC && !defined(SYCL_DEVICE_ONLY)
834 #define EIGEN_ALWAYS_INLINE __attribute__((always_inline)) inline
835 #else
836 #define EIGEN_ALWAYS_INLINE EIGEN_STRONG_INLINE
837 #endif
838 
839 #if EIGEN_COMP_GNUC
840 #define EIGEN_DONT_INLINE __attribute__((noinline))
841 #elif EIGEN_COMP_MSVC
842 #define EIGEN_DONT_INLINE __declspec(noinline)
843 #else
844 #define EIGEN_DONT_INLINE
845 #endif
846 
847 #if EIGEN_COMP_GNUC
848 #define EIGEN_PERMISSIVE_EXPR __extension__
849 #else
850 #define EIGEN_PERMISSIVE_EXPR
851 #endif
852 
853 // GPU stuff
854 
855 // Disable some features when compiling with GPU compilers (SYCL/HIPCC)
856 #if defined(SYCL_DEVICE_ONLY) || defined(EIGEN_HIP_DEVICE_COMPILE)
857  // Do not try asserts on device code
858  #ifndef EIGEN_NO_DEBUG
859  #define EIGEN_NO_DEBUG
860  #endif
861 
862  #ifdef EIGEN_INTERNAL_DEBUGGING
863  #undef EIGEN_INTERNAL_DEBUGGING
864  #endif
865 #endif
866 
867 // No exceptions on device.
868 #if defined(SYCL_DEVICE_ONLY) || defined(EIGEN_GPU_COMPILE_PHASE)
869  #ifdef EIGEN_EXCEPTIONS
870  #undef EIGEN_EXCEPTIONS
871  #endif
872 #endif
873 
874 #if defined(SYCL_DEVICE_ONLY)
875  #ifndef EIGEN_DONT_VECTORIZE
876  #define EIGEN_DONT_VECTORIZE
877  #endif
878  #define EIGEN_DEVICE_FUNC __attribute__((flatten)) __attribute__((always_inline))
879 // All functions callable from CUDA/HIP code must be qualified with __device__
880 #elif defined(EIGEN_GPUCC)
881  #define EIGEN_DEVICE_FUNC __host__ __device__
882 #else
883  #define EIGEN_DEVICE_FUNC
884 #endif
885 
886 
887 // this macro allows to get rid of linking errors about multiply defined functions.
888 // - static is not very good because it prevents definitions from different object files to be merged.
889 // So static causes the resulting linked executable to be bloated with multiple copies of the same function.
890 // - inline is not perfect either as it unwantedly hints the compiler toward inlining the function.
891 #define EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_DEVICE_FUNC
892 #define EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_DEVICE_FUNC inline
893 
894 #ifdef NDEBUG
895 # ifndef EIGEN_NO_DEBUG
896 # define EIGEN_NO_DEBUG
897 # endif
898 #endif
899 
900 // eigen_assert can be overridden
901 #ifndef eigen_assert
902 #define eigen_assert(x) eigen_plain_assert(x)
903 #endif
904 
905 #ifdef EIGEN_INTERNAL_DEBUGGING
906 #define eigen_internal_assert(x) eigen_assert(x)
907 #else
908 #define eigen_internal_assert(x) ((void)0)
909 #endif
910 
911 #if defined(EIGEN_NO_DEBUG) || (defined(EIGEN_GPU_COMPILE_PHASE) && defined(EIGEN_NO_DEBUG_GPU))
912 #define EIGEN_ONLY_USED_FOR_DEBUG(x) EIGEN_UNUSED_VARIABLE(x)
913 #else
914 #define EIGEN_ONLY_USED_FOR_DEBUG(x)
915 #endif
916 
917 #ifndef EIGEN_NO_DEPRECATED_WARNING
918  #if EIGEN_COMP_GNUC
919  #define EIGEN_DEPRECATED __attribute__((deprecated))
920  #elif EIGEN_COMP_MSVC
921  #define EIGEN_DEPRECATED __declspec(deprecated)
922  #else
923  #define EIGEN_DEPRECATED
924  #endif
925 #else
926  #define EIGEN_DEPRECATED
927 #endif
928 
929 #if EIGEN_COMP_GNUC
930 #define EIGEN_UNUSED __attribute__((unused))
931 #else
932 #define EIGEN_UNUSED
933 #endif
934 
935 #if EIGEN_COMP_GNUC
936  #define EIGEN_PRAGMA(tokens) _Pragma(#tokens)
937  #define EIGEN_DIAGNOSTICS(tokens) EIGEN_PRAGMA(GCC diagnostic tokens)
938  #define EIGEN_DIAGNOSTICS_OFF(msc, gcc) EIGEN_DIAGNOSTICS(gcc)
939 #elif EIGEN_COMP_MSVC
940  #define EIGEN_PRAGMA(tokens) __pragma(tokens)
941  #define EIGEN_DIAGNOSTICS(tokens) EIGEN_PRAGMA(warning(tokens))
942  #define EIGEN_DIAGNOSTICS_OFF(msc, gcc) EIGEN_DIAGNOSTICS(msc)
943 #else
944  #define EIGEN_PRAGMA(tokens)
945  #define EIGEN_DIAGNOSTICS(tokens)
946  #define EIGEN_DIAGNOSTICS_OFF(msc, gcc)
947 #endif
948 
949 #define EIGEN_DISABLE_DEPRECATED_WARNING EIGEN_DIAGNOSTICS_OFF(disable : 4996, ignored "-Wdeprecated-declarations")
950 
951 // Suppresses 'unused variable' warnings.
952 namespace Eigen {
953  namespace internal {
954  template<typename T> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr void ignore_unused_variable(const T&) {}
955  }
956 }
957 #define EIGEN_UNUSED_VARIABLE(var) Eigen::internal::ignore_unused_variable(var);
958 
959 #if !defined(EIGEN_ASM_COMMENT)
960  #if EIGEN_COMP_GNUC && (EIGEN_ARCH_i386_OR_x86_64 || EIGEN_ARCH_ARM_OR_ARM64)
961  #define EIGEN_ASM_COMMENT(X) __asm__("#" X)
962  #else
963  #define EIGEN_ASM_COMMENT(X)
964  #endif
965 #endif
966 
967 
968 // Acts as a barrier preventing operations involving `X` from crossing. This
969 // occurs, for example, in the fast rounding trick where a magic constant is
970 // added then subtracted, which is otherwise compiled away with -ffast-math.
971 //
972 // See bug 1674
973 #if !defined(EIGEN_OPTIMIZATION_BARRIER)
974  #if EIGEN_COMP_GNUC
975  // According to https://gcc.gnu.org/onlinedocs/gcc/Constraints.html:
976  // X: Any operand whatsoever.
977  // r: A register operand is allowed provided that it is in a general
978  // register.
979  // g: Any register, memory or immediate integer operand is allowed, except
980  // for registers that are not general registers.
981  // w: (AArch32/AArch64) Floating point register, Advanced SIMD vector
982  // register or SVE vector register.
983  // x: (SSE) Any SSE register.
984  // (AArch64) Like w, but restricted to registers 0 to 15 inclusive.
985  // v: (PowerPC) An Altivec vector register.
986  // wa:(PowerPC) A VSX register.
987  //
988  // "X" (uppercase) should work for all cases, though this seems to fail for
989  // some versions of GCC for arm/aarch64 with
990  // "error: inconsistent operand constraints in an 'asm'"
991  // Clang x86_64/arm/aarch64 seems to require "g" to support both scalars and
992  // vectors, otherwise
993  // "error: non-trivial scalar-to-vector conversion, possible invalid
994  // constraint for vector type"
995  //
996  // GCC for ppc64le generates an internal compiler error with x/X/g.
997  // GCC for AVX generates an internal compiler error with X.
998  //
999  // Tested on icc/gcc/clang for sse, avx, avx2, avx512dq
1000  // gcc for arm, aarch64,
1001  // gcc for ppc64le,
1002  // both vectors and scalars.
1003  //
1004  // Note that this is restricted to plain types - this will not work
1005  // directly for std::complex<T>, Eigen::half, Eigen::bfloat16. For these,
1006  // you will need to apply to the underlying POD type.
1007  #if EIGEN_ARCH_PPC && EIGEN_COMP_GNUC_STRICT
1008  // This seems to be broken on clang. Packet4f is loaded into a single
1009  // register rather than a vector, zeroing out some entries. Integer
1010  // types also generate a compile error.
1011  #if EIGEN_OS_MAC
1012  // General, Altivec for Apple (VSX were added in ISA v2.06):
1013  #define EIGEN_OPTIMIZATION_BARRIER(X) __asm__ ("" : "+r,v" (X));
1014  #else
1015  // General, Altivec, VSX otherwise:
1016  #define EIGEN_OPTIMIZATION_BARRIER(X) __asm__ ("" : "+r,v,wa" (X));
1017  #endif
1018  #elif EIGEN_ARCH_ARM_OR_ARM64
1019  #ifdef __ARM_FP
1020  // General, VFP or NEON.
1021  // Clang doesn't like "r",
1022  // error: non-trivial scalar-to-vector conversion, possible invalid
1023  // constraint for vector typ
1024  #define EIGEN_OPTIMIZATION_BARRIER(X) __asm__ ("" : "+g,w" (X));
1025  #else
1026  // Arm without VFP or NEON.
1027  // "w" constraint will not compile.
1028  #define EIGEN_OPTIMIZATION_BARRIER(X) __asm__ ("" : "+g" (X));
1029  #endif
1030  #elif EIGEN_ARCH_i386_OR_x86_64
1031  // General, SSE.
1032  #define EIGEN_OPTIMIZATION_BARRIER(X) __asm__ ("" : "+g,x" (X));
1033  #else
1034  // Not implemented for other architectures.
1035  #define EIGEN_OPTIMIZATION_BARRIER(X)
1036  #endif
1037  #else
1038  // Not implemented for other compilers.
1039  #define EIGEN_OPTIMIZATION_BARRIER(X)
1040  #endif
1041 #endif
1042 
1043 #if EIGEN_COMP_MSVC
1044  // NOTE MSVC often gives C4127 warnings with compiletime if statements. See bug 1362.
1045  // This workaround is ugly, but it does the job.
1046 # define EIGEN_CONST_CONDITIONAL(cond) (void)0, cond
1047 #else
1048 # define EIGEN_CONST_CONDITIONAL(cond) cond
1049 #endif
1050 
1051 #ifdef EIGEN_DONT_USE_RESTRICT_KEYWORD
1052  #define EIGEN_RESTRICT
1053 #endif
1054 #ifndef EIGEN_RESTRICT
1055  #define EIGEN_RESTRICT __restrict
1056 #endif
1057 
1058 
1059 #ifndef EIGEN_DEFAULT_IO_FORMAT
1060 #ifdef EIGEN_MAKING_DOCS
1061 // format used in Eigen's documentation
1062 // needed to define it here as escaping characters in CMake add_definition's argument seems very problematic.
1063 #define EIGEN_DEFAULT_IO_FORMAT Eigen::IOFormat(3, 0, " ", "\n", "", "")
1064 #else
1065 #define EIGEN_DEFAULT_IO_FORMAT Eigen::IOFormat()
1066 #endif
1067 #endif
1068 
1069 // just an empty macro !
1070 #define EIGEN_EMPTY
1071 
1072 
1073 // When compiling CUDA/HIP device code with NVCC or HIPCC
1074 // pull in math functions from the global namespace.
1075 // In host mode, and when device code is compiled with clang,
1076 // use the std versions.
1077 #if (defined(EIGEN_CUDA_ARCH) && defined(__NVCC__)) || defined(EIGEN_HIP_DEVICE_COMPILE)
1078  #define EIGEN_USING_STD(FUNC) using ::FUNC;
1079 #else
1080  #define EIGEN_USING_STD(FUNC) using std::FUNC;
1081 #endif
1082 
1083 #if EIGEN_COMP_MSVC_STRICT && EIGEN_COMP_NVCC
1084  // Wwhen compiling with NVCC, using the base operator is necessary,
1085  // otherwise we get duplicate definition errors
1086  // For later MSVC versions, we require explicit operator= definition, otherwise we get
1087  // use of implicitly deleted operator errors.
1088  // (cf Bugs 920, 1000, 1324, 2291)
1089  #define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
1090  using Base::operator =;
1091 #elif EIGEN_COMP_CLANG // workaround clang bug (see http://forum.kde.org/viewtopic.php?f=74&t=102653)
1092  #define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
1093  using Base::operator =; \
1094  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const Derived& other) { Base::operator=(other); return *this; } \
1095  template <typename OtherDerived> \
1096  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const DenseBase<OtherDerived>& other) { Base::operator=(other.derived()); return *this; }
1097 #else
1098  #define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
1099  using Base::operator =; \
1100  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const Derived& other) \
1101  { \
1102  Base::operator=(other); \
1103  return *this; \
1104  }
1105 #endif
1106 
1107 
1113 #define EIGEN_DEFAULT_COPY_CONSTRUCTOR(CLASS) EIGEN_DEVICE_FUNC CLASS(const CLASS&) = default;
1114 
1115 
1116 
1122 #define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived) \
1123  EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
1124  EIGEN_DEFAULT_COPY_CONSTRUCTOR(Derived)
1125 
1133 #define EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(Derived) \
1134  EIGEN_DEVICE_FUNC Derived() = default; \
1135  EIGEN_DEVICE_FUNC ~Derived() = default;
1136 
1137 
1138 
1139 
1140 
1149 #define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived) \
1150  typedef typename Eigen::internal::traits<Derived>::Scalar Scalar; \
1151  typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; \
1152  typedef typename Base::CoeffReturnType CoeffReturnType; \
1153  typedef typename Eigen::internal::ref_selector<Derived>::type Nested; \
1154  typedef typename Eigen::internal::traits<Derived>::StorageKind StorageKind; \
1155  typedef typename Eigen::internal::traits<Derived>::StorageIndex StorageIndex; \
1156  enum CompileTimeTraits \
1157  { RowsAtCompileTime = Eigen::internal::traits<Derived>::RowsAtCompileTime, \
1158  ColsAtCompileTime = Eigen::internal::traits<Derived>::ColsAtCompileTime, \
1159  Flags = Eigen::internal::traits<Derived>::Flags, \
1160  SizeAtCompileTime = Base::SizeAtCompileTime, \
1161  MaxSizeAtCompileTime = Base::MaxSizeAtCompileTime, \
1162  IsVectorAtCompileTime = Base::IsVectorAtCompileTime }; \
1163  using Base::derived; \
1164  using Base::const_cast_derived;
1165 
1166 
1167 // FIXME Maybe the EIGEN_DENSE_PUBLIC_INTERFACE could be removed as importing PacketScalar is rarely needed
1168 #define EIGEN_DENSE_PUBLIC_INTERFACE(Derived) \
1169  EIGEN_GENERIC_PUBLIC_INTERFACE(Derived) \
1170  typedef typename Base::PacketScalar PacketScalar;
1171 
1172 
1173 #if EIGEN_HAS_BUILTIN(__builtin_expect) || EIGEN_COMP_GNUC
1174 #define EIGEN_PREDICT_FALSE(x) (__builtin_expect(x, false))
1175 #define EIGEN_PREDICT_TRUE(x) (__builtin_expect(false || (x), true))
1176 #else
1177 #define EIGEN_PREDICT_FALSE(x) (x)
1178 #define EIGEN_PREDICT_TRUE(x) (x)
1179 #endif
1180 
1181 // the expression type of a standard coefficient wise binary operation
1182 #define EIGEN_CWISE_BINARY_RETURN_TYPE(LHS,RHS,OPNAME) \
1183  CwiseBinaryOp< \
1184  EIGEN_CAT(EIGEN_CAT(internal::scalar_,OPNAME),_op)< \
1185  typename internal::traits<LHS>::Scalar, \
1186  typename internal::traits<RHS>::Scalar \
1187  >, \
1188  const LHS, \
1189  const RHS \
1190  >
1191 
1192 #define EIGEN_MAKE_CWISE_BINARY_OP(METHOD,OPNAME) \
1193  template<typename OtherDerived> \
1194  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const EIGEN_CWISE_BINARY_RETURN_TYPE(Derived,OtherDerived,OPNAME) \
1195  (METHOD)(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const \
1196  { \
1197  return EIGEN_CWISE_BINARY_RETURN_TYPE(Derived,OtherDerived,OPNAME)(derived(), other.derived()); \
1198  }
1199 
1200 #define EIGEN_SCALAR_BINARY_SUPPORTED(OPNAME,TYPEA,TYPEB) \
1201  (Eigen::internal::has_ReturnType<Eigen::ScalarBinaryOpTraits<TYPEA,TYPEB,EIGEN_CAT(EIGEN_CAT(Eigen::internal::scalar_,OPNAME),_op)<TYPEA,TYPEB> > >::value)
1202 
1203 #define EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(EXPR,SCALAR,OPNAME) \
1204  CwiseBinaryOp<EIGEN_CAT(EIGEN_CAT(internal::scalar_,OPNAME),_op)<typename internal::traits<EXPR>::Scalar,SCALAR>, const EXPR, \
1205  const typename internal::plain_constant_type<EXPR,SCALAR>::type>
1206 
1207 #define EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(SCALAR,EXPR,OPNAME) \
1208  CwiseBinaryOp<EIGEN_CAT(EIGEN_CAT(internal::scalar_,OPNAME),_op)<SCALAR,typename internal::traits<EXPR>::Scalar>, \
1209  const typename internal::plain_constant_type<EXPR,SCALAR>::type, const EXPR>
1210 
1211 #define EIGEN_MAKE_SCALAR_BINARY_OP_ONTHERIGHT(METHOD,OPNAME) \
1212  template <typename T> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE \
1213  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)\
1214  (METHOD)(const T& scalar) const { \
1215  typedef typename internal::promote_scalar_arg<Scalar,T,EIGEN_SCALAR_BINARY_SUPPORTED(OPNAME,Scalar,T)>::type PromotedT; \
1216  return EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(Derived,PromotedT,OPNAME)(derived(), \
1217  typename internal::plain_constant_type<Derived,PromotedT>::type(derived().rows(), derived().cols(), internal::scalar_constant_op<PromotedT>(scalar))); \
1218  }
1219 
1220 #define EIGEN_MAKE_SCALAR_BINARY_OP_ONTHELEFT(METHOD,OPNAME) \
1221  template <typename T> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE friend \
1222  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) \
1223  (METHOD)(const T& scalar, const StorageBaseType& matrix) { \
1224  typedef typename internal::promote_scalar_arg<Scalar,T,EIGEN_SCALAR_BINARY_SUPPORTED(OPNAME,T,Scalar)>::type PromotedT; \
1225  return EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(PromotedT,Derived,OPNAME)( \
1226  typename internal::plain_constant_type<Derived,PromotedT>::type(matrix.derived().rows(), matrix.derived().cols(), internal::scalar_constant_op<PromotedT>(scalar)), matrix.derived()); \
1227  }
1228 
1229 #define EIGEN_MAKE_SCALAR_BINARY_OP(METHOD,OPNAME) \
1230  EIGEN_MAKE_SCALAR_BINARY_OP_ONTHELEFT(METHOD,OPNAME) \
1231  EIGEN_MAKE_SCALAR_BINARY_OP_ONTHERIGHT(METHOD,OPNAME)
1232 
1233 
1234 #if (defined(_CPPUNWIND) || defined(__EXCEPTIONS)) && !defined(EIGEN_CUDA_ARCH) && !defined(EIGEN_EXCEPTIONS) && !defined(EIGEN_USE_SYCL) && !defined(EIGEN_HIP_DEVICE_COMPILE)
1235  #define EIGEN_EXCEPTIONS
1236 #endif
1237 
1238 
1239 #ifdef EIGEN_EXCEPTIONS
1240 # define EIGEN_THROW_X(X) throw X
1241 # define EIGEN_THROW throw
1242 # define EIGEN_TRY try
1243 # define EIGEN_CATCH(X) catch (X)
1244 #else
1245 # if defined(EIGEN_CUDA_ARCH)
1246 # define EIGEN_THROW_X(X) asm("trap;")
1247 # define EIGEN_THROW asm("trap;")
1248 # elif defined(EIGEN_HIP_DEVICE_COMPILE)
1249 # define EIGEN_THROW_X(X) asm("s_trap 0")
1250 # define EIGEN_THROW asm("s_trap 0")
1251 # else
1252 # define EIGEN_THROW_X(X) std::abort()
1253 # define EIGEN_THROW std::abort()
1254 # endif
1255 # define EIGEN_TRY if (true)
1256 # define EIGEN_CATCH(X) else
1257 #endif
1258 
1259 
1260 #define EIGEN_NOEXCEPT noexcept
1261 #define EIGEN_NOEXCEPT_IF(x) noexcept(x)
1262 #define EIGEN_NO_THROW noexcept(true)
1263 #define EIGEN_EXCEPTION_SPEC(X) noexcept(false)
1264 
1265 
1266 // The all function is used to enable a variadic version of eigen_assert which can take a parameter pack as its input.
1267 namespace Eigen {
1268 namespace internal {
1269 
1270 EIGEN_DEVICE_FUNC inline bool all(){ return true; }
1271 
1272 template<typename T, typename ...Ts>
1273 EIGEN_DEVICE_FUNC bool all(T t, Ts ... ts){ return t && all(ts...); }
1274 
1275 }
1276 }
1277 
1278 // provide override and final specifiers if they are available:
1279 #define EIGEN_OVERRIDE override
1280 #define EIGEN_FINAL final
1281 
1282 // Wrapping #pragma unroll in a macro since it is required for SYCL
1283 #if defined(SYCL_DEVICE_ONLY)
1284  #if defined(_MSC_VER)
1285  #define EIGEN_UNROLL_LOOP __pragma(unroll)
1286  #else
1287  #define EIGEN_UNROLL_LOOP _Pragma("unroll")
1288  #endif
1289 #else
1290  #define EIGEN_UNROLL_LOOP
1291 #endif
1292 
1293 // Notice: Use this macro with caution. The code in the if body should still
1294 // compile with C++14.
1295 #if defined(EIGEN_HAS_CXX17_IFCONSTEXPR)
1296 #define EIGEN_IF_CONSTEXPR(X) if constexpr (X)
1297 #else
1298 #define EIGEN_IF_CONSTEXPR(X) if (X)
1299 #endif
1300 
1301 #endif // EIGEN_MACROS_H
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:883
Eigen::Triplet< double > T
bool all()
Definition: Macros.h:1270
constexpr void ignore_unused_variable(const T &)
Definition: Macros.h:954
: InteropHeaders
Definition: Core:139