14 #include "../InternalHeaderCheck.h"
16 #if defined(EIGEN_GPU_COMPILE_PHASE)
20 #if defined(EIGEN_CUDA_ARCH)
24 #if defined(EIGEN_HIP_DEVICE_COMPILE)
44 template <
size_t Size>
93 struct true_type {
enum { value = 1 }; };
94 struct false_type {
enum { value = 0 }; };
96 template<
bool Condition>
100 struct bool_constant<true> : true_type {};
103 struct bool_constant<false> : false_type {};
106 using std::conditional;
107 using std::remove_reference;
108 using std::remove_pointer;
109 using std::remove_const;
111 template<
typename T>
struct remove_all {
typedef T type; };
112 template<
typename T>
struct remove_all<const
T> {
typedef typename remove_all<T>::type type; };
113 template<
typename T>
struct remove_all<
T const&> {
typedef typename remove_all<T>::type type; };
114 template<
typename T>
struct remove_all<
T&> {
typedef typename remove_all<T>::type type; };
115 template<
typename T>
struct remove_all<
T const*> {
typedef typename remove_all<T>::type type; };
116 template<
typename T>
struct remove_all<
T*> {
typedef typename remove_all<T>::type type; };
121 template<
typename T>
struct is_arithmetic {
enum { value =
false }; };
122 template<>
struct is_arithmetic<float> {
enum { value =
true }; };
123 template<>
struct is_arithmetic<double> {
enum { value =
true }; };
125 #ifndef EIGEN_GPU_COMPILE_PHASE
126 template<>
struct is_arithmetic<long double> {
enum { value =
true }; };
128 template<>
struct is_arithmetic<
bool> {
enum { value =
true }; };
129 template<>
struct is_arithmetic<char> {
enum { value =
true }; };
130 template<>
struct is_arithmetic<signed char> {
enum { value =
true }; };
131 template<>
struct is_arithmetic<unsigned char> {
enum { value =
true }; };
132 template<>
struct is_arithmetic<signed short> {
enum { value =
true }; };
133 template<>
struct is_arithmetic<unsigned short>{
enum { value =
true }; };
134 template<>
struct is_arithmetic<signed int> {
enum { value =
true }; };
135 template<>
struct is_arithmetic<unsigned int> {
enum { value =
true }; };
136 template<>
struct is_arithmetic<signed long> {
enum { value =
true }; };
137 template<>
struct is_arithmetic<unsigned long> {
enum { value =
true }; };
139 template<
typename T,
typename U>
struct is_same {
enum { value = 0 }; };
140 template<
typename T>
struct is_same<
T,
T> {
enum { value = 1 }; };
143 struct is_void : is_same<void, std::remove_const_t<T>> {};
153 #if EIGEN_COMP_CXXVER >= 17
156 template<
typename...>
160 template<>
struct is_arithmetic<signed long long> {
enum { value =
true }; };
161 template<>
struct is_arithmetic<unsigned long long> {
enum { value =
true }; };
162 using std::is_integral;
164 using std::make_unsigned;
166 template <
typename T>
struct is_const {
enum { value = 0 }; };
167 template <
typename T>
struct is_const<T const> {
enum { value = 1 }; };
169 template<
typename T>
struct add_const_on_value_type {
typedef const T type; };
170 template<
typename T>
struct add_const_on_value_type<T&> {
typedef T const& type; };
171 template<
typename T>
struct add_const_on_value_type<T*> {
typedef T const* type; };
172 template<
typename T>
struct add_const_on_value_type<T* const> {
typedef T const*
const type; };
173 template<
typename T>
struct add_const_on_value_type<T const* const> {
typedef T const*
const type; };
178 using std::is_convertible;
206 template<
typename T,
typename EnableIf =
void>
struct array_size {
210 template<
typename T>
struct array_size<
T, std::enable_if_t<((T::SizeAtCompileTime&0)==0)>> {
211 enum { value = T::SizeAtCompileTime };
214 template<
typename T,
int N>
struct array_size<const
T (&)[N]> {
217 template<
typename T,
int N>
struct array_size<
T (&)[N]> {
221 template<
typename T, std::
size_t N>
struct array_size<const
std::
array<T,N> > {
224 template<
typename T, std::
size_t N>
struct array_size<
std::
array<T,N> > {
239 #if EIGEN_COMP_CXXVER < 20 || EIGEN_GNUC_STRICT_LESS_THAN(10,0,0)
240 template <
typename T>
242 using R = std::common_type_t<std::ptrdiff_t, std::make_signed_t<decltype(
x.size())>>;
243 return static_cast<R
>(
x.size());
246 template<
typename T, std::ptrdiff_t N>
249 template <
typename T>
252 return ssize(std::forward<T>(
x));
266 #if EIGEN_HAS_STD_INVOKE_RESULT
267 template<
typename T>
struct result_of;
269 template<
typename F,
typename... ArgTypes>
270 struct result_of<F(ArgTypes...)> {
271 typedef typename std::invoke_result<F, ArgTypes...>::type type1;
272 typedef remove_all_t<type1> type;
275 template<
typename F,
typename... ArgTypes>
276 struct invoke_result {
277 typedef typename std::invoke_result<F, ArgTypes...>::type type1;
278 typedef remove_all_t<type1> type;
281 template<
typename T>
struct result_of {
282 typedef typename std::result_of<T>::type type1;
283 typedef remove_all_t<type1> type;
286 template<
typename F,
typename... ArgTypes>
287 struct invoke_result {
288 typedef typename result_of<F(ArgTypes...)>::type type1;
289 typedef remove_all_t<type1> type;
294 template<
bool... values>
296 std::integer_sequence<
bool,
true, values...> >;
299 template<
bool... values>
301 !std::is_same<std::integer_sequence<
bool, values...,
false>, std::integer_sequence<
bool,
false, values...> >::value>;
303 struct meta_yes {
char a[1]; };
304 struct meta_no {
char a[2]; };
307 template <
typename T>
308 struct has_ReturnType
310 template <
typename C>
static meta_yes testFunctor(C
const *,
typename C::ReturnType
const * = 0);
311 template <
typename C>
static meta_no testFunctor(...);
313 enum { value =
sizeof(testFunctor<T>(
static_cast<T*
>(0))) ==
sizeof(meta_yes) };
318 template <
typename T,
typename IndexType=Index>
319 struct has_nullary_operator
321 template <
typename C>
static meta_yes testFunctor(C
const *,std::enable_if_t<(
sizeof(return_ptr<C>()->
operator()())>0)> * = 0);
322 static meta_no testFunctor(...);
324 enum { value =
sizeof(testFunctor(
static_cast<T*
>(0))) ==
sizeof(meta_yes) };
327 template <
typename T,
typename IndexType=Index>
328 struct has_unary_operator
330 template <
typename C>
static meta_yes testFunctor(C
const *,std::enable_if_t<(
sizeof(return_ptr<C>()->
operator()(IndexType(0)))>0)> * = 0);
331 static meta_no testFunctor(...);
333 enum { value =
sizeof(testFunctor(
static_cast<T*
>(0))) ==
sizeof(meta_yes) };
336 template <
typename T,
typename IndexType=Index>
337 struct has_binary_operator
339 template <
typename C>
static meta_yes testFunctor(C
const *,std::enable_if_t<(
sizeof(return_ptr<C>()->
operator()(IndexType(0),IndexType(0)))>0)> * = 0);
340 static meta_no testFunctor(...);
342 enum { value =
sizeof(testFunctor(
static_cast<T*
>(0))) ==
sizeof(meta_yes) };
350 int SupX = ((Y==1) ? 1 : Y/2),
351 bool Done = ((SupX - InfX) <= 1 || ((SupX * SupX <= Y) && ((SupX + 1) * (SupX + 1) > Y)))>
355 MidX = (InfX+SupX)/2,
356 TakeInf = MidX*MidX > Y ? 1 : 0,
357 NewInf =
int(TakeInf) ? InfX : int(MidX),
358 NewSup = int(TakeInf) ? int(MidX) : SupX
361 enum { ret = meta_sqrt<Y,NewInf,NewSup>::ret };
364 template<
int Y,
int InfX,
int SupX>
365 class meta_sqrt<Y, InfX, SupX, true> {
public:
enum { ret = (SupX*SupX <= Y) ? SupX : InfX }; };
371 template<
int A,
int B,
int K=1,
bool Done = ((A*K)%B)==0,
bool Big=(A>=
B)>
372 struct meta_least_common_multiple
374 enum { ret = meta_least_common_multiple<A,B,K+1>::ret };
376 template<
int A,
int B,
int K,
bool Done>
377 struct meta_least_common_multiple<
A,
B,K,Done,false>
379 enum { ret = meta_least_common_multiple<B,A,K>::ret };
381 template<
int A,
int B,
int K>
382 struct meta_least_common_multiple<
A,
B,K,true,true>
389 template<
typename T,
typename U>
struct scalar_product_traits
391 enum { Defined = 0 };
403 template<
unsigned Len,
unsigned Align>
404 struct aligned_storage {
412 template<
typename T>
struct NumTraits;
416 #if defined(EIGEN_GPU_COMPILE_PHASE)
422 using std::numeric_limits;
434 template <typename X, typename Y, bool XIsInteger = NumTraits<X>::IsInteger,
bool XIsSigned =
NumTraits<X>::IsSigned,
439 template <
typename X,
typename Y>
444 using UnsignedY =
typename internal::make_unsigned<Y>::type;
446 return y < Y(0) ? false : (x == static_cast<UnsignedY>(
y));
449 template <
typename X,
typename Y>
462 #if !defined(EIGEN_GPU_COMPILE_PHASE) || (!defined(EIGEN_CUDA_ARCH) && defined(EIGEN_CONSTEXPR_ARE_DEVICE_FUNC))
467 bool equal_strict(
const double&
x,
const double&
y) {
return std::equal_to<double>()(
x,
y); }
487 #if !defined(EIGEN_GPU_COMPILE_PHASE) || (!defined(EIGEN_CUDA_ARCH) && defined(EIGEN_CONSTEXPR_ARE_DEVICE_FUNC))
499 template<
typename Scalar>
500 struct is_identically_zero_impl {
501 static inline bool run(
const Scalar& s) {
506 template<
typename Scalar> EIGEN_STRONG_INLINE
515 template<
typename A,
typename B>
517 static_assert(is_int_or_enum_v<A>,
"Argument a must be an integer or enum");
518 static_assert(is_int_or_enum_v<B>,
"Argument b must be an integer or enum");
519 return ((
int)
a <= (
int)
b) ? (int)
a : (
int)
b;
523 template<
typename A,
typename B>
525 static_assert(is_int_or_enum_v<A>,
"Argument a must be an integer or enum");
526 static_assert(is_int_or_enum_v<B>,
"Argument b must be an integer or enum");
527 return ((
int)
a >= (
int)
b) ? (int)
a : (
int)
b;
536 template<
typename A,
typename B>
538 static_assert(is_int_or_enum_v<A>,
"Argument a must be an integer or enum");
539 static_assert(is_int_or_enum_v<B>,
"Argument b must be an integer or enum");
540 if ((
int)
a == 0 || (
int)
b == 0)
return 0;
541 if ((
int)
a == 1 || (
int)
b == 1)
return 1;
552 template<
typename A,
typename B>
554 static_assert(is_int_or_enum_v<A>,
"Argument a must be an integer or enum");
555 static_assert(is_int_or_enum_v<B>,
"Argument b must be an integer or enum");
556 if ((
int)
a == 0 || (
int)
b == 0)
return 0;
557 if ((
int)
a == 1 || (
int)
b == 1)
return 1;
565 template<
typename A,
typename B>
567 static_assert(is_int_or_enum_v<A>,
"Argument a must be an integer or enum");
568 static_assert(is_int_or_enum_v<B>,
"Argument b must be an integer or enum");
584 #if EIGEN_COMP_CXXVER >= 20
#define EIGEN_DEFAULT_DENSE_INDEX_TYPE
#define EIGEN_DEVICE_FUNC
Eigen::Triplet< double > T
constexpr int plain_enum_min(A a, B b)
constexpr int plain_enum_max(A a, B b)
std::integral_constant< bool, !std::is_same< std::integer_sequence< bool, values..., false >, std::integer_sequence< bool, false, values... > >::value > reduce_any
constexpr bool is_int_or_enum_v
constexpr bool check_implication(bool a, bool b)
constexpr int min_size_prefer_fixed(A a, B b)
bool is_identically_zero(const Scalar &s)
constexpr bool logical_xor(bool a, bool b)
std::is_same< std::integer_sequence< bool, values..., true >, std::integer_sequence< bool, true, values... > > reduce_all
typename remove_all< T >::type remove_all_t
EIGEN_CONSTEXPR auto index_list_size(const T &x)
constexpr bool is_constant_evaluated()
void swap(scoped_array< T > &a, scoped_array< T > &b)
constexpr int max_size_prefer_dynamic(A a, B b)
typename add_const_on_value_type< T >::type add_const_on_value_type_t
constexpr int min_size_prefer_dynamic(A a, B b)
bool is_exactly_one(const X &x)
bool not_equal_strict(const double &x, const double &y)
bool equal_strict(const double &x, const double &y)
T div_ceil(const T &a, const T &b)
bool is_exactly_zero(const X &x)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
EIGEN_DEFAULT_DENSE_INDEX_TYPE DenseIndex
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
static bool run(const X &x, const Y &y)
typename internal::make_unsigned< Y >::type UnsignedY
static bool run(const X &x, const Y &y)
static bool run(const X &x, const Y &y)