1 #ifndef MATHUTILITIES_H 2 #define MATHUTILITIES_H 4 #include "../conversion/types.h" 17 template <
typename T> constexpr T
min(T first, T second)
19 return first < second ? first : second;
23 template <
typename T1,
typename... T2> constexpr T1
min(T1 first, T1 second, T2... remaining)
25 return first < second ?
min(first, remaining...) :
min(second, remaining...);
29 template <
typename T> constexpr T
max(T first, T second)
31 return first > second ? first : second;
35 template <
typename T1,
typename... T2> constexpr T1
max(T1 first, T1 second, T2... remaining)
37 return first > second ?
max(first, remaining...) :
max(second, remaining...);
42 #endif // MATHUTILITIES_H CPP_UTILITIES_EXPORT int factorial(int number)
Returns the factorial of the given number.
CPP_UTILITIES_EXPORT uint64 orderModulo(uint64 number, uint64 module)
Computes the order of number modulo module.
std::int64_t int64
signed 64-bit integer
#define CPP_UTILITIES_EXPORT
CPP_UTILITIES_EXPORT int64 inverseModulo(int64 number, int64 module)
Computes the inverse of number modulo module.
Contains various mathematical functions.
std::uint64_t uint64
unsigned 64-bit integer
CPP_UTILITIES_EXPORT int random(int lowerbounds, int upperbounds)
Returns a pseudo random number between lowerbounds and upperbounds.
constexpr T max(T first, T second)
Returns the greatest of the given items.
CPP_UTILITIES_EXPORT int digitsum(int number, int base=10)
Returns the digitsum of the given number using the specified base.
constexpr T min(T first, T second)
Returns the smallest of the given items.
CPP_UTILITIES_EXPORT uint64 powerModulo(uint64 base, uint64 expontent, uint64 module)
Computes base power exponent modulo module.