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