14 #if defined(EIGEN_GPU_COMPILE_PHASE)
18 #if defined(EIGEN_CUDA_ARCH)
19 #include <math_constants.h>
22 #if defined(EIGEN_HIP_DEVICE_COMPILE)
23 #include "Eigen/src/Core/arch/HIP/hcc/math_constants.h"
28 #if EIGEN_COMP_ICC>=1600 && __cplusplus >= 201103L
34 typedef EIGEN_DEFAULT_DENSE_INDEX_TYPE DenseIndex;
42 typedef EIGEN_DEFAULT_DENSE_INDEX_TYPE
Index;
55 #if EIGEN_COMP_ICC>=1600 && __cplusplus >= 201103L
56 typedef std::intptr_t IntPtr;
57 typedef std::uintptr_t UIntPtr;
59 typedef std::ptrdiff_t IntPtr;
60 typedef std::size_t UIntPtr;
66 template<
bool Condition>
75 template<
bool Condition,
typename Then,
typename Else>
78 template<
typename Then,
typename Else>
79 struct conditional <false, Then, Else> {
typedef Else type; };
89 template <
class T>
struct remove_const<const T> {
typedef T type; };
90 template <
class T>
struct remove_const<const T[]> {
typedef T type[]; };
91 template <
class T,
unsigned int Size>
struct remove_const<const T[Size]> {
typedef T type[Size]; };
93 template<
typename T>
struct remove_all {
typedef T type; };
94 template<
typename T>
struct remove_all<const T> {
typedef typename remove_all<T>::type type; };
95 template<
typename T>
struct remove_all<T const&> {
typedef typename remove_all<T>::type type; };
96 template<
typename T>
struct remove_all<T&> {
typedef typename remove_all<T>::type type; };
97 template<
typename T>
struct remove_all<T const*> {
typedef typename remove_all<T>::type type; };
98 template<
typename T>
struct remove_all<T*> {
typedef typename remove_all<T>::type type; };
115 template<
typename T,
typename U>
struct is_same {
enum { value = 0 }; };
116 template<
typename T>
struct is_same<T,T> {
enum { value = 1 }; };
122 template<>
struct is_arithmetic<signed long long> {
enum { value =
true }; };
123 template<>
struct is_arithmetic<unsigned long long> {
enum { value =
true }; };
124 using std::is_integral;
126 template<
typename T>
struct is_integral {
enum { value =
false }; };
129 template<>
struct is_integral<signed char> {
enum { value =
true }; };
130 template<>
struct is_integral<unsigned char> {
enum { value =
true }; };
131 template<>
struct is_integral<signed short> {
enum { value =
true }; };
132 template<>
struct is_integral<unsigned short> {
enum { value =
true }; };
133 template<>
struct is_integral<signed int> {
enum { value =
true }; };
134 template<>
struct is_integral<unsigned int> {
enum { value =
true }; };
135 template<>
struct is_integral<signed long> {
enum { value =
true }; };
136 template<>
struct is_integral<unsigned long> {
enum { value =
true }; };
138 template<>
struct is_integral<signed __int64> {
enum { value =
true }; };
139 template<>
struct is_integral<unsigned __int64> {
enum { value =
true }; };
144 using std::make_unsigned;
151 template<>
struct make_unsigned<signed char> {
typedef unsigned char type; };
152 template<>
struct make_unsigned<unsigned char> {
typedef unsigned char type; };
153 template<>
struct make_unsigned<signed short> {
typedef unsigned short type; };
154 template<>
struct make_unsigned<unsigned short> {
typedef unsigned short type; };
156 template<>
struct make_unsigned<unsigned int> {
typedef unsigned int type; };
157 template<>
struct make_unsigned<signed long> {
typedef unsigned long type; };
158 template<>
struct make_unsigned<unsigned long> {
typedef unsigned long type; };
160 template<>
struct make_unsigned<signed __int64> {
typedef unsigned __int64 type; };
161 template<>
struct make_unsigned<unsigned __int64> {
typedef unsigned __int64 type; };
170 template <
typename T>
struct add_const<T&> {
typedef T& type; };
172 template <
typename T>
struct is_const {
enum { value = 0 }; };
173 template <
typename T>
struct is_const<T const> {
enum { value = 1 }; };
183 using std::is_convertible;
187 template<
typename From,
typename To>
191 struct any_conversion
193 template <
typename T> any_conversion(
const volatile T&);
194 template <
typename T> any_conversion(T&);
196 struct yes {
int a[1];};
197 struct no {
int a[2];};
200 static yes test(T,
int);
203 static no test(any_conversion, ...);
206 static typename internal::remove_reference<From>::type* ms_from;
207 #ifdef __INTEL_COMPILER
209 #pragma warning ( disable : 2259 )
211 enum { value =
sizeof(test<To>(*ms_from, 0))==
sizeof(yes) };
212 #ifdef __INTEL_COMPILER
217 template<
typename From,
typename To>
234 template<
bool Condition,
typename T=
void>
struct enable_if;
239 #if defined(EIGEN_GPU_COMPILE_PHASE)
240 #if !defined(__FLT_EPSILON__)
241 #define __FLT_EPSILON__ FLT_EPSILON
242 #define __DBL_EPSILON__ DBL_EPSILON
247 template<
typename T>
struct numeric_limits
250 static T epsilon() {
return 0; }
251 static T (max)() { assert(
false &&
"Highest not supported for this type"); }
252 static T (min)() { assert(
false &&
"Lowest not supported for this type"); }
253 static T infinity() { assert(
false &&
"Infinity not supported for this type"); }
254 static T quiet_NaN() { assert(
false &&
"quiet_NaN not supported for this type"); }
256 template<>
struct numeric_limits<float>
259 static float epsilon() {
return __FLT_EPSILON__; }
261 static float (max)() {
262 #if defined(EIGEN_CUDA_ARCH)
263 return CUDART_MAX_NORMAL_F;
265 return HIPRT_MAX_NORMAL_F;
269 static float (min)() {
return FLT_MIN; }
271 static float infinity() {
272 #if defined(EIGEN_CUDA_ARCH)
279 static float quiet_NaN() {
280 #if defined(EIGEN_CUDA_ARCH)
287 template<>
struct numeric_limits<double>
290 static double epsilon() {
return __DBL_EPSILON__; }
292 static double (max)() {
return DBL_MAX; }
294 static double (min)() {
return DBL_MIN; }
296 static double infinity() {
297 #if defined(EIGEN_CUDA_ARCH)
304 static double quiet_NaN() {
305 #if defined(EIGEN_CUDA_ARCH)
312 template<>
struct numeric_limits<int>
315 static int epsilon() {
return 0; }
317 static int (max)() {
return INT_MAX; }
319 static int (min)() {
return INT_MIN; }
321 template<>
struct numeric_limits<unsigned int>
324 static unsigned int epsilon() {
return 0; }
326 static unsigned int (max)() {
return UINT_MAX; }
328 static unsigned int (min)() {
return 0; }
330 template<>
struct numeric_limits<long>
333 static long epsilon() {
return 0; }
335 static long (max)() {
return LONG_MAX; }
337 static long (min)() {
return LONG_MIN; }
339 template<>
struct numeric_limits<unsigned long>
342 static unsigned long epsilon() {
return 0; }
344 static unsigned long (max)() {
return ULONG_MAX; }
346 static unsigned long (min)() {
return 0; }
348 template<>
struct numeric_limits<long long>
351 static long long epsilon() {
return 0; }
353 static long long (max)() {
return LLONG_MAX; }
355 static long long (min)() {
return LLONG_MIN; }
357 template<>
struct numeric_limits<unsigned long long>
360 static unsigned long long epsilon() {
return 0; }
362 static unsigned long long (max)() {
return ULLONG_MAX; }
364 static unsigned long long (min)() {
return 0; }
366 template<>
struct numeric_limits<bool>
369 static bool epsilon() {
return false; }
371 static bool (max)() {
return true; }
373 static bool (min)() {
return false; }
406 template<
typename T,
typename EnableIf =
void>
struct array_size {
410 template<
typename T>
struct array_size<T,typename internal::
enable_if<((T::SizeAtCompileTime&0)==0)>::type> {
411 enum { value = T::SizeAtCompileTime };
414 template<
typename T,
int N>
struct array_size<const T (&)[N]> {
422 template<
typename T, std::
size_t N>
struct array_size<const std::array<T,N> > {
425 template<
typename T, std::
size_t N>
struct array_size<std::array<T,N> > {
440 Index size(
const T& x) {
return x.size(); }
442 template<
typename T,std::
size_t N>
443 Index size(
const T (&) [N]) {
return N; }
452 #if EIGEN_HAS_STD_RESULT_OF
453 template<
typename T>
struct result_of {
454 typedef typename std::result_of<T>::type type1;
455 typedef typename remove_all<type1>::type type;
464 template<
typename Func,
typename ArgType,
int SizeOf=sizeof(has_none)>
467 template<
typename Func,
typename ArgType>
470 template<
typename Func,
typename ArgType>
473 template<
typename Func,
typename ArgType>
478 static has_tr1_result testFunctor(T
const *,
typename T::template result<T(ArgType)>::type
const * = 0);
482 enum {FunctorType =
sizeof(testFunctor(
static_cast<Func*
>(0)))};
483 typedef typename unary_result_of_select<Func, ArgType, FunctorType>::type type;
486 template<
typename Func,
typename ArgType0,
typename ArgType1,
int SizeOf=sizeof(has_none)>
489 template<
typename Func,
typename ArgType0,
typename ArgType1>
491 {
typedef typename Func::result_type type;};
493 template<
typename Func,
typename ArgType0,
typename ArgType1>
495 {
typedef typename Func::template result<Func(ArgType0,ArgType1)>::type type;};
497 template<
typename Func,
typename ArgType0,
typename ArgType1>
502 static has_tr1_result testFunctor(T
const *,
typename T::template result<T(ArgType0,ArgType1)>::type
const * = 0);
506 enum {FunctorType =
sizeof(testFunctor(
static_cast<Func*
>(0)))};
507 typedef typename binary_result_of_select<Func, ArgType0, ArgType1, FunctorType>::type type;
510 template<
typename Func,
typename ArgType0,
typename ArgType1,
typename ArgType2,
int SizeOf=sizeof(has_none)>
513 template<
typename Func,
typename ArgType0,
typename ArgType1,
typename ArgType2>
515 {
typedef typename Func::result_type type;};
517 template<
typename Func,
typename ArgType0,
typename ArgType1,
typename ArgType2>
519 {
typedef typename Func::template result<Func(ArgType0,ArgType1,ArgType2)>::type type;};
521 template<
typename Func,
typename ArgType0,
typename ArgType1,
typename ArgType2>
526 static has_tr1_result testFunctor(T
const *,
typename T::template result<T(ArgType0,ArgType1,ArgType2)>::type
const * = 0);
530 enum {FunctorType =
sizeof(testFunctor(
static_cast<Func*
>(0)))};
531 typedef typename ternary_result_of_select<Func, ArgType0, ArgType1, ArgType2, FunctorType>::type type;
539 template <
typename T>
542 template <
typename C>
static meta_yes testFunctor(C
const *,
typename C::ReturnType
const * = 0);
543 template <
typename C>
static meta_no testFunctor(...);
545 enum { value =
sizeof(testFunctor<T>(
static_cast<T*
>(0))) ==
sizeof(
meta_yes) };
548 template<
typename T>
const T* return_ptr();
550 template <
typename T,
typename IndexType=Index>
553 template <
typename C>
static meta_yes testFunctor(C
const *,
typename enable_if<(
sizeof(return_ptr<C>()->
operator()())>0)>::type * = 0);
554 static meta_no testFunctor(...);
556 enum { value =
sizeof(testFunctor(
static_cast<T*
>(0))) ==
sizeof(
meta_yes) };
559 template <
typename T,
typename IndexType=Index>
562 template <
typename C>
static meta_yes testFunctor(C
const *,
typename enable_if<(
sizeof(return_ptr<C>()->
operator()(IndexType(0)))>0)>::type * = 0);
563 static meta_no testFunctor(...);
565 enum { value =
sizeof(testFunctor(
static_cast<T*
>(0))) ==
sizeof(
meta_yes) };
568 template <
typename T,
typename IndexType=Index>
571 template <
typename C>
static meta_yes testFunctor(C
const *,
typename enable_if<(
sizeof(return_ptr<C>()->
operator()(IndexType(0),IndexType(0)))>0)>::type * = 0);
572 static meta_no testFunctor(...);
574 enum { value =
sizeof(testFunctor(
static_cast<T*
>(0))) ==
sizeof(
meta_yes) };
582 int SupX = ((Y==1) ? 1 : Y/2),
583 bool Done = ((SupX-InfX)<=1 ?
true : ((SupX*SupX <= Y) && ((SupX+1)*(SupX+1) > Y))) >
588 MidX = (InfX+SupX)/2,
589 TakeInf = MidX*MidX > Y ? 1 : 0,
590 NewInf =
int(TakeInf) ? InfX : int(MidX),
591 NewSup = int(TakeInf) ? int(MidX) : SupX
597 template<
int Y,
int InfX,
int SupX>
598 class meta_sqrt<Y, InfX, SupX, true> {
public:
enum { ret = (SupX*SupX <= Y) ? SupX : InfX }; };
605 template<
int A,
int B,
int K=1,
bool Done = ((A*K)%B)==0>
610 template<
int A,
int B,
int K>
619 enum { Defined = 0 };
631 template<
unsigned Len,
unsigned Align>
634 EIGEN_ALIGN_TO_BOUNDARY(Align)
unsigned char data[Len];
642 #if defined(EIGEN_GPU_COMPILE_PHASE)
643 template<
typename T> EIGEN_DEVICE_FUNC
void swap(T &a, T &b) { T tmp = b; b = a; a = tmp; }
645 template<
typename T> EIGEN_STRONG_INLINE
void swap(T &a, T &b) { std::swap(a,b); }
648 #if defined(EIGEN_GPU_COMPILE_PHASE)
649 using internal::device::numeric_limits;
651 using std::numeric_limits;
658 T div_ceil(
const T &a,
const T &b)
665 template<
typename X,
typename Y> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC
666 bool equal_strict(
const X& x,
const Y& y) {
return x == y; }
668 #if !defined(EIGEN_GPU_COMPILE_PHASE) || (!defined(EIGEN_CUDA_ARCH) && defined(EIGEN_CONSTEXPR_ARE_DEVICE_FUNC))
669 template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC
670 bool equal_strict(
const float& x,
const float& y) {
return std::equal_to<float>()(x,y); }
672 template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC
673 bool equal_strict(
const double& x,
const double& y) {
return std::equal_to<double>()(x,y); }
676 template<
typename X,
typename Y> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC
677 bool not_equal_strict(
const X& x,
const Y& y) {
return x != y; }
679 #if !defined(EIGEN_GPU_COMPILE_PHASE) || (!defined(EIGEN_CUDA_ARCH) && defined(EIGEN_CONSTEXPR_ARE_DEVICE_FUNC))
680 template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC
681 bool not_equal_strict(
const float& x,
const float& y) {
return std::not_equal_to<float>()(x,y); }
683 template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC
684 bool not_equal_strict(
const double& x,
const double& y) {
return std::not_equal_to<double>()(x,y); }
696 typedef std::uint8_t uint8_t;
697 typedef std::int8_t int8_t;
698 typedef std::uint16_t uint16_t;
699 typedef std::int16_t int16_t;
700 typedef std::uint32_t uint32_t;
701 typedef std::int32_t int32_t;
702 typedef std::uint64_t uint64_t;
703 typedef std::int64_t int64_t;
712 typedef ::uint8_t uint8_t;
713 typedef ::int8_t int8_t;
714 typedef ::uint16_t uint16_t;
715 typedef ::int16_t int16_t;
716 typedef ::uint32_t uint32_t;
717 typedef ::int32_t int32_t;
718 typedef ::uint64_t uint64_t;
719 typedef ::int64_t int64_t;
724 #endif // EIGEN_META_H