provides some generic functions for non-standard arithmetic operations
#include <AUtils.h>
Static Public Member Functions | |
template<class T > | |
static T | max (T a, T b) |
template<class T > | |
static T | min (T a, T b) |
template<class T > | |
static T | div_roundup (T a, T b) |
template<class T > | |
static T | bminus (T a, T b) |
template<class T , T top> | |
static T | bplus (T a, T b) |
template<class T > | |
static T | bplus (T a, T b, T top) |
template<class T , class CTYPE > | |
static T | modsum (T *s, CTYPE n, T m) |
template<class IT , class FT > | |
static IT | roundup (FT x) |
template<class T > | |
static T | log2_ceil (T n) |
T AUtils::bminus | ( | T | a, | |
T | b | |||
) | [inline, static] |
substraction with the modification to return 0 (T()) for negative difference (needs >, -, T())
T AUtils::bplus | ( | T | a, | |
T | b, | |||
T | top | |||
) | [inline, static] |
T AUtils::bplus | ( | T | a, | |
T | b | |||
) | [inline, static] |
addition with the modification to return top for sums that are larger than top
T AUtils::div_roundup | ( | T | a, | |
T | b | |||
) | [inline, static] |
returns a divided through b rounded up to nearest "integer" (needs =, --, +, /)
T AUtils::log2_ceil | ( | T | n | ) | [inline, static] |
compute 2-logarithm of n (rounded up to nearest int), i.e. number of bits needed to store values from {0,...,n-1}
T AUtils::max | ( | T | a, | |
T | b | |||
) | [inline, static] |
return the maximum of a and b (needs >)
T AUtils::min | ( | T | a, | |
T | b | |||
) | [inline, static] |
return the minimum of a and b (needs <)
T AUtils::modsum | ( | T * | s, | |
CTYPE | n, | |||
T | m | |||
) | [inline, static] |
calculate the sum s[0]+...s[n-1] modulo m (needs =, +, % for T and =, CTYPE(), <, ++ for CTYPE)
IT AUtils::roundup | ( | FT | x | ) | [inline, static] |
round up x to nearest integer