4 #ifdef HAVE_LIBQUADMATH 5 #include <boost/multiprecision/float128.hpp> 8 #include "util/cuda_util.hpp" 24 return (T(0) < val) - (val < T(0));
38 static inline size_t factorial(
size_t f)
42 for (
size_t s = 2 ; s <= f ; s++)
63 static inline size_t C(
size_t n,
size_t k)
65 return factorial(n)/(factorial(k)*factorial(n-k));
78 static inline size_t round_big_2(
size_t n)
105 inline constexpr
size_t pow(
const T base,
unsigned const exponent)
108 return (exponent == 0) ? 1 : (base * pow(base, exponent-1));
112 double intpowlog(
const T x,
unsigned const e)
114 if (e == 0)
return 1.0;
117 double h = intpowlog(x, e / 2);
122 double h = intpowlog(x, e / 2);
138 static inline long int positive_modulo(
long int i,
long int n)
140 return (i % n + n) % n;
158 template<
typename T>
static inline T periodic(
const T & pos,
const T & p2,
const T & p1)
162 pos_tmp = pos - (p2 - p1) * (
long int)( (pos -p1) / (p2 - p1));
163 pos_tmp += (pos < p1)?(p2 - p1):0;
185 template<
typename T> __device__ __host__
static inline T periodic_l(
const T & pos,
const T & p2,
const T & p1)
191 pos_tmp = p1 + (pos - p2);
195 pos_tmp = p2 - (p1 - pos);
210 inline long int size_t_floor(
double x)
212 size_t i = (
long int)x;
213 return i - ( i > x );
220 inline long int size_t_floor(
float x)
222 size_t i = (
long int)x;
223 return i - ( i > x );
230 __device__ __host__
inline int uint_floor(
double x)
232 unsigned int i = (
int)x;
233 return i - ( i > x );
240 __device__ __host__
inline int uint_floor(
float x)
242 unsigned int i = (
int)x;
243 return i - ( i > x );
246 const int tab64[64] = {
247 63, 0, 58, 1, 59, 47, 53, 2,
248 60, 39, 48, 27, 54, 33, 42, 3,
249 61, 51, 37, 40, 49, 18, 28, 20,
250 55, 30, 34, 11, 43, 14, 22, 4,
251 62, 57, 46, 52, 38, 26, 32, 41,
252 50, 36, 17, 19, 29, 10, 13, 21,
253 56, 45, 25, 31, 35, 16, 9, 12,
254 44, 24, 15, 8, 23, 7, 6, 5};
261 inline int log2_64 (uint64_t value)
267 value |= value >> 16;
268 value |= value >> 32;
269 return tab64[((uint64_t)((value - (value >> 1))*0x07EDD5E59A4E28C2)) >> 58];
273 #ifdef HAVE_LIBQUADMATH 279 inline long int size_t_floor(boost::multiprecision::float128 x)
281 size_t i = (
long int)x;
282 return i - ( i > x );
convert a type into constant type
int sgn(T val)
Gets the sign of a variable.
KeyT const ValueT ValueT OffsetIteratorT OffsetIteratorT int
[in] The number of segments that comprise the sorting data