SpeedCrunch  0.11
Static Public Member Functions
HMath Class Reference

#include <hmath.h>

List of all members.

Static Public Member Functions

static char * format (const HNumber &n, char format= 'g', int prec=-1)
static HNumber e ()
static HNumber phi ()
static HNumber pi ()
static HNumber nan (Error error=Success)
static HNumber rad2deg (const HNumber &angle)
static HNumber deg2rad (const HNumber &angle)
static HNumber max (const HNumber &n1, const HNumber &n2)
static HNumber min (const HNumber &n1, const HNumber &n2)
static HNumber abs (const HNumber &n)
static HNumber integer (const HNumber &n)
static HNumber frac (const HNumber &n)
static HNumber floor (const HNumber &n)
static HNumber ceil (const HNumber &n)
static HNumber gcd (const HNumber &n1, const HNumber &n2)
static HNumber idiv (const HNumber &n1, const HNumber &n2)
static HNumber round (const HNumber &n, int prec=0)
static HNumber trunc (const HNumber &n, int prec=0)
static HNumber sqrt (const HNumber &n)
static HNumber cbrt (const HNumber &n)
static HNumber raise (const HNumber &n1, int n)
static HNumber raise (const HNumber &n1, const HNumber &n2)
static HNumber sgn (const HNumber &x)
static HNumber exp (const HNumber &x)
static HNumber ln (const HNumber &x)
static HNumber lg (const HNumber &x)
static HNumber lb (const HNumber &x)
static HNumber log (const HNumber &base, const HNumber &x)
static HNumber sinh (const HNumber &x)
static HNumber cosh (const HNumber &x)
static HNumber tanh (const HNumber &x)
static HNumber arsinh (const HNumber &x)
static HNumber arcosh (const HNumber &x)
static HNumber artanh (const HNumber &x)
static HNumber sin (const HNumber &x)
static HNumber cos (const HNumber &x)
static HNumber tan (const HNumber &x)
static HNumber cot (const HNumber &x)
static HNumber sec (const HNumber &x)
static HNumber csc (const HNumber &x)
static HNumber arcsin (const HNumber &x)
static HNumber arccos (const HNumber &x)
static HNumber arctan (const HNumber &x)
static HNumber factorial (const HNumber &x, const HNumber &base=HNumber(1))
static HNumber gamma (const HNumber &x)
static HNumber lnGamma (const HNumber &x)
static HNumber erf (const HNumber &x)
static HNumber erfc (const HNumber &x)
static HNumber nCr (const HNumber &n, const HNumber &k)
static HNumber nPr (const HNumber &n, const HNumber &r)
static HNumber binomialPmf (const HNumber &k, const HNumber &n, const HNumber &p)
static HNumber binomialCdf (const HNumber &k, const HNumber &n, const HNumber &p)
static HNumber binomialMean (const HNumber &n, const HNumber &p)
static HNumber binomialVariance (const HNumber &n, const HNumber &p)
static HNumber hypergeometricPmf (const HNumber &k, const HNumber &N, const HNumber &M, const HNumber &n)
static HNumber hypergeometricCdf (const HNumber &k, const HNumber &N, const HNumber &M, const HNumber &n)
static HNumber hypergeometricMean (const HNumber &N, const HNumber &M, const HNumber &n)
static HNumber hypergeometricVariance (const HNumber &N, const HNumber &M, const HNumber &n)
static HNumber poissonPmf (const HNumber &k, const HNumber &l)
static HNumber poissonCdf (const HNumber &k, const HNumber &l)
static HNumber poissonMean (const HNumber &l)
static HNumber poissonVariance (const HNumber &l)
static HNumber mask (const HNumber &val, const HNumber &bits)
static HNumber sgnext (const HNumber &val, const HNumber &bits)
static HNumber ashr (const HNumber &val, const HNumber &bits)

Member Function Documentation

HNumber HMath::abs ( const HNumber n) [static]

Returns the absolute value of n.

HNumber HMath::arccos ( const HNumber x) [static]

Returns the arc cosine of x.

HNumber HMath::arcosh ( const HNumber x) [static]

Returns the area hyperbolic cosine of x.

HNumber HMath::arcsin ( const HNumber x) [static]

Returns the arc sine of x.

HNumber HMath::arctan ( const HNumber x) [static]

Returns the arc tangent of x.

HNumber HMath::arsinh ( const HNumber x) [static]

Returns the area hyperbolic sine of x.

HNumber HMath::artanh ( const HNumber x) [static]

Returns the area hyperbolic tangent of x.

HNumber HMath::ashr ( const HNumber val,
const HNumber bits 
) [static]

For bits >= 0 does an arithmetic shift right, for bits < 0 a shift left.

HNumber HMath::binomialCdf ( const HNumber k,
const HNumber n,
const HNumber p 
) [static]

Calculates the binomial cumulative distribution function:

\[X{\sim}B(n,p)\]

\[\Pr(X \leq k|n,p)=\sum_{i=0}^{k}{n\choose i}p^{i}(1-p)^{n-i}\]

Parameters:
[in]kthe maximum number of probed successes
[in]nthe number of trials
[in]pthe probability of success in a single trial
Returns:
the probability of up to k successes, otherwise NaN if the function is not defined for the specified parameters.
HNumber HMath::binomialMean ( const HNumber n,
const HNumber p 
) [static]

Calculates the expected value of a binomially distributed random variable:

\[X{\sim}B(n,p)\]

\[E(X)=np\]

Parameters:
[in]nthe number of trials
[in]pthe probability of success in a single trial
Returns:
the expected value of the variable, otherwise NaN if the function is not defined for the specified parameters.
HNumber HMath::binomialPmf ( const HNumber k,
const HNumber n,
const HNumber p 
) [static]

Calculates the binomial discrete distribution probability mass function:

\[X{\sim}B(n,p)\]

\[\Pr(X=k|n,p)={n\choose k}p^{k}(1-p)^{n-k}\]

Parameters:
[in]kthe number of probed exact successes
[in]nthe number of trials
[in]pthe probability of success in a single trial
Returns:
the probability of exactly k successes, otherwise NaN if the function is not defined for the specified parameters.
HNumber HMath::binomialVariance ( const HNumber n,
const HNumber p 
) [static]

Calculates the variance of a binomially distributed random variable:

\[X{\sim}B(n,p)\]

\[Var(X)=np(1-p)\]

Parameters:
[in]nthe number of trials
[in]pthe probability of success in a single trial
Returns:
the variance of the variable, otherwise NaN if the function is not defined for the specified parameters.
HNumber HMath::cbrt ( const HNumber n) [static]

Returns the cube root of n.

HNumber HMath::ceil ( const HNumber n) [static]

Returns the ceiling of n.

HNumber HMath::cos ( const HNumber x) [static]

Returns the cosine of x. Note that x must be in radians.

HNumber HMath::cosh ( const HNumber x) [static]

Returns the hyperbolic cosine of x.

HNumber HMath::cot ( const HNumber x) [static]

Returns the cotangent of x. Note that x must be in radians.

HNumber HMath::csc ( const HNumber x) [static]

Returns the cosecant of x. Note that x must be in radians.

HNumber HMath::deg2rad ( const HNumber angle) [static]

Converts degrees to radians.

HNumber HMath::e ( ) [static]

Returns the constant e (Euler's number).

HNumber HMath::erf ( const HNumber x) [static]

Returns the erf function (related to normal distribution).

HNumber HMath::erfc ( const HNumber x) [static]

Returns the complementary erf function (related to normal distribution).

HNumber HMath::exp ( const HNumber x) [static]

Returns e raised to x.

HNumber HMath::factorial ( const HNumber x,
const HNumber base = HNumber(1) 
) [static]

Returns the falling Pochhammer symbol x*(x-1)*..*base. For base == 1, this is the usual factorial x!, what this function is named after. This function has been extended using the Gamma function, so that actually Gamma(x+1)/Gamma(base) is computed, a value that equals the falling Pochhammer symbol, when x - base is an integer, but allows other differences as well.

HNumber HMath::floor ( const HNumber n) [static]

Returns the floor of n.

char * HMath::format ( const HNumber hn,
char  format = 'g',
int  prec = -1 
) [static]

Formats the given number as string, using specified decimal digits. Note that the returned string must be freed.

HNumber HMath::frac ( const HNumber n) [static]

Returns the fraction part of n.

HNumber HMath::gamma ( const HNumber x) [static]

Returns the Gamma function.

HNumber HMath::gcd ( const HNumber n1,
const HNumber n2 
) [static]

Returns the greatest common divisor of n1 and n2.

HNumber HMath::hypergeometricCdf ( const HNumber k,
const HNumber N,
const HNumber M,
const HNumber n 
) [static]

Calculates the hypergeometric cumulative distribution function:

\[X{\sim}H(N,M,n)\]

\[\Pr(X\leq k|N,M,n)= \sum_{i=0}^{k}\frac{{M\choose k}{N-M\choose n-k}}{{N\choose n}}\]

Parameters:
[in]kthe maximum number of probed successes
[in]Nthe number of total elements
[in]Mthe number of success elements
[in]nthe number of selected elements
Returns:
the probability of up to k successes, otherwise NaN if the function is not defined for the specified parameters.
HNumber HMath::hypergeometricMean ( const HNumber N,
const HNumber M,
const HNumber n 
) [static]

Calculates the expected value of a hypergeometrically distributed random variable:

\[X{\sim}H(N,M,n)\]

\[E(X)=n\frac{M}{N}\]

Parameters:
[in]Nthe number of total elements
[in]Mthe number of success elements
[in]nthe number of selected elements
Returns:
the expected value of the variable, otherwise NaN if the function is not defined for the specified parameter.
HNumber HMath::hypergeometricPmf ( const HNumber k,
const HNumber N,
const HNumber M,
const HNumber n 
) [static]

Calculates the hypergeometric discrete distribution probability mass function:

\[X{\sim}H(N,M,n)\]

\[\Pr(X=k|N,M,n)=\frac{{M\choose k}{N-M\choose n-k}}{{N\choose n}}\]

Parameters:
[in]kthe number of probed exact successes
[in]Nthe number of total elements
[in]Mthe number of success elements
[in]nthe number of selected elements
Returns:
the probability of exactly k successes, otherwise NaN if the function is not defined for the specified parameters.
HNumber HMath::hypergeometricVariance ( const HNumber N,
const HNumber M,
const HNumber n 
) [static]

Calculates the variance of a hypergeometrically distributed random variable:

\[X{\sim}H(N,M,n)\]

\[Var(X)=\frac{n\frac{M}{N}(1-\frac{M}{N})(N-n)}{N-1}\]

Parameters:
[in]Nthe number of total elements
[in]Mthe number of success elements
[in]nthe number of selected elements
Returns:
the variance of the variable, otherwise NaN if the function is not defined for the specified parameter.
HNumber HMath::idiv ( const HNumber dividend,
const HNumber divisor 
) [static]

Performs an integer divide

HNumber HMath::integer ( const HNumber n) [static]

Returns the integer part of n.

HNumber HMath::lb ( const HNumber x) [static]

Returns the binary logarithm of x. If x is non positive, returns NaN.

HNumber HMath::lg ( const HNumber x) [static]

Returns the common logarithm of x. If x is non positive, returns NaN.

HNumber HMath::ln ( const HNumber x) [static]

Returns the natural logarithm of x. If x is non positive, returns NaN.

HNumber HMath::lnGamma ( const HNumber x) [static]

Returns ln(abs(Gamma(x))).

HNumber HMath::log ( const HNumber base,
const HNumber x 
) [static]

Returns the logarithm of x to base. If x is non positive, returns NaN.

HNumber HMath::mask ( const HNumber val,
const HNumber bits 
) [static]

Restricts a logic value to a given bit size.

HNumber HMath::max ( const HNumber n1,
const HNumber n2 
) [static]

Returns the maximum of two numbers.

HNumber HMath::min ( const HNumber n1,
const HNumber n2 
) [static]

Returns the minimum of two numbers.

HNumber HMath::nan ( Error  error = Success) [static]

Returns a NaN (Not a Number) with error set to passed parameter.

HNumber HMath::nCr ( const HNumber n,
const HNumber r 
) [static]

Returns the binomial coefficient of n and r. Is any of n and r negative or a non-integer, 1/(n+1)*B(r+1, n-r+1)) is returned, where B(x,y) is the complete Beta function

HNumber HMath::nPr ( const HNumber n,
const HNumber r 
) [static]

Returns the permutation of n elements chosen r elements.

HNumber HMath::phi ( ) [static]

Returns the constant Phi (golden number).

HNumber HMath::pi ( ) [static]

Returns the constant Pi.

HNumber HMath::poissonCdf ( const HNumber k,
const HNumber l 
) [static]

Calculates the poissonian cumulative distribution function:

\[X{\sim}P(\lambda)\]

\[\Pr(X\leq k|\lambda)=\sum_{i=0}^{k}\frac{e^{-\lambda}\lambda^k}{k!}\]

Parameters:
[in]kthe maximum number of event occurrences
[in]lthe expected number of occurrences that occur in an interval
Returns:
the probability of up to k event occurrences, otherwise NaN if the function is not defined for the specified parameters.
HNumber HMath::poissonMean ( const HNumber l) [static]

Calculates the expected value of a Poisson distributed random variable:

\[X{\sim}P(\lambda)\]

\[E(X)=\lambda\]

Parameters:
[in]lthe expected number of occurrences that occur in an interval
Returns:
the expected value of the variable, otherwise NaN if the function is not defined for the specified parameter.
HNumber HMath::poissonPmf ( const HNumber k,
const HNumber l 
) [static]

Calculates the poissonian discrete distribution probability mass function:

\[X{\sim}P(\lambda)\]

\[\Pr(X=k|\lambda)=\frac{e^{-\lambda}\lambda^k}{k!}\]

Parameters:
[in]kthe number of event occurrences
[in]lthe expected number of occurrences that occur in an interval
Returns:
the probability of exactly k event occurrences, otherwise NaN if the function is not defined for the specified parameters.
HNumber HMath::poissonVariance ( const HNumber l) [static]

Calculates the variance of a Poisson distributed random variable:

\[X{\sim}P(\lambda)\]

\[Var(X)=\lambda\]

Parameters:
[in]lthe expected number of occurrences that occur in an interval
Returns:
the variance of the variable, otherwise NaN if the function is not defined for the specified parameter.
HNumber HMath::rad2deg ( const HNumber angle) [static]

Converts radians to degrees.

HNumber HMath::raise ( const HNumber n1,
int  n 
) [static]

Raises n1 to an integer n.

HNumber HMath::raise ( const HNumber n1,
const HNumber n2 
) [static]

Raises n1 to n2.

HNumber HMath::round ( const HNumber n,
int  prec = 0 
) [static]

Rounds n to the specified decimal digits.

HNumber HMath::sec ( const HNumber x) [static]

Returns the secant of x. Note that x must be in radians.

HNumber HMath::sgn ( const HNumber x) [static]

Returns signum x.

HNumber HMath::sgnext ( const HNumber val,
const HNumber bits 
) [static]

sign-extends an unsigned value

HNumber HMath::sin ( const HNumber x) [static]

Returns the sine of x. Note that x must be in radians.

HNumber HMath::sinh ( const HNumber x) [static]

Returns the hyperbolic sine of x.

HNumber HMath::sqrt ( const HNumber n) [static]

Returns the square root of n. If n is negative, returns NaN.

HNumber HMath::tan ( const HNumber x) [static]

Returns the tangent of x. Note that x must be in radians.

HNumber HMath::tanh ( const HNumber x) [static]

Returns the hyperbolic tangent of x.

HNumber HMath::trunc ( const HNumber n,
int  prec = 0 
) [static]

Truncates n to the specified decimal digits.


The documentation for this class was generated from the following files: