14 #if defined(__CUDA_ARCH__) 16 #include <math_constants.h> 19 #if EIGEN_COMP_ICC>=1600 && __cplusplus >= 201103L 25 typedef EIGEN_DEFAULT_DENSE_INDEX_TYPE DenseIndex;
33 typedef EIGEN_DEFAULT_DENSE_INDEX_TYPE
Index;
46 #if EIGEN_COMP_ICC>=1600 && __cplusplus >= 201103L 47 typedef std::intptr_t IntPtr;
48 typedef std::uintptr_t UIntPtr;
50 typedef std::ptrdiff_t IntPtr;
51 typedef std::size_t UIntPtr;
54 struct true_type {
enum { value = 1 }; };
55 struct false_type {
enum { value = 0 }; };
57 template<
bool Condition,
typename Then,
typename Else>
58 struct conditional {
typedef Then type; };
60 template<
typename Then,
typename Else>
61 struct conditional <false, Then, Else> {
typedef Else type; };
63 template<
typename T,
typename U>
struct is_same {
enum { value = 0 }; };
64 template<
typename T>
struct is_same<T,T> {
enum { value = 1 }; };
66 template<
typename T>
struct remove_reference {
typedef T type; };
67 template<
typename T>
struct remove_reference<T&> {
typedef T type; };
69 template<
typename T>
struct remove_pointer {
typedef T type; };
70 template<
typename T>
struct remove_pointer<T*> {
typedef T type; };
71 template<
typename T>
struct remove_pointer<T*
const> {
typedef T type; };
73 template <
class T>
struct remove_const {
typedef T type; };
74 template <
class T>
struct remove_const<const T> {
typedef T type; };
75 template <
class T>
struct remove_const<const T[]> {
typedef T type[]; };
76 template <
class T,
unsigned int Size>
struct remove_const<const T[Size]> {
typedef T type[Size]; };
78 template<
typename T>
struct remove_all {
typedef T type; };
79 template<
typename T>
struct remove_all<const T> {
typedef typename remove_all<T>::type type; };
80 template<
typename T>
struct remove_all<T const&> {
typedef typename remove_all<T>::type type; };
81 template<
typename T>
struct remove_all<T&> {
typedef typename remove_all<T>::type type; };
82 template<
typename T>
struct remove_all<T const*> {
typedef typename remove_all<T>::type type; };
83 template<
typename T>
struct remove_all<T*> {
typedef typename remove_all<T>::type type; };
85 template<
typename T>
struct is_arithmetic {
enum { value =
false }; };
86 template<>
struct is_arithmetic<float> {
enum { value =
true }; };
87 template<>
struct is_arithmetic<double> {
enum { value =
true }; };
88 template<>
struct is_arithmetic<long double> {
enum { value =
true }; };
89 template<>
struct is_arithmetic<bool> {
enum { value =
true }; };
90 template<>
struct is_arithmetic<char> {
enum { value =
true }; };
91 template<>
struct is_arithmetic<signed char> {
enum { value =
true }; };
92 template<>
struct is_arithmetic<unsigned char> {
enum { value =
true }; };
93 template<>
struct is_arithmetic<signed short> {
enum { value =
true }; };
94 template<>
struct is_arithmetic<unsigned short>{
enum { value =
true }; };
95 template<>
struct is_arithmetic<signed int> {
enum { value =
true }; };
96 template<>
struct is_arithmetic<unsigned int> {
enum { value =
true }; };
97 template<>
struct is_arithmetic<signed long> {
enum { value =
true }; };
98 template<>
struct is_arithmetic<unsigned long> {
enum { value =
true }; };
100 template<
typename T>
struct is_integral {
enum { value =
false }; };
101 template<>
struct is_integral<bool> {
enum { value =
true }; };
102 template<>
struct is_integral<char> {
enum { value =
true }; };
103 template<>
struct is_integral<signed char> {
enum { value =
true }; };
104 template<>
struct is_integral<unsigned char> {
enum { value =
true }; };
105 template<>
struct is_integral<signed short> {
enum { value =
true }; };
106 template<>
struct is_integral<unsigned short> {
enum { value =
true }; };
107 template<>
struct is_integral<signed int> {
enum { value =
true }; };
108 template<>
struct is_integral<unsigned int> {
enum { value =
true }; };
109 template<>
struct is_integral<signed long> {
enum { value =
true }; };
110 template<>
struct is_integral<unsigned long> {
enum { value =
true }; };
113 using std::make_unsigned;
118 template<
typename>
struct make_unsigned;
119 template<>
struct make_unsigned<char> {
typedef unsigned char type; };
120 template<>
struct make_unsigned<signed char> {
typedef unsigned char type; };
121 template<>
struct make_unsigned<unsigned char> {
typedef unsigned char type; };
122 template<>
struct make_unsigned<signed short> {
typedef unsigned short type; };
123 template<>
struct make_unsigned<unsigned short> {
typedef unsigned short type; };
124 template<>
struct make_unsigned<signed int> {
typedef unsigned int type; };
125 template<>
struct make_unsigned<unsigned int> {
typedef unsigned int type; };
126 template<>
struct make_unsigned<signed long> {
typedef unsigned long type; };
127 template<>
struct make_unsigned<unsigned long> {
typedef unsigned long type; };
129 template<>
struct make_unsigned<signed __int64> {
typedef unsigned __int64 type; };
130 template<>
struct make_unsigned<unsigned __int64> {
typedef unsigned __int64 type; };
134 template <
typename T>
struct add_const {
typedef const T type; };
135 template <
typename T>
struct add_const<T&> {
typedef T& type; };
137 template <
typename T>
struct is_const {
enum { value = 0 }; };
138 template <
typename T>
struct is_const<T const> {
enum { value = 1 }; };
140 template<
typename T>
struct add_const_on_value_type {
typedef const T type; };
141 template<
typename T>
struct add_const_on_value_type<T&> {
typedef T
const& type; };
142 template<
typename T>
struct add_const_on_value_type<T*> {
typedef T
const* type; };
143 template<
typename T>
struct add_const_on_value_type<T*
const> {
typedef T
const*
const type; };
144 template<
typename T>
struct add_const_on_value_type<T const*
const> {
typedef T
const*
const type; };
147 template<
typename From,
typename To>
148 struct is_convertible_impl
151 struct any_conversion
153 template <
typename T> any_conversion(
const volatile T&);
154 template <
typename T> any_conversion(T&);
156 struct yes {
int a[1];};
157 struct no {
int a[2];};
159 static yes test(
const To&,
int);
160 static no test(any_conversion, ...);
164 #ifdef __INTEL_COMPILER 166 #pragma warning ( disable : 2259 ) 168 enum { value =
sizeof(test(ms_from, 0))==
sizeof(yes) };
169 #ifdef __INTEL_COMPILER 174 template<
typename From,
typename To>
175 struct is_convertible
177 enum { value = is_convertible_impl<typename remove_all<From>::type,
178 typename remove_all<To >::type>::value };
184 template<
bool Condition,
typename T=
void>
struct enable_if;
186 template<
typename T>
struct enable_if<true,T>
189 #if defined(__CUDA_ARCH__) 190 #if !defined(__FLT_EPSILON__) 191 #define __FLT_EPSILON__ FLT_EPSILON 192 #define __DBL_EPSILON__ DBL_EPSILON 197 template<
typename T>
struct numeric_limits
200 static T epsilon() {
return 0; }
201 static T (max)() { assert(
false &&
"Highest not supported for this type"); }
202 static T (min)() { assert(
false &&
"Lowest not supported for this type"); }
203 static T infinity() { assert(
false &&
"Infinity not supported for this type"); }
204 static T quiet_NaN() { assert(
false &&
"quiet_NaN not supported for this type"); }
206 template<>
struct numeric_limits<float>
209 static float epsilon() {
return __FLT_EPSILON__; }
211 static float (max)() {
return CUDART_MAX_NORMAL_F; }
213 static float (min)() {
return FLT_MIN; }
215 static float infinity() {
return CUDART_INF_F; }
217 static float quiet_NaN() {
return CUDART_NAN_F; }
219 template<>
struct numeric_limits<double>
222 static double epsilon() {
return __DBL_EPSILON__; }
224 static double (max)() {
return DBL_MAX; }
226 static double (min)() {
return DBL_MIN; }
228 static double infinity() {
return CUDART_INF; }
230 static double quiet_NaN() {
return CUDART_NAN; }
232 template<>
struct numeric_limits<int>
235 static int epsilon() {
return 0; }
237 static int (max)() {
return INT_MAX; }
239 static int (min)() {
return INT_MIN; }
241 template<>
struct numeric_limits<unsigned int>
244 static unsigned int epsilon() {
return 0; }
246 static unsigned int (max)() {
return UINT_MAX; }
248 static unsigned int (min)() {
return 0; }
250 template<>
struct numeric_limits<long>
253 static long epsilon() {
return 0; }
255 static long (max)() {
return LONG_MAX; }
257 static long (min)() {
return LONG_MIN; }
259 template<>
struct numeric_limits<unsigned long>
262 static unsigned long epsilon() {
return 0; }
264 static unsigned long (max)() {
return ULONG_MAX; }
266 static unsigned long (min)() {
return 0; }
268 template<>
struct numeric_limits<long long>
271 static long long epsilon() {
return 0; }
273 static long long (max)() {
return LLONG_MAX; }
275 static long long (min)() {
return LLONG_MIN; }
277 template<>
struct numeric_limits<unsigned long long>
280 static unsigned long long epsilon() {
return 0; }
282 static unsigned long long (max)() {
return ULLONG_MAX; }
284 static unsigned long long (min)() {
return 0; }
296 EIGEN_DEVICE_FUNC noncopyable(
const noncopyable&);
297 EIGEN_DEVICE_FUNC
const noncopyable& operator=(
const noncopyable&);
299 EIGEN_DEVICE_FUNC noncopyable() {}
300 EIGEN_DEVICE_FUNC ~noncopyable() {}
310 #if EIGEN_HAS_STD_RESULT_OF 311 template<
typename T>
struct result_of {
312 typedef typename std::result_of<T>::type type1;
313 typedef typename remove_all<type1>::type type;
316 template<
typename T>
struct result_of { };
318 struct has_none {
int a[1];};
319 struct has_std_result_type {
int a[2];};
320 struct has_tr1_result {
int a[3];};
322 template<
typename Func,
typename ArgType,
int SizeOf=sizeof(has_none)>
323 struct unary_result_of_select {
typedef typename internal::remove_all<ArgType>::type type;};
325 template<
typename Func,
typename ArgType>
326 struct unary_result_of_select<Func, ArgType, sizeof(has_std_result_type)> {
typedef typename Func::result_type type;};
328 template<
typename Func,
typename ArgType>
329 struct unary_result_of_select<Func, ArgType, sizeof(has_tr1_result)> {
typedef typename Func::template result<Func(ArgType)>::type type;};
331 template<
typename Func,
typename ArgType>
332 struct result_of<Func(ArgType)> {
334 static has_std_result_type testFunctor(T
const *,
typename T::result_type
const * = 0);
336 static has_tr1_result testFunctor(T
const *,
typename T::template result<T(ArgType)>::type
const * = 0);
337 static has_none testFunctor(...);
340 enum {FunctorType =
sizeof(testFunctor(static_cast<Func*>(0)))};
341 typedef typename unary_result_of_select<Func, ArgType, FunctorType>::type type;
344 template<
typename Func,
typename ArgType0,
typename ArgType1,
int SizeOf=sizeof(has_none)>
345 struct binary_result_of_select {
typedef typename internal::remove_all<ArgType0>::type type;};
347 template<
typename Func,
typename ArgType0,
typename ArgType1>
348 struct binary_result_of_select<Func, ArgType0, ArgType1, sizeof(has_std_result_type)>
349 {
typedef typename Func::result_type type;};
351 template<
typename Func,
typename ArgType0,
typename ArgType1>
352 struct binary_result_of_select<Func, ArgType0, ArgType1, sizeof(has_tr1_result)>
353 {
typedef typename Func::template result<Func(ArgType0,ArgType1)>::type type;};
355 template<
typename Func,
typename ArgType0,
typename ArgType1>
356 struct result_of<Func(ArgType0,ArgType1)> {
358 static has_std_result_type testFunctor(T
const *,
typename T::result_type
const * = 0);
360 static has_tr1_result testFunctor(T
const *,
typename T::template result<T(ArgType0,ArgType1)>::type
const * = 0);
361 static has_none testFunctor(...);
364 enum {FunctorType =
sizeof(testFunctor(static_cast<Func*>(0)))};
365 typedef typename binary_result_of_select<Func, ArgType0, ArgType1, FunctorType>::type type;
368 template<
typename Func,
typename ArgType0,
typename ArgType1,
typename ArgType2,
int SizeOf=sizeof(has_none)>
369 struct ternary_result_of_select {
typedef typename internal::remove_all<ArgType0>::type type;};
371 template<
typename Func,
typename ArgType0,
typename ArgType1,
typename ArgType2>
372 struct ternary_result_of_select<Func, ArgType0, ArgType1, ArgType2, sizeof(has_std_result_type)>
373 {
typedef typename Func::result_type type;};
375 template<
typename Func,
typename ArgType0,
typename ArgType1,
typename ArgType2>
376 struct ternary_result_of_select<Func, ArgType0, ArgType1, ArgType2, sizeof(has_tr1_result)>
377 {
typedef typename Func::template result<Func(ArgType0,ArgType1,ArgType2)>::type type;};
379 template<
typename Func,
typename ArgType0,
typename ArgType1,
typename ArgType2>
380 struct result_of<Func(ArgType0,ArgType1,ArgType2)> {
382 static has_std_result_type testFunctor(T
const *,
typename T::result_type
const * = 0);
384 static has_tr1_result testFunctor(T
const *,
typename T::template result<T(ArgType0,ArgType1,ArgType2)>::type
const * = 0);
385 static has_none testFunctor(...);
388 enum {FunctorType =
sizeof(testFunctor(static_cast<Func*>(0)))};
389 typedef typename ternary_result_of_select<Func, ArgType0, ArgType1, ArgType2, FunctorType>::type type;
393 struct meta_yes {
char a[1]; };
394 struct meta_no {
char a[2]; };
397 template <
typename T>
398 struct has_ReturnType
400 template <
typename C>
static meta_yes testFunctor(
typename C::ReturnType
const *);
401 template <
typename C>
static meta_no testFunctor(...);
403 enum { value =
sizeof(testFunctor<T>(0)) ==
sizeof(meta_yes) };
406 template<
typename T>
const T* return_ptr();
408 template <
typename T,
typename IndexType=Index>
409 struct has_nullary_operator
411 template <
typename C>
static meta_yes testFunctor(C
const *,
typename enable_if<(
sizeof(return_ptr<C>()->
operator()())>0)>::type * = 0);
412 static meta_no testFunctor(...);
414 enum { value =
sizeof(testFunctor(static_cast<T*>(0))) ==
sizeof(meta_yes) };
417 template <
typename T,
typename IndexType=Index>
418 struct has_unary_operator
420 template <
typename C>
static meta_yes testFunctor(C
const *,
typename enable_if<(
sizeof(return_ptr<C>()->
operator()(IndexType(0)))>0)>::type * = 0);
421 static meta_no testFunctor(...);
423 enum { value =
sizeof(testFunctor(static_cast<T*>(0))) ==
sizeof(meta_yes) };
426 template <
typename T,
typename IndexType=Index>
427 struct has_binary_operator
429 template <
typename C>
static meta_yes testFunctor(C
const *,
typename enable_if<(
sizeof(return_ptr<C>()->
operator()(IndexType(0),IndexType(0)))>0)>::type * = 0);
430 static meta_no testFunctor(...);
432 enum { value =
sizeof(testFunctor(static_cast<T*>(0))) ==
sizeof(meta_yes) };
440 int SupX = ((Y==1) ? 1 : Y/2),
441 bool Done = ((SupX-InfX)<=1 ?
true : ((SupX*SupX <= Y) && ((SupX+1)*(SupX+1) > Y))) >
446 MidX = (InfX+SupX)/2,
447 TakeInf = MidX*MidX > Y ? 1 : 0,
448 NewInf =
int(TakeInf) ? InfX : int(MidX),
449 NewSup = int(TakeInf) ? int(MidX) : SupX
452 enum { ret = meta_sqrt<Y,NewInf,NewSup>::ret };
455 template<
int Y,
int InfX,
int SupX>
456 class meta_sqrt<Y, InfX, SupX, true> {
public:
enum { ret = (SupX*SupX <= Y) ? SupX : InfX }; };
463 template<
int A,
int B,
int K=1,
bool Done = ((A*K)%B)==0>
464 struct meta_least_common_multiple
466 enum { ret = meta_least_common_multiple<A,B,K+1>::ret };
468 template<
int A,
int B,
int K>
469 struct meta_least_common_multiple<A,B,K,true>
475 template<
typename T,
typename U>
struct scalar_product_traits
477 enum { Defined = 0 };
490 #if defined(__CUDA_ARCH__) 491 template<
typename T> EIGEN_DEVICE_FUNC
void swap(T &a, T &b) { T tmp = b; b = a; a = tmp; }
493 template<
typename T> EIGEN_STRONG_INLINE
void swap(T &a, T &b) { std::swap(a,b); }
496 #if defined(__CUDA_ARCH__) 497 using internal::device::numeric_limits;
499 using std::numeric_limits;
505 T div_ceil(
const T &a,
const T &b)
512 template<
typename X,
typename Y> EIGEN_STRONG_INLINE
513 bool equal_strict(
const X& x,
const Y& y) {
return x == y; }
515 template<> EIGEN_STRONG_INLINE
516 bool equal_strict(
const float& x,
const float& y) {
return std::equal_to<float>()(x,y); }
518 template<> EIGEN_STRONG_INLINE
519 bool equal_strict(
const double& x,
const double& y) {
return std::equal_to<double>()(x,y); }
521 template<
typename X,
typename Y> EIGEN_STRONG_INLINE
522 bool not_equal_strict(
const X& x,
const Y& y) {
return x != y; }
524 template<> EIGEN_STRONG_INLINE
525 bool not_equal_strict(
const float& x,
const float& y) {
return std::not_equal_to<float>()(x,y); }
527 template<> EIGEN_STRONG_INLINE
528 bool not_equal_strict(
const double& x,
const double& y) {
return std::not_equal_to<double>()(x,y); }
534 #endif // EIGEN_META_H Namespace containing all symbols from the Eigen library.
Definition: Core:306
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:33
Definition: Eigen_Colamd.h:50