Path Tracer
Meta.h
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2008-2015 Gael Guennebaud <gael.guennebaud@inria.fr>
5 // Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
6 //
7 // This Source Code Form is subject to the terms of the Mozilla
8 // Public License v. 2.0. If a copy of the MPL was not distributed
9 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 
11 #ifndef EIGEN_META_H
12 #define EIGEN_META_H
13 
14 #if defined(EIGEN_GPU_COMPILE_PHASE)
15 
16  #include <cfloat>
17 
18  #if defined(EIGEN_CUDA_ARCH)
19  #include <math_constants.h>
20  #endif
21 
22  #if defined(EIGEN_HIP_DEVICE_COMPILE)
23  #include "Eigen/src/Core/arch/HIP/hcc/math_constants.h"
24  #endif
25 
26 #endif
27 
28 #if EIGEN_COMP_ICC>=1600 && __cplusplus >= 201103L
29 #include <cstdint>
30 #endif
31 
32 namespace Eigen {
33 
34 typedef EIGEN_DEFAULT_DENSE_INDEX_TYPE DenseIndex;
35 
42 typedef EIGEN_DEFAULT_DENSE_INDEX_TYPE Index;
43 
44 namespace internal {
45 
53 // Only recent versions of ICC complain about using ptrdiff_t to hold pointers,
54 // and older versions do not provide *intptr_t types.
55 #if EIGEN_COMP_ICC>=1600 && __cplusplus >= 201103L
56 typedef std::intptr_t IntPtr;
57 typedef std::uintptr_t UIntPtr;
58 #else
59 typedef std::ptrdiff_t IntPtr;
60 typedef std::size_t UIntPtr;
61 #endif
62 
63 struct true_type { enum { value = 1 }; };
64 struct false_type { enum { value = 0 }; };
65 
66 template<bool Condition>
68 
69 template<>
70 struct bool_constant<true> : true_type {};
71 
72 template<>
73 struct bool_constant<false> : false_type {};
74 
75 template<bool Condition, typename Then, typename Else>
76 struct conditional { typedef Then type; };
77 
78 template<typename Then, typename Else>
79 struct conditional <false, Then, Else> { typedef Else type; };
80 
81 template<typename T> struct remove_reference { typedef T type; };
82 template<typename T> struct remove_reference<T&> { typedef T type; };
83 
84 template<typename T> struct remove_pointer { typedef T type; };
85 template<typename T> struct remove_pointer<T*> { typedef T type; };
86 template<typename T> struct remove_pointer<T*const> { typedef T type; };
87 
88 template <class T> struct remove_const { typedef T 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]; };
92 
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; };
99 
100 template<typename T> struct is_arithmetic { enum { value = false }; };
101 template<> struct is_arithmetic<float> { enum { value = true }; };
102 template<> struct is_arithmetic<double> { enum { value = true }; };
103 template<> struct is_arithmetic<long double> { enum { value = true }; };
104 template<> struct is_arithmetic<bool> { enum { value = true }; };
105 template<> struct is_arithmetic<char> { enum { value = true }; };
106 template<> struct is_arithmetic<signed char> { enum { value = true }; };
107 template<> struct is_arithmetic<unsigned char> { enum { value = true }; };
108 template<> struct is_arithmetic<signed short> { enum { value = true }; };
109 template<> struct is_arithmetic<unsigned short>{ enum { value = true }; };
110 template<> struct is_arithmetic<signed int> { enum { value = true }; };
111 template<> struct is_arithmetic<unsigned int> { enum { value = true }; };
112 template<> struct is_arithmetic<signed long> { enum { value = true }; };
113 template<> struct is_arithmetic<unsigned long> { enum { value = true }; };
114 
115 template<typename T, typename U> struct is_same { enum { value = 0 }; };
116 template<typename T> struct is_same<T,T> { enum { value = 1 }; };
117 
118 template< class T >
119 struct is_void : is_same<void, typename remove_const<T>::type> {};
120 
121 #if EIGEN_HAS_CXX11
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;
125 #else
126 template<typename T> struct is_integral { enum { value = false }; };
127 template<> struct is_integral<bool> { enum { value = true }; };
128 template<> struct is_integral<char> { enum { value = true }; };
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 }; };
137 #if EIGEN_COMP_MSVC
138 template<> struct is_integral<signed __int64> { enum { value = true }; };
139 template<> struct is_integral<unsigned __int64> { enum { value = true }; };
140 #endif
141 #endif
142 
143 #if EIGEN_HAS_CXX11
144 using std::make_unsigned;
145 #else
146 // TODO: Possibly improve this implementation of make_unsigned.
147 // It is currently used only by
148 // template<typename Scalar> struct random_default_impl<Scalar, false, true>.
149 template<typename> struct make_unsigned;
150 template<> struct make_unsigned<char> { typedef unsigned char type; };
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; };
155 template<> struct make_unsigned<signed int> { typedef unsigned int 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; };
159 #if EIGEN_COMP_MSVC
160 template<> struct make_unsigned<signed __int64> { typedef unsigned __int64 type; };
161 template<> struct make_unsigned<unsigned __int64> { typedef unsigned __int64 type; };
162 #endif
163 
164 // TODO: Some platforms define int64_t as long long even for C++03. In this case
165 // we are missing the definition for make_unsigned. If we just define it, we get
166 // duplicated definitions for platforms defining int64_t as signed long for C++03
167 #endif
168 
169 template <typename T> struct add_const { typedef const T type; };
170 template <typename T> struct add_const<T&> { typedef T& type; };
171 
172 template <typename T> struct is_const { enum { value = 0 }; };
173 template <typename T> struct is_const<T const> { enum { value = 1 }; };
174 
175 template<typename T> struct add_const_on_value_type { typedef const T type; };
176 template<typename T> struct add_const_on_value_type<T&> { typedef T const& type; };
177 template<typename T> struct add_const_on_value_type<T*> { typedef T const* type; };
178 template<typename T> struct add_const_on_value_type<T* const> { typedef T const* const type; };
179 template<typename T> struct add_const_on_value_type<T const* const> { typedef T const* const type; };
180 
181 #if EIGEN_HAS_CXX11
182 
183 using std::is_convertible;
184 
185 #else
186 
187 template<typename From, typename To>
189 {
190 private:
191  struct any_conversion
192  {
193  template <typename T> any_conversion(const volatile T&);
194  template <typename T> any_conversion(T&);
195  };
196  struct yes {int a[1];};
197  struct no {int a[2];};
198 
199  template<typename T>
200  static yes test(T, int);
201 
202  template<typename T>
203  static no test(any_conversion, ...);
204 
205 public:
206  static typename internal::remove_reference<From>::type* ms_from;
207 #ifdef __INTEL_COMPILER
208  #pragma warning push
209  #pragma warning ( disable : 2259 )
210 #endif
211  enum { value = sizeof(test<To>(*ms_from, 0))==sizeof(yes) };
212 #ifdef __INTEL_COMPILER
213  #pragma warning pop
214 #endif
215 };
216 
217 template<typename From, typename To>
219 {
220  enum { value = is_convertible_impl<From,To>::value };
221 };
222 
223 template<typename T>
224 struct is_convertible<T,T&> { enum { value = false }; };
225 
226 template<typename T>
227 struct is_convertible<const T,const T&> { enum { value = true }; };
228 
229 #endif
230 
234 template<bool Condition, typename T=void> struct enable_if;
235 
236 template<typename T> struct enable_if<true,T>
237 { typedef T type; };
238 
239 #if defined(EIGEN_GPU_COMPILE_PHASE)
240 #if !defined(__FLT_EPSILON__)
241 #define __FLT_EPSILON__ FLT_EPSILON
242 #define __DBL_EPSILON__ DBL_EPSILON
243 #endif
244 
245 namespace device {
246 
247 template<typename T> struct numeric_limits
248 {
249  EIGEN_DEVICE_FUNC
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"); }
255 };
256 template<> struct numeric_limits<float>
257 {
258  EIGEN_DEVICE_FUNC
259  static float epsilon() { return __FLT_EPSILON__; }
260  EIGEN_DEVICE_FUNC
261  static float (max)() {
262  #if defined(EIGEN_CUDA_ARCH)
263  return CUDART_MAX_NORMAL_F;
264  #else
265  return HIPRT_MAX_NORMAL_F;
266  #endif
267  }
268  EIGEN_DEVICE_FUNC
269  static float (min)() { return FLT_MIN; }
270  EIGEN_DEVICE_FUNC
271  static float infinity() {
272  #if defined(EIGEN_CUDA_ARCH)
273  return CUDART_INF_F;
274  #else
275  return HIPRT_INF_F;
276  #endif
277  }
278  EIGEN_DEVICE_FUNC
279  static float quiet_NaN() {
280  #if defined(EIGEN_CUDA_ARCH)
281  return CUDART_NAN_F;
282  #else
283  return HIPRT_NAN_F;
284  #endif
285  }
286 };
287 template<> struct numeric_limits<double>
288 {
289  EIGEN_DEVICE_FUNC
290  static double epsilon() { return __DBL_EPSILON__; }
291  EIGEN_DEVICE_FUNC
292  static double (max)() { return DBL_MAX; }
293  EIGEN_DEVICE_FUNC
294  static double (min)() { return DBL_MIN; }
295  EIGEN_DEVICE_FUNC
296  static double infinity() {
297  #if defined(EIGEN_CUDA_ARCH)
298  return CUDART_INF;
299  #else
300  return HIPRT_INF;
301  #endif
302  }
303  EIGEN_DEVICE_FUNC
304  static double quiet_NaN() {
305  #if defined(EIGEN_CUDA_ARCH)
306  return CUDART_NAN;
307  #else
308  return HIPRT_NAN;
309  #endif
310  }
311 };
312 template<> struct numeric_limits<int>
313 {
314  EIGEN_DEVICE_FUNC
315  static int epsilon() { return 0; }
316  EIGEN_DEVICE_FUNC
317  static int (max)() { return INT_MAX; }
318  EIGEN_DEVICE_FUNC
319  static int (min)() { return INT_MIN; }
320 };
321 template<> struct numeric_limits<unsigned int>
322 {
323  EIGEN_DEVICE_FUNC
324  static unsigned int epsilon() { return 0; }
325  EIGEN_DEVICE_FUNC
326  static unsigned int (max)() { return UINT_MAX; }
327  EIGEN_DEVICE_FUNC
328  static unsigned int (min)() { return 0; }
329 };
330 template<> struct numeric_limits<long>
331 {
332  EIGEN_DEVICE_FUNC
333  static long epsilon() { return 0; }
334  EIGEN_DEVICE_FUNC
335  static long (max)() { return LONG_MAX; }
336  EIGEN_DEVICE_FUNC
337  static long (min)() { return LONG_MIN; }
338 };
339 template<> struct numeric_limits<unsigned long>
340 {
341  EIGEN_DEVICE_FUNC
342  static unsigned long epsilon() { return 0; }
343  EIGEN_DEVICE_FUNC
344  static unsigned long (max)() { return ULONG_MAX; }
345  EIGEN_DEVICE_FUNC
346  static unsigned long (min)() { return 0; }
347 };
348 template<> struct numeric_limits<long long>
349 {
350  EIGEN_DEVICE_FUNC
351  static long long epsilon() { return 0; }
352  EIGEN_DEVICE_FUNC
353  static long long (max)() { return LLONG_MAX; }
354  EIGEN_DEVICE_FUNC
355  static long long (min)() { return LLONG_MIN; }
356 };
357 template<> struct numeric_limits<unsigned long long>
358 {
359  EIGEN_DEVICE_FUNC
360  static unsigned long long epsilon() { return 0; }
361  EIGEN_DEVICE_FUNC
362  static unsigned long long (max)() { return ULLONG_MAX; }
363  EIGEN_DEVICE_FUNC
364  static unsigned long long (min)() { return 0; }
365 };
366 template<> struct numeric_limits<bool>
367 {
368  EIGEN_DEVICE_FUNC
369  static bool epsilon() { return false; }
370  EIGEN_DEVICE_FUNC
371  static bool (max)() { return true; }
372  EIGEN_DEVICE_FUNC
373  static bool (min)() { return false; }
374 };
375 
376 }
377 
378 #endif
379 
384 {
385  EIGEN_DEVICE_FUNC noncopyable(const noncopyable&);
386  EIGEN_DEVICE_FUNC const noncopyable& operator=(const noncopyable&);
387 protected:
388  EIGEN_DEVICE_FUNC noncopyable() {}
389  EIGEN_DEVICE_FUNC ~noncopyable() {}
390 };
391 
406 template<typename T, typename EnableIf = void> struct array_size {
407  enum { value = Dynamic };
408 };
409 
410 template<typename T> struct array_size<T,typename internal::enable_if<((T::SizeAtCompileTime&0)==0)>::type> {
411  enum { value = T::SizeAtCompileTime };
412 };
413 
414 template<typename T, int N> struct array_size<const T (&)[N]> {
415  enum { value = N };
416 };
417 template<typename T, int N> struct array_size<T (&)[N]> {
418  enum { value = N };
419 };
420 
421 #if EIGEN_HAS_CXX11
422 template<typename T, std::size_t N> struct array_size<const std::array<T,N> > {
423  enum { value = N };
424 };
425 template<typename T, std::size_t N> struct array_size<std::array<T,N> > {
426  enum { value = N };
427 };
428 #endif
429 
439 template<typename T>
440 Index size(const T& x) { return x.size(); }
441 
442 template<typename T,std::size_t N>
443 Index size(const T (&) [N]) { return N; }
444 
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;
456 };
457 #else
458 template<typename T> struct result_of { };
459 
460 struct has_none {int a[1];};
461 struct has_std_result_type {int a[2];};
462 struct has_tr1_result {int a[3];};
463 
464 template<typename Func, typename ArgType, int SizeOf=sizeof(has_none)>
465 struct unary_result_of_select {typedef typename internal::remove_all<ArgType>::type type;};
466 
467 template<typename Func, typename ArgType>
468 struct unary_result_of_select<Func, ArgType, sizeof(has_std_result_type)> {typedef typename Func::result_type type;};
469 
470 template<typename Func, typename ArgType>
471 struct unary_result_of_select<Func, ArgType, sizeof(has_tr1_result)> {typedef typename Func::template result<Func(ArgType)>::type type;};
472 
473 template<typename Func, typename ArgType>
474 struct result_of<Func(ArgType)> {
475  template<typename T>
476  static has_std_result_type testFunctor(T const *, typename T::result_type const * = 0);
477  template<typename T>
478  static has_tr1_result testFunctor(T const *, typename T::template result<T(ArgType)>::type const * = 0);
479  static has_none testFunctor(...);
480 
481  // note that the following indirection is needed for gcc-3.3
482  enum {FunctorType = sizeof(testFunctor(static_cast<Func*>(0)))};
483  typedef typename unary_result_of_select<Func, ArgType, FunctorType>::type type;
484 };
485 
486 template<typename Func, typename ArgType0, typename ArgType1, int SizeOf=sizeof(has_none)>
487 struct binary_result_of_select {typedef typename internal::remove_all<ArgType0>::type type;};
488 
489 template<typename Func, typename ArgType0, typename ArgType1>
490 struct binary_result_of_select<Func, ArgType0, ArgType1, sizeof(has_std_result_type)>
491 {typedef typename Func::result_type type;};
492 
493 template<typename Func, typename ArgType0, typename ArgType1>
494 struct binary_result_of_select<Func, ArgType0, ArgType1, sizeof(has_tr1_result)>
495 {typedef typename Func::template result<Func(ArgType0,ArgType1)>::type type;};
496 
497 template<typename Func, typename ArgType0, typename ArgType1>
498 struct result_of<Func(ArgType0,ArgType1)> {
499  template<typename T>
500  static has_std_result_type testFunctor(T const *, typename T::result_type const * = 0);
501  template<typename T>
502  static has_tr1_result testFunctor(T const *, typename T::template result<T(ArgType0,ArgType1)>::type const * = 0);
503  static has_none testFunctor(...);
504 
505  // note that the following indirection is needed for gcc-3.3
506  enum {FunctorType = sizeof(testFunctor(static_cast<Func*>(0)))};
507  typedef typename binary_result_of_select<Func, ArgType0, ArgType1, FunctorType>::type type;
508 };
509 
510 template<typename Func, typename ArgType0, typename ArgType1, typename ArgType2, int SizeOf=sizeof(has_none)>
511 struct ternary_result_of_select {typedef typename internal::remove_all<ArgType0>::type type;};
512 
513 template<typename Func, typename ArgType0, typename ArgType1, typename ArgType2>
514 struct ternary_result_of_select<Func, ArgType0, ArgType1, ArgType2, sizeof(has_std_result_type)>
515 {typedef typename Func::result_type type;};
516 
517 template<typename Func, typename ArgType0, typename ArgType1, typename ArgType2>
518 struct ternary_result_of_select<Func, ArgType0, ArgType1, ArgType2, sizeof(has_tr1_result)>
519 {typedef typename Func::template result<Func(ArgType0,ArgType1,ArgType2)>::type type;};
520 
521 template<typename Func, typename ArgType0, typename ArgType1, typename ArgType2>
522 struct result_of<Func(ArgType0,ArgType1,ArgType2)> {
523  template<typename T>
524  static has_std_result_type testFunctor(T const *, typename T::result_type const * = 0);
525  template<typename T>
526  static has_tr1_result testFunctor(T const *, typename T::template result<T(ArgType0,ArgType1,ArgType2)>::type const * = 0);
527  static has_none testFunctor(...);
528 
529  // note that the following indirection is needed for gcc-3.3
530  enum {FunctorType = sizeof(testFunctor(static_cast<Func*>(0)))};
531  typedef typename ternary_result_of_select<Func, ArgType0, ArgType1, ArgType2, FunctorType>::type type;
532 };
533 #endif
534 
535 struct meta_yes { char a[1]; };
536 struct meta_no { char a[2]; };
537 
538 // Check whether T::ReturnType does exist
539 template <typename T>
541 {
542  template <typename C> static meta_yes testFunctor(C const *, typename C::ReturnType const * = 0);
543  template <typename C> static meta_no testFunctor(...);
544 
545  enum { value = sizeof(testFunctor<T>(static_cast<T*>(0))) == sizeof(meta_yes) };
546 };
547 
548 template<typename T> const T* return_ptr();
549 
550 template <typename T, typename IndexType=Index>
552 {
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(...);
555 
556  enum { value = sizeof(testFunctor(static_cast<T*>(0))) == sizeof(meta_yes) };
557 };
558 
559 template <typename T, typename IndexType=Index>
561 {
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(...);
564 
565  enum { value = sizeof(testFunctor(static_cast<T*>(0))) == sizeof(meta_yes) };
566 };
567 
568 template <typename T, typename IndexType=Index>
570 {
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(...);
573 
574  enum { value = sizeof(testFunctor(static_cast<T*>(0))) == sizeof(meta_yes) };
575 };
576 
580 template<int Y,
581  int InfX = 0,
582  int SupX = ((Y==1) ? 1 : Y/2),
583  bool Done = ((SupX-InfX)<=1 ? true : ((SupX*SupX <= Y) && ((SupX+1)*(SupX+1) > Y))) >
584  // use ?: instead of || just to shut up a stupid gcc 4.3 warning
586 {
587  enum {
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
592  };
593  public:
594  enum { ret = meta_sqrt<Y,NewInf,NewSup>::ret };
595 };
596 
597 template<int Y, int InfX, int SupX>
598 class meta_sqrt<Y, InfX, SupX, true> { public: enum { ret = (SupX*SupX <= Y) ? SupX : InfX }; };
599 
600 
605 template<int A, int B, int K=1, bool Done = ((A*K)%B)==0>
607 {
609 };
610 template<int A, int B, int K>
611 struct meta_least_common_multiple<A,B,K,true>
612 {
613  enum { ret = A*K };
614 };
615 
617 template<typename T, typename U> struct scalar_product_traits
618 {
619  enum { Defined = 0 };
620 };
621 
622 // FIXME quick workaround around current limitation of result_of
623 // template<typename Scalar, typename ArgType0, typename ArgType1>
624 // struct result_of<scalar_product_op<Scalar>(ArgType0,ArgType1)> {
625 // typedef typename scalar_product_traits<typename remove_all<ArgType0>::type, typename remove_all<ArgType1>::type>::ReturnType type;
626 // };
627 
631 template<unsigned Len, unsigned Align>
633  struct type {
634  EIGEN_ALIGN_TO_BOUNDARY(Align) unsigned char data[Len];
635  };
636 };
637 
638 } // end namespace internal
639 
640 namespace numext {
641 
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; }
644 #else
645 template<typename T> EIGEN_STRONG_INLINE void swap(T &a, T &b) { std::swap(a,b); }
646 #endif
647 
648 #if defined(EIGEN_GPU_COMPILE_PHASE)
649 using internal::device::numeric_limits;
650 #else
651 using std::numeric_limits;
652 #endif
653 
654 // Integer division with rounding up.
655 // T is assumed to be an integer type with a>=0, and b>0
656 template<typename T>
657 EIGEN_DEVICE_FUNC
658 T div_ceil(const T &a, const T &b)
659 {
660  return (a+b-1) / b;
661 }
662 
663 // The aim of the following functions is to bypass -Wfloat-equal warnings
664 // when we really want a strict equality comparison on floating points.
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; }
667 
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); }
671 
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); }
674 #endif
675 
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; }
678 
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); }
682 
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); }
685 #endif
686 
687 } // end namespace numext
688 
689 } // end namespace Eigen
690 
691 // Define portable (u)int{32,64} types
692 #if EIGEN_HAS_CXX11
693 #include <cstdint>
694 namespace Eigen {
695 namespace numext {
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;
704 }
705 }
706 #else
707 // Without c++11, all compilers able to compile Eigen also
708 // provides the C99 stdint.h header file.
709 #include <stdint.h>
710 namespace Eigen {
711 namespace numext {
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;
720 }
721 }
722 #endif
723 
724 #endif // EIGEN_META_H
Eigen
Namespace containing all symbols from the Eigen library.
Definition: LDLT.h:16
Eigen::internal::noncopyable
Definition: Meta.h:384
Eigen::internal::meta_sqrt
Definition: Meta.h:586
Eigen::internal::meta_no
Definition: Meta.h:536
Eigen::internal::remove_all
Definition: Meta.h:93
Eigen::internal::unary_result_of_select
Definition: Meta.h:465
Eigen::internal::false_type
Definition: Meta.h:64
Eigen::internal::scalar_product_traits
Definition: Meta.h:618
Eigen::internal::has_ReturnType
Definition: Meta.h:541
Eigen::internal::has_binary_operator
Definition: Meta.h:570
Eigen::internal::is_convertible
Definition: Meta.h:219
Eigen::internal::aligned_storage::type
Definition: Meta.h:633
Eigen::internal::true_type
Definition: Meta.h:63
Eigen::internal::remove_pointer
Definition: Meta.h:84
Eigen::internal::remove_const
Definition: Meta.h:88
Eigen::internal::binary_result_of_select
Definition: Meta.h:487
Eigen::Dynamic
const int Dynamic
Definition: Constants.h:21
Eigen::Diagonal
Expression of a diagonal/subdiagonal/superdiagonal in a matrix.
Definition: Diagonal.h:65
Eigen::internal::add_const
Definition: Meta.h:169
Eigen::internal::is_convertible_impl
Definition: Meta.h:189
Eigen::internal::remove_reference
Definition: Meta.h:81
Eigen::internal::is_integral
Definition: Meta.h:126
Eigen::internal::array_size
Definition: Meta.h:406
Eigen::internal::has_std_result_type
Definition: Meta.h:461
Eigen::internal::ternary_result_of_select
Definition: Meta.h:511
Eigen::internal::conditional
Definition: Meta.h:76
Eigen::internal::has_none
Definition: Meta.h:460
Eigen::internal::result_of
Definition: Meta.h:458
Eigen::internal::has_unary_operator
Definition: Meta.h:561
Eigen::internal::is_same
Definition: Meta.h:115
Eigen::internal::is_void
Definition: Meta.h:119
Eigen::internal::is_const
Definition: Meta.h:172
Eigen::internal::meta_yes
Definition: Meta.h:535
Eigen::internal::enable_if
Definition: Meta.h:234
Eigen::internal::aligned_storage
Definition: Meta.h:632
Eigen::internal::has_nullary_operator
Definition: Meta.h:552
Eigen::internal::has_tr1_result
Definition: Meta.h:462
Eigen::internal::make_unsigned
Definition: Meta.h:149
Eigen::internal::meta_least_common_multiple
Definition: Meta.h:607
Eigen::internal::bool_constant
Definition: Meta.h:67
Eigen::internal::is_arithmetic
Definition: Meta.h:100
Eigen::Index
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:42
Eigen::internal::add_const_on_value_type
Definition: Meta.h:175