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