15#include "../InternalHeaderCheck.h"
17#if defined(EIGEN_GPU_COMPILE_PHASE)
21#if defined(EIGEN_CUDA_ARCH)
22#include <math_constants.h>
25#if defined(EIGEN_HIP_DEVICE_COMPILE)
26#include "Eigen/src/Core/arch/HIP/hcc/math_constants.h"
36typedef std::uint8_t uint8_t;
37typedef std::int8_t int8_t;
38typedef std::uint16_t uint16_t;
39typedef std::int16_t int16_t;
40typedef std::uint32_t uint32_t;
41typedef std::int32_t int32_t;
42typedef std::uint64_t uint64_t;
43typedef std::int64_t int64_t;
46struct get_integer_by_size {
47 typedef void signed_type;
48 typedef void unsigned_type;
51struct get_integer_by_size<1> {
52 typedef int8_t signed_type;
53 typedef uint8_t unsigned_type;
56struct get_integer_by_size<2> {
57 typedef int16_t signed_type;
58 typedef uint16_t unsigned_type;
61struct get_integer_by_size<4> {
62 typedef int32_t signed_type;
63 typedef uint32_t unsigned_type;
66struct get_integer_by_size<8> {
67 typedef int64_t signed_type;
68 typedef uint64_t unsigned_type;
75typedef EIGEN_DEFAULT_DENSE_INDEX_TYPE DenseIndex;
83typedef EIGEN_DEFAULT_DENSE_INDEX_TYPE
Index;
101template <
bool Condition>
105struct bool_constant<true> : true_type {};
108struct bool_constant<false> : false_type {};
111using std::conditional;
112using std::remove_const;
113using std::remove_pointer;
114using std::remove_reference;
121struct remove_all<const T> {
122 typedef typename remove_all<T>::type type;
125struct remove_all<T const&> {
126 typedef typename remove_all<T>::type type;
129struct remove_all<T&> {
130 typedef typename remove_all<T>::type type;
133struct remove_all<T const*> {
134 typedef typename remove_all<T>::type type;
137struct remove_all<T*> {
138 typedef typename remove_all<T>::type type;
142using remove_all_t =
typename remove_all<T>::type;
145struct is_arithmetic {
146 enum { value =
false };
149struct is_arithmetic<float> {
150 enum { value =
true };
153struct is_arithmetic<double> {
154 enum { value =
true };
157#ifndef EIGEN_GPU_COMPILE_PHASE
159struct is_arithmetic<long double> {
160 enum { value =
true };
164struct is_arithmetic<bool> {
165 enum { value =
true };
168struct is_arithmetic<char> {
169 enum { value =
true };
172struct is_arithmetic<signed char> {
173 enum { value =
true };
176struct is_arithmetic<unsigned char> {
177 enum { value =
true };
180struct is_arithmetic<signed short> {
181 enum { value =
true };
184struct is_arithmetic<unsigned short> {
185 enum { value =
true };
188struct is_arithmetic<signed int> {
189 enum { value =
true };
192struct is_arithmetic<unsigned int> {
193 enum { value =
true };
196struct is_arithmetic<signed long> {
197 enum { value =
true };
200struct is_arithmetic<unsigned long> {
201 enum { value =
true };
204template <
typename T,
typename U>
209struct is_same<T, T> {
214struct is_void : is_same<void, std::remove_const_t<T>> {};
224#if EIGEN_COMP_CXXVER >= 17
227template <
typename...>
232struct is_arithmetic<signed long long> {
233 enum { value =
true };
236struct is_arithmetic<unsigned long long> {
237 enum { value =
true };
239using std::is_integral;
241using std::make_unsigned;
248struct is_const<T const> {
253struct add_const_on_value_type {
254 typedef const T type;
257struct add_const_on_value_type<T&> {
258 typedef T
const& type;
261struct add_const_on_value_type<T*> {
262 typedef T
const* type;
265struct add_const_on_value_type<T* const> {
266 typedef T
const*
const type;
269struct add_const_on_value_type<T const* const> {
270 typedef T
const*
const type;
274using add_const_on_value_type_t =
typename add_const_on_value_type<T>::type;
276using std::is_convertible;
282 EIGEN_DEVICE_FUNC noncopyable(
const noncopyable&);
283 EIGEN_DEVICE_FUNC
const noncopyable& operator=(
const noncopyable&);
286 EIGEN_DEVICE_FUNC noncopyable() {}
287 EIGEN_DEVICE_FUNC ~noncopyable() {}
304template <
typename T,
typename EnableIf =
void>
310struct array_size<T, std::enable_if_t<((T::SizeAtCompileTime & 0) == 0)>> {
311 static constexpr Index value = T::SizeAtCompileTime;
314template <
typename T,
int N>
315struct array_size<const T (&)[N]> {
316 static constexpr Index value = N;
318template <
typename T,
int N>
319struct array_size<T (&)[N]> {
320 static constexpr Index value = N;
323template <
typename T, std::
size_t N>
324struct array_size<const std::array<T, N>> {
325 static constexpr Index value = N;
327template <
typename T, std::
size_t N>
328struct array_size<std::array<T, N>> {
329 static constexpr Index value = N;
342#if EIGEN_COMP_CXXVER < 20 || EIGEN_GNUC_STRICT_LESS_THAN(10, 0, 0)
344EIGEN_CONSTEXPR
auto index_list_size(
const T& x) {
345 using R = std::common_type_t<std::ptrdiff_t, std::make_signed_t<
decltype(x.size())>>;
346 return static_cast<R
>(x.size());
349template <
typename T, std::ptrdiff_t N>
350EIGEN_CONSTEXPR std::ptrdiff_t index_list_size(
const T (&)[N]) {
355EIGEN_CONSTEXPR
auto index_list_size(T&& x) {
357 return ssize(std::forward<T>(x));
371#if EIGEN_HAS_STD_INVOKE_RESULT
375template <
typename F,
typename... ArgTypes>
376struct result_of<F(ArgTypes...)> {
377 typedef typename std::invoke_result<F, ArgTypes...>::type type1;
378 typedef remove_all_t<type1> type;
381template <
typename F,
typename... ArgTypes>
382struct invoke_result {
383 typedef typename std::invoke_result<F, ArgTypes...>::type type1;
384 typedef remove_all_t<type1> type;
389 typedef typename std::result_of<T>::type type1;
390 typedef remove_all_t<type1> type;
393template <
typename F,
typename... ArgTypes>
394struct invoke_result {
395 typedef typename result_of<F(ArgTypes...)>::type type1;
396 typedef remove_all_t<type1> type;
401template <
bool... values>
403 std::is_same<std::integer_sequence<bool, values...,
true>, std::integer_sequence<bool,
true, values...>>;
406template <
bool... values>
407using reduce_any = std::integral_constant<bool, !std::is_same<std::integer_sequence<bool, values...,
false>,
408 std::integer_sequence<bool,
false, values...>>::value>;
419struct has_ReturnType {
420 template <
typename C>
421 static meta_yes testFunctor(C
const*,
typename C::ReturnType
const* = 0);
422 template <
typename C>
423 static meta_no testFunctor(...);
425 enum { value =
sizeof(testFunctor<T>(
static_cast<T*
>(0))) ==
sizeof(meta_yes) };
429const T* return_ptr();
431template <
typename T,
typename IndexType = Index>
432struct has_nullary_operator {
433 template <
typename C>
434 static meta_yes testFunctor(C
const*, std::enable_if_t<(
sizeof(return_ptr<C>()->
operator()()) > 0)>* = 0);
435 static meta_no testFunctor(...);
437 enum { value =
sizeof(testFunctor(
static_cast<T*
>(0))) ==
sizeof(meta_yes) };
440template <
typename T,
typename IndexType = Index>
441struct has_unary_operator {
442 template <
typename C>
443 static meta_yes testFunctor(C
const*, std::enable_if_t<(
sizeof(return_ptr<C>()->
operator()(IndexType(0))) > 0)>* = 0);
444 static meta_no testFunctor(...);
446 enum { value =
sizeof(testFunctor(
static_cast<T*
>(0))) ==
sizeof(meta_yes) };
449template <
typename T,
typename IndexType = Index>
450struct has_binary_operator {
451 template <
typename C>
452 static meta_yes testFunctor(
453 C
const*, std::enable_if_t<(
sizeof(return_ptr<C>()->
operator()(IndexType(0), IndexType(0))) > 0)>* = 0);
454 static meta_no testFunctor(...);
456 enum { value =
sizeof(testFunctor(
static_cast<T*
>(0))) ==
sizeof(meta_yes) };
462template <
int Y,
int InfX = 0,
int SupX = ((Y == 1) ? 1 : Y / 2),
463 bool Done = ((SupX - InfX) <= 1 || ((SupX * SupX <= Y) && ((SupX + 1) * (SupX + 1) > Y)))>
466 MidX = (InfX + SupX) / 2,
467 TakeInf = MidX * MidX > Y ? 1 : 0,
468 NewInf = int(TakeInf) ? InfX : int(MidX),
469 NewSup = int(TakeInf) ? int(MidX) : SupX
473 enum { ret = meta_sqrt<Y, NewInf, NewSup>::ret };
476template <
int Y,
int InfX,
int SupX>
477class meta_sqrt<Y, InfX, SupX, true> {
479 enum { ret = (SupX * SupX <= Y) ? SupX : InfX };
485template <
int A,
int B,
int K = 1,
bool Done = ((A * K) % B) == 0,
bool Big = (A >= B)>
486struct meta_least_common_multiple {
487 enum { ret = meta_least_common_multiple<A, B, K + 1>::ret };
489template <
int A,
int B,
int K,
bool Done>
490struct meta_least_common_multiple<A, B, K, Done, false> {
491 enum { ret = meta_least_common_multiple<B, A, K>::ret };
493template <
int A,
int B,
int K>
494struct meta_least_common_multiple<A, B, K, true, true> {
495 enum { ret = A * K };
499template <
typename T,
typename U>
500struct scalar_product_traits {
501 enum { Defined = 0 };
513template <
unsigned Len,
unsigned Align>
514struct aligned_storage {
516 EIGEN_ALIGN_TO_BOUNDARY(Align)
unsigned char data[Len];
527#if defined(EIGEN_GPU_COMPILE_PHASE)
529EIGEN_DEVICE_FUNC
void swap(T& a, T& b) {
536EIGEN_STRONG_INLINE
void swap(T& a, T& b) {
541using std::numeric_limits;
544template <typename X, typename Y, bool XIsInteger = NumTraits<X>::IsInteger,
bool XIsSigned =
NumTraits<X>::IsSigned,
546struct equal_strict_impl {
547 static EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC
bool run(
const X& x,
const Y& y) {
return x == y; }
549template <
typename X,
typename Y>
550struct equal_strict_impl<X, Y, true, false, true, true> {
554 using UnsignedY =
typename internal::make_unsigned<Y>::type;
555 static EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC
bool run(
const X& x,
const Y& y) {
556 return y < Y(0) ? false : (x == static_cast<UnsignedY>(y));
559template <
typename X,
typename Y>
560struct equal_strict_impl<X, Y, true, true, true, false> {
563 static EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC
bool run(
const X& x,
const Y& y) {
564 return equal_strict_impl<Y, X>::run(y, x);
570template <
typename X,
typename Y>
571EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC
bool equal_strict(
const X& x,
const Y& y) {
572 return equal_strict_impl<X, Y>::run(x, y);
575#if !defined(EIGEN_GPU_COMPILE_PHASE) || (!defined(EIGEN_CUDA_ARCH) && defined(EIGEN_CONSTEXPR_ARE_DEVICE_FUNC))
577EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC
bool equal_strict(
const float& x,
const float& y) {
578 return std::equal_to<float>()(x, y);
582EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC
bool equal_strict(
const double& x,
const double& y) {
583 return std::equal_to<double>()(x, y);
592EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC
bool is_exactly_zero(
const X& x) {
593 return equal_strict(x,
typename NumTraits<X>::Literal{0});
601EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC
bool is_exactly_one(
const X& x) {
602 return equal_strict(x,
typename NumTraits<X>::Literal{1});
605template <
typename X,
typename Y>
606EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC
bool not_equal_strict(
const X& x,
const Y& y) {
607 return !equal_strict_impl<X, Y>::run(x, y);
610#if !defined(EIGEN_GPU_COMPILE_PHASE) || (!defined(EIGEN_CUDA_ARCH) && defined(EIGEN_CONSTEXPR_ARE_DEVICE_FUNC))
612EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC
bool not_equal_strict(
const float& x,
const float& y) {
613 return std::not_equal_to<float>()(x, y);
617EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC
bool not_equal_strict(
const double& x,
const double& y) {
618 return std::not_equal_to<double>()(x, y);
626template <
typename Scalar>
627struct is_identically_zero_impl {
628 static inline bool run(
const Scalar& s) {
return numext::is_exactly_zero(s); }
631template <
typename Scalar>
632EIGEN_STRONG_INLINE
bool is_identically_zero(
const Scalar& s) {
633 return is_identically_zero_impl<Scalar>::run(s);
639constexpr bool is_int_or_enum_v = std::is_enum<A>::value || std::is_integral<A>::value;
642template <
typename A,
typename B>
643inline constexpr int plain_enum_min(A a, B b) {
644 static_assert(is_int_or_enum_v<A>,
"Argument a must be an integer or enum");
645 static_assert(is_int_or_enum_v<B>,
"Argument b must be an integer or enum");
646 return ((
int)a <= (int)b) ? (int)a : (int)b;
650template <
typename A,
typename B>
651inline constexpr int plain_enum_max(A a, B b) {
652 static_assert(is_int_or_enum_v<A>,
"Argument a must be an integer or enum");
653 static_assert(is_int_or_enum_v<B>,
"Argument b must be an integer or enum");
654 return ((
int)a >= (int)b) ? (int)a : (int)b;
663template <
typename A,
typename B>
664inline constexpr int min_size_prefer_dynamic(A a, B b) {
665 static_assert(is_int_or_enum_v<A>,
"Argument a must be an integer or enum");
666 static_assert(is_int_or_enum_v<B>,
"Argument b must be an integer or enum");
667 if ((
int)a == 0 || (int)b == 0)
return 0;
668 if ((
int)a == 1 || (int)b == 1)
return 1;
670 return plain_enum_min(a, b);
679template <
typename A,
typename B>
680inline constexpr int min_size_prefer_fixed(A a, B b) {
681 static_assert(is_int_or_enum_v<A>,
"Argument a must be an integer or enum");
682 static_assert(is_int_or_enum_v<B>,
"Argument b must be an integer or enum");
683 if ((
int)a == 0 || (int)b == 0)
return 0;
684 if ((
int)a == 1 || (int)b == 1)
return 1;
686 if ((
int)a ==
Dynamic)
return (
int)b;
687 if ((
int)b ==
Dynamic)
return (
int)a;
688 return plain_enum_min(a, b);
692template <
typename A,
typename B>
693inline constexpr int max_size_prefer_dynamic(A a, B b) {
694 static_assert(is_int_or_enum_v<A>,
"Argument a must be an integer or enum");
695 static_assert(is_int_or_enum_v<B>,
"Argument b must be an integer or enum");
697 return plain_enum_max(a, b);
701inline constexpr bool logical_xor(
bool a,
bool b) {
return a != b; }
704inline constexpr bool check_implication(
bool a,
bool b) {
return !a || b; }
707#if EIGEN_COMP_CXXVER >= 20
708using std::is_constant_evaluated;
710constexpr bool is_constant_evaluated() {
return false; }
Namespace containing all symbols from the Eigen library.
Definition Core:137
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:83
const int Dynamic
Definition Constants.h:25
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition Meta.h:523