QccMathMax(x, y)
QccMathMin(x, y)
QccMathPercent(x, y)
QccMathModulus(x,
y)
QccMathLog2(x)
QccMathMedian(a, b, c)
double QccMathRand(void);
double QccMathRandNormal(void);
double QccMathGaussianDensity(double
x, double variance, double mean);
double QccMathLaplacianDensity(double
x, double variance, double mean);
#define QccMathMax(x, y) (((x) >= (y)) ? (x) : (y))
QccMathMin() returns the minimum of two numbers. It is a macro defined as
#define QccMathMax(x, y) (((x) <= (y)) ? (x) : (y))
QccMathPercent() returns the percentage that x is of y. It is a macro defined as
#define QccMathPercent(x, y) (((double)(x)/(y))*100.0)
QccMathModulus() is a macro that calculates the signed remainder of x after division with y. If y is nonzero, QccMathModulus() calculates
If y is zero, QccMathModulus() simply evaluates to x. x and y can be integers or floating point.x - y * floor(x/y)
QccMathLog2() is a macro that calculates the logarithm base 2 of x.
QccMathMedian() is a macro that calculates the median of the three values a, b, and c.
QccMathRand() is a wrapper around random(3) that ensures that random(3) is properly seeded (by calling srandom(3) with the current time) the first time that QccMathRand() is called. The return value of QccMathRand() is approximately uniformly distributed on the interval [0.0, 1.0]. Warning: Although QccMathRand() is MT-safe if the QccPack library is compiled with thread support enabled, the underlying random(3) and srandom(3) functions are not MT-safe in typical systems. The implication is that multithreaded application programs must not mix calls to random(3) and srandom(3) with calls to QccMathRand(). Use QccMathRand() exclusively in all threads.
QccMathRandNormal() returns a random number distributed according to a normal density of mean 0 and unit variance. The Box-Muller method is used to transform a pair of uniformly distributed values (as generated by QccMathRand()) into a normally distributed value.
QccMathGaussianDensity() returns the value of the Gaussian (normal) density function with the given variance and mean. It is equivalent to
return(exp((-(x - mean)*(x - mean))/2/variance)/sqrt(2*M_PI*variance));
QccMathLaplacianDensity() returns the value of the Laplacian density function with the given variance and mean. It is equivalent to
return(exp((-sqrt(2/variance))*fabs(x - mean))/sqrt(2*variance));