21 static inline size_t factorial(
size_t f)
25 for (
size_t s = 2 ; s <= f ; s++)
46 static inline size_t C(
size_t n,
size_t k)
48 return factorial(n)/(factorial(k)*factorial(n-k));
61 static inline size_t round_big_2(
size_t n)
88 inline constexpr T pow(
const T base,
unsigned const exponent)
91 return (exponent == 0) ? 1 : (base * pow(base, exponent-1));
103 static inline long int positive_modulo(
long int i,
long int n)
105 return (i % n + n) % n;
123 template<
typename T>
static inline T periodic(
const T & pos,
const T & p2,
const T & p1)
127 pos_tmp = pos - (p2 - p1) * (
long int)( (pos -p1) / (p2 - p1));
128 pos_tmp += (pos < p1)?(p2 - p1):0;
150 template<
typename T>
static inline T periodic_l(
const T & pos,
const T & p2,
const T & p1)
155 pos_tmp -= (p2 - p1);
157 pos_tmp += (p2 - p1);