14 #if defined(__CUDA_ARCH__) 16 #include <math_constants.h> 19 #if EIGEN_COMP_ICC>=1600 && __cplusplus >= 201103L 36 #if EIGEN_COMP_ICC>=1600 && __cplusplus >= 201103L 37 typedef std::intptr_t IntPtr;
38 typedef std::uintptr_t UIntPtr;
40 typedef std::ptrdiff_t IntPtr;
41 typedef std::size_t UIntPtr;
44 struct true_type {
enum { value = 1 }; };
45 struct false_type {
enum { value = 0 }; };
47 template<
bool Condition,
typename Then,
typename Else>
48 struct conditional {
typedef Then type; };
50 template<
typename Then,
typename Else>
51 struct conditional <false, Then, Else> {
typedef Else type; };
53 template<
typename T,
typename U>
struct is_same {
enum { value = 0 }; };
54 template<
typename T>
struct is_same<T,T> {
enum { value = 1 }; };
56 template<
typename T>
struct remove_reference {
typedef T type; };
57 template<
typename T>
struct remove_reference<T&> {
typedef T type; };
59 template<
typename T>
struct remove_pointer {
typedef T type; };
60 template<
typename T>
struct remove_pointer<T*> {
typedef T type; };
61 template<
typename T>
struct remove_pointer<T*
const> {
typedef T type; };
63 template <
class T>
struct remove_const {
typedef T type; };
64 template <
class T>
struct remove_const<const T> {
typedef T type; };
65 template <
class T>
struct remove_const<const T[]> {
typedef T type[]; };
66 template <
class T,
unsigned int Size>
struct remove_const<const T[Size]> {
typedef T type[Size]; };
68 template<
typename T>
struct remove_all {
typedef T type; };
69 template<
typename T>
struct remove_all<const T> {
typedef typename remove_all<T>::type type; };
70 template<
typename T>
struct remove_all<T const&> {
typedef typename remove_all<T>::type type; };
71 template<
typename T>
struct remove_all<T&> {
typedef typename remove_all<T>::type type; };
72 template<
typename T>
struct remove_all<T const*> {
typedef typename remove_all<T>::type type; };
73 template<
typename T>
struct remove_all<T*> {
typedef typename remove_all<T>::type type; };
75 template<
typename T>
struct is_arithmetic {
enum { value =
false }; };
76 template<>
struct is_arithmetic<float> {
enum { value =
true }; };
77 template<>
struct is_arithmetic<double> {
enum { value =
true }; };
78 template<>
struct is_arithmetic<long double> {
enum { value =
true }; };
79 template<>
struct is_arithmetic<bool> {
enum { value =
true }; };
80 template<>
struct is_arithmetic<char> {
enum { value =
true }; };
81 template<>
struct is_arithmetic<signed char> {
enum { value =
true }; };
82 template<>
struct is_arithmetic<unsigned char> {
enum { value =
true }; };
83 template<>
struct is_arithmetic<signed short> {
enum { value =
true }; };
84 template<>
struct is_arithmetic<unsigned short>{
enum { value =
true }; };
85 template<>
struct is_arithmetic<signed int> {
enum { value =
true }; };
86 template<>
struct is_arithmetic<unsigned int> {
enum { value =
true }; };
87 template<>
struct is_arithmetic<signed long> {
enum { value =
true }; };
88 template<>
struct is_arithmetic<unsigned long> {
enum { value =
true }; };
90 template<
typename T>
struct is_integral {
enum { value =
false }; };
91 template<>
struct is_integral<bool> {
enum { value =
true }; };
92 template<>
struct is_integral<char> {
enum { value =
true }; };
93 template<>
struct is_integral<signed char> {
enum { value =
true }; };
94 template<>
struct is_integral<unsigned char> {
enum { value =
true }; };
95 template<>
struct is_integral<signed short> {
enum { value =
true }; };
96 template<>
struct is_integral<unsigned short> {
enum { value =
true }; };
97 template<>
struct is_integral<signed int> {
enum { value =
true }; };
98 template<>
struct is_integral<unsigned int> {
enum { value =
true }; };
99 template<>
struct is_integral<signed long> {
enum { value =
true }; };
100 template<>
struct is_integral<unsigned long> {
enum { value =
true }; };
102 template <
typename T>
struct add_const {
typedef const T type; };
103 template <
typename T>
struct add_const<T&> {
typedef T& type; };
105 template <
typename T>
struct is_const {
enum { value = 0 }; };
106 template <
typename T>
struct is_const<T const> {
enum { value = 1 }; };
108 template<
typename T>
struct add_const_on_value_type {
typedef const T type; };
109 template<
typename T>
struct add_const_on_value_type<T&> {
typedef T
const& type; };
110 template<
typename T>
struct add_const_on_value_type<T*> {
typedef T
const* type; };
111 template<
typename T>
struct add_const_on_value_type<T*
const> {
typedef T
const*
const type; };
112 template<
typename T>
struct add_const_on_value_type<T const*
const> {
typedef T
const*
const type; };
115 template<
typename From,
typename To>
116 struct is_convertible_impl
119 struct any_conversion
121 template <
typename T> any_conversion(
const volatile T&);
122 template <
typename T> any_conversion(T&);
124 struct yes {
int a[1];};
125 struct no {
int a[2];};
127 static yes test(
const To&,
int);
128 static no test(any_conversion, ...);
132 #ifdef __INTEL_COMPILER 134 #pragma warning ( disable : 2259 ) 136 enum { value =
sizeof(test(ms_from, 0))==
sizeof(yes) };
137 #ifdef __INTEL_COMPILER 142 template<
typename From,
typename To>
143 struct is_convertible
145 enum { value = is_convertible_impl<typename remove_all<From>::type,
146 typename remove_all<To >::type>::value };
152 template<
bool Condition,
typename T=
void>
struct enable_if;
154 template<
typename T>
struct enable_if<true,T>
157 #if defined(__CUDA_ARCH__) 158 #if !defined(__FLT_EPSILON__) 159 #define __FLT_EPSILON__ FLT_EPSILON 160 #define __DBL_EPSILON__ DBL_EPSILON 165 template<
typename T>
struct numeric_limits
168 static T epsilon() {
return 0; }
169 static T (max)() { assert(
false &&
"Highest not supported for this type"); }
170 static T (min)() { assert(
false &&
"Lowest not supported for this type"); }
171 static T infinity() { assert(
false &&
"Infinity not supported for this type"); }
172 static T quiet_NaN() { assert(
false &&
"quiet_NaN not supported for this type"); }
174 template<>
struct numeric_limits<float>
177 static float epsilon() {
return __FLT_EPSILON__; }
179 static float (max)() {
return CUDART_MAX_NORMAL_F; }
181 static float (min)() {
return FLT_MIN; }
183 static float infinity() {
return CUDART_INF_F; }
185 static float quiet_NaN() {
return CUDART_NAN_F; }
187 template<>
struct numeric_limits<double>
190 static double epsilon() {
return __DBL_EPSILON__; }
192 static double (max)() {
return DBL_MAX; }
194 static double (min)() {
return DBL_MIN; }
196 static double infinity() {
return CUDART_INF; }
198 static double quiet_NaN() {
return CUDART_NAN; }
200 template<>
struct numeric_limits<int>
203 static int epsilon() {
return 0; }
205 static int (max)() {
return INT_MAX; }
207 static int (min)() {
return INT_MIN; }
209 template<>
struct numeric_limits<unsigned int>
212 static unsigned int epsilon() {
return 0; }
214 static unsigned int (max)() {
return UINT_MAX; }
216 static unsigned int (min)() {
return 0; }
218 template<>
struct numeric_limits<long>
221 static long epsilon() {
return 0; }
223 static long (max)() {
return LONG_MAX; }
225 static long (min)() {
return LONG_MIN; }
227 template<>
struct numeric_limits<unsigned long>
230 static unsigned long epsilon() {
return 0; }
232 static unsigned long (max)() {
return ULONG_MAX; }
234 static unsigned long (min)() {
return 0; }
236 template<>
struct numeric_limits<long long>
239 static long long epsilon() {
return 0; }
241 static long long (max)() {
return LLONG_MAX; }
243 static long long (min)() {
return LLONG_MIN; }
245 template<>
struct numeric_limits<unsigned long long>
248 static unsigned long long epsilon() {
return 0; }
250 static unsigned long long (max)() {
return ULLONG_MAX; }
252 static unsigned long long (min)() {
return 0; }
264 EIGEN_DEVICE_FUNC noncopyable(
const noncopyable&);
265 EIGEN_DEVICE_FUNC
const noncopyable& operator=(
const noncopyable&);
267 EIGEN_DEVICE_FUNC noncopyable() {}
268 EIGEN_DEVICE_FUNC ~noncopyable() {}
278 #if EIGEN_HAS_STD_RESULT_OF 279 template<
typename T>
struct result_of {
280 typedef typename std::result_of<T>::type type1;
281 typedef typename remove_all<type1>::type type;
284 template<
typename T>
struct result_of { };
286 struct has_none {
int a[1];};
287 struct has_std_result_type {
int a[2];};
288 struct has_tr1_result {
int a[3];};
290 template<
typename Func,
typename ArgType,
int SizeOf=sizeof(has_none)>
291 struct unary_result_of_select {
typedef typename internal::remove_all<ArgType>::type type;};
293 template<
typename Func,
typename ArgType>
294 struct unary_result_of_select<Func, ArgType, sizeof(has_std_result_type)> {
typedef typename Func::result_type type;};
296 template<
typename Func,
typename ArgType>
297 struct unary_result_of_select<Func, ArgType, sizeof(has_tr1_result)> {
typedef typename Func::template result<Func(ArgType)>::type type;};
299 template<
typename Func,
typename ArgType>
300 struct result_of<Func(ArgType)> {
302 static has_std_result_type testFunctor(T
const *,
typename T::result_type
const * = 0);
304 static has_tr1_result testFunctor(T
const *,
typename T::template result<T(ArgType)>::type
const * = 0);
305 static has_none testFunctor(...);
308 enum {FunctorType =
sizeof(testFunctor(static_cast<Func*>(0)))};
309 typedef typename unary_result_of_select<Func, ArgType, FunctorType>::type type;
312 template<
typename Func,
typename ArgType0,
typename ArgType1,
int SizeOf=sizeof(has_none)>
313 struct binary_result_of_select {
typedef typename internal::remove_all<ArgType0>::type type;};
315 template<
typename Func,
typename ArgType0,
typename ArgType1>
316 struct binary_result_of_select<Func, ArgType0, ArgType1, sizeof(has_std_result_type)>
317 {
typedef typename Func::result_type type;};
319 template<
typename Func,
typename ArgType0,
typename ArgType1>
320 struct binary_result_of_select<Func, ArgType0, ArgType1, sizeof(has_tr1_result)>
321 {
typedef typename Func::template result<Func(ArgType0,ArgType1)>::type type;};
323 template<
typename Func,
typename ArgType0,
typename ArgType1>
324 struct result_of<Func(ArgType0,ArgType1)> {
326 static has_std_result_type testFunctor(T
const *,
typename T::result_type
const * = 0);
328 static has_tr1_result testFunctor(T
const *,
typename T::template result<T(ArgType0,ArgType1)>::type
const * = 0);
329 static has_none testFunctor(...);
332 enum {FunctorType =
sizeof(testFunctor(static_cast<Func*>(0)))};
333 typedef typename binary_result_of_select<Func, ArgType0, ArgType1, FunctorType>::type type;
336 template<
typename Func,
typename ArgType0,
typename ArgType1,
typename ArgType2,
int SizeOf=sizeof(has_none)>
337 struct ternary_result_of_select {
typedef typename internal::remove_all<ArgType0>::type type;};
339 template<
typename Func,
typename ArgType0,
typename ArgType1,
typename ArgType2>
340 struct ternary_result_of_select<Func, ArgType0, ArgType1, ArgType2, sizeof(has_std_result_type)>
341 {
typedef typename Func::result_type type;};
343 template<
typename Func,
typename ArgType0,
typename ArgType1,
typename ArgType2>
344 struct ternary_result_of_select<Func, ArgType0, ArgType1, ArgType2, sizeof(has_tr1_result)>
345 {
typedef typename Func::template result<Func(ArgType0,ArgType1,ArgType2)>::type type;};
347 template<
typename Func,
typename ArgType0,
typename ArgType1,
typename ArgType2>
348 struct result_of<Func(ArgType0,ArgType1,ArgType2)> {
350 static has_std_result_type testFunctor(T
const *,
typename T::result_type
const * = 0);
352 static has_tr1_result testFunctor(T
const *,
typename T::template result<T(ArgType0,ArgType1,ArgType2)>::type
const * = 0);
353 static has_none testFunctor(...);
356 enum {FunctorType =
sizeof(testFunctor(static_cast<Func*>(0)))};
357 typedef typename ternary_result_of_select<Func, ArgType0, ArgType1, ArgType2, FunctorType>::type type;
362 template <
typename T>
363 struct has_ReturnType
368 template <
typename C>
static yes& testFunctor(C
const *,
typename C::ReturnType
const * = 0);
369 static no& testFunctor(...);
371 static const bool value =
sizeof(testFunctor(static_cast<T*>(0))) ==
sizeof(yes);
379 int SupX = ((Y==1) ? 1 : Y/2),
380 bool Done = ((SupX-InfX)<=1 ?
true : ((SupX*SupX <= Y) && ((SupX+1)*(SupX+1) > Y))) >
385 MidX = (InfX+SupX)/2,
386 TakeInf = MidX*MidX > Y ? 1 : 0,
387 NewInf =
int(TakeInf) ? InfX : int(MidX),
388 NewSup = int(TakeInf) ? int(MidX) : SupX
391 enum { ret = meta_sqrt<Y,NewInf,NewSup>::ret };
394 template<
int Y,
int InfX,
int SupX>
395 class meta_sqrt<Y, InfX, SupX, true> {
public:
enum { ret = (SupX*SupX <= Y) ? SupX : InfX }; };
402 template<
int A,
int B,
int K=1,
bool Done = ((A*K)%B)==0>
403 struct meta_least_common_multiple
405 enum { ret = meta_least_common_multiple<A,B,K+1>::ret };
407 template<
int A,
int B,
int K>
408 struct meta_least_common_multiple<A,B,K,true>
414 template<
typename T,
typename U>
struct scalar_product_traits
416 enum { Defined = 0 };
429 #if defined(__CUDA_ARCH__) 430 template<
typename T> EIGEN_DEVICE_FUNC
void swap(T &a, T &b) { T tmp = b; b = a; a = tmp; }
432 template<
typename T> EIGEN_STRONG_INLINE
void swap(T &a, T &b) { std::swap(a,b); }
435 #if defined(__CUDA_ARCH__) 436 using internal::device::numeric_limits;
438 using std::numeric_limits;
444 T div_ceil(
const T &a,
const T &b)
453 #endif // EIGEN_META_H Namespace containing all symbols from the Eigen library.
Definition: Core:271
Definition: Eigen_Colamd.h:50