48 #ifndef _SUPER4PCS_ACCELERATORS_UTILS_H_ 49 #define _SUPER4PCS_ACCELERATORS_UTILS_H_ 53 #define M_PI 3.14159265358979323846 61 template<
typename baseT,
typename expoT>
62 constexpr baseT
POW(baseT base, expoT expo)
64 return (expo != 0 )? base *
POW(base, expo -1) : 1;
78 template <
bool enable>
84 template <
class IndexT,
class SizeT>
86 constexpr IndexT
validate(
const IndexT& n,
92 template <
class IndexT,
class SizeT>
94 constexpr
bool _test(
const IndexT& n,
const SizeT& gsize){
100 template <
class IndexT,
class SizeT>
107 throw std::out_of_range(
108 std::string(
"[IndexValidator] ") +
110 std::string(
" bigger than ") +
111 std::to_string(gsize) );
115 template <
class IndexT,
class SizeT>
139 template<
bool val
idate,
class ndIndexT,
class IndexT,
class SizeT>
140 constexpr
inline IndexT
146 UnrollIndexLoop<validate>(coord, cdim-1, gsize) )
163 template<
bool val
idate,
class ndIndexT,
class IndexT,
class SizeT>
164 constexpr
inline IndexT
166 const ndIndexT& offset,
171 UnrollIndexLoop<validate>(coord, offset, cdim-1, gsize) )
Helper structure used to (conditionnaly) validate indices.
Definition: utils.h:79
constexpr baseT POW(baseT base, expoT expo)
Compile time pow.
Definition: utils.h:62
static constexpr bool _test(const IndexT &n, const SizeT &gsize)
Test used internally to validate the input index.
Definition: utils.h:94
static constexpr IndexT validate(const IndexT &n, const SizeT &gsize)
Check if n is within [0:gsize] if enable=true.
constexpr IndexT UnrollIndexLoop(const ndIndexT &coord, IndexT cdim, SizeT gsize)
Convert a normalized n-d vector to a linear index in a uniform regular grid This function is recursiv...
Definition: utils.h:141