LTI-Lib latest version v1.9 - last update 10 Apr 2010

Basic Math Functions
[Math]

Collaboration diagram for Basic Math Functions:

Functions

template<class T >
bool lti::closeTo (const T &a, const T &b, const T epsilon=std::numeric_limits< T >::epsilon())
template<class T >
bool lti::closeToZero (const T &a, const T epsilon=std::numeric_limits< T >::epsilon())
template<class T >
lti::round (T x)
template<class T >
int lti::iround (T x)
template<class T >
long lti::lround (T x)
template<class T >
void lti::exchange (T &a, T &b)
template<class T >
lti::min (const T x, const T y)
template<class T >
lti::max (const T x, const T y)
template<class T >
lti::min (const T x, const T y, const T z)
template<class T >
lti::max (const T x, const T y, const T z)
template<class T >
lti::lnGamma (const T &x)
double lti::factorial (const int x)
double lti::lnFactorial (const int x)
double lti::binomial (const int n, const int k)
byte lti::abs (byte x)
int lti::abs (int x)
float lti::abs (float x)
double lti::abs (const double &x)
template<class T >
lti::absdiff (const T &x, const T &y)
template<class T >
lti::rectify (const T &x)
template<class T >
lti::sqr (const T &x)
int lti::sqrt (int x)
unsigned int lti::sqrt (unsigned int x)
float lti::sqrt (float x)
double lti::sqrt (const double &x)
float lti::sigmoid (const float x)
double lti::sigmoid (const double &x)
double lti::sigmoid (const int x)
template<class T >
lti::signum (T x)
template<class T >
lti::signum0 (T x)
template<class T >
bool lti::even (const T x)
template<class T >
bool lti::odd (const T x)
template<class T >
lti::betai (const T &a, const T &b, const T &x)

Variables

const double lti::Pi = 3.1415926535897932
const double lti::NaN = log(-1.0)
const double lti::Inf = tan(Pi/2.0)

Detailed Description

See also:
Conceptual Class Hierarchy in the LTI-Lib

Function Documentation

double lti::abs ( const double &  x  )  [inline]

absolute value for any type

References lti::abs().

float lti::abs ( float  x  )  [inline]

absolute value for any type

References lti::abs().

int lti::abs ( int  x  )  [inline]

absolute value for integers

byte lti::abs ( byte  x  )  [inline]

absolute value for signed bytes

template<class T >
T lti::absdiff ( const T &  x,
const T &  y 
) [inline]

absolute difference for the given values equals if (x>y) then (x-y) else (y-x).

Note that with complex numbers it does not return the real abs value.

template<class T >
T lti::betai ( const T &  a,
const T &  b,
const T &  x 
) [inline]

Compute the incomplete beta function.

double lti::binomial ( const int  n,
const int  k 
)

Returns the binomial coefficient defined by

\[ \begin{pmatrix} n \\ k \end{pmatrix} \frac{n!}{k!(n-k)!} \quad 0 \leq k \leq n \]

.

template<class T >
bool lti::closeTo ( const T &  a,
const T &  b,
const T  epsilon = std::numeric_limits<T>::epsilon() 
) [inline]

Returns true if a is close to b, i.e.

if abs(a-b) <= epsilon.

This is always better than testing equality with a==b for floating point types. For default epsilon integers are tested for equality.

Note: Do not used for unsigned types T.

Parameters:
a first value
b second value
epsilon max difference between a and b , default std::numeric_limits<T>::epsilon()
Returns:
true if distance between a and b is <= epsilon
template<class T >
bool lti::closeToZero ( const T &  a,
const T  epsilon = std::numeric_limits<T>::epsilon() 
) [inline]

Returns true if a is close to T(0), i.e.

if abs(a) <= epsilon.

This is always better than testing equality with a==0. for floating point types. For default epsilon integers are tested for ==0 automagically.

Note: Do not used for unsigned types T.

Parameters:
a value
epsilon maximum absolute value of a , default std::numeric_limits<T>::epsilon()
Returns:
true if absolute value of a is <= epsilon
template<class T >
bool lti::even ( const T  x  )  [inline]

Return true if the given number is an even number.

For floating point types, this function will return true only if the number is exacltly an integer and it is even.

template<class T >
void lti::exchange ( T &  a,
T &  b 
) [inline]

Exchange the content of the two given variables.

It works for all types T that properly define the copy constructor and operator=().

Deprecated:
Please use swap instead
Parameters:
a first variable
b second variable

Referenced by lti::minmax().

double lti::factorial ( const int  x  ) 

Returns the factorial of x.

Note that the returned type is always the same as the input type. So, if you require very large faculty values, just cast the input to double.

template<class T >
int lti::iround ( x  )  [inline]

round any float type mathematicly and return an integer

Referenced by lti::nearestNeighborInterpolator< T >::interpolate(), lti::arctanLUT::operator()(), and lti::draw< rgbPixel >::turnPoint().

double lti::lnFactorial ( const int  x  ) 

Returns the natural logarithm of the factorial of x.

template<class T >
T lti::lnGamma ( const T &  x  )  [inline]

Returns the value ln( gamma(x) ) for xx>0.

template<class T >
long lti::lround ( x  )  [inline]

round any float type mathematicly and return an long integer

template<class T >
T lti::max ( const T  x,
const T  y,
const T  z 
) [inline]

Get the maximum of x, y and z.

References lti::max().

template<class T >
T lti::max ( const T  x,
const T  y 
) [inline]
template<class T >
T lti::min ( const T  x,
const T  y,
const T  z 
) [inline]

Get the minimum of x, y and z.

References lti::min().

template<class T >
T lti::min ( const T  x,
const T  y 
) [inline]
template<class T >
bool lti::odd ( const T  x  )  [inline]

Return true if the given number is an odd number.

For floating point types, this function will return true only if the number is exacltly an integer and it is odd.

template<class T >
T lti::rectify ( const T &  x  )  [inline]

rectify is 0 if x<0 or x otherwise

template<class T >
T lti::round ( x  )  [inline]

round any float type mathematicly

double lti::sigmoid ( const int  x  )  [inline]

sigmoid for ints

References lti::exp().

double lti::sigmoid ( const double &  x  )  [inline]

sigmoid for doubles

References lti::exp().

float lti::sigmoid ( const float  x  )  [inline]

sigmoid for floats

References lti::exp().

template<class T >
T lti::signum ( x  )  [inline]

signum of x (for x==0 -> signum = 1) (

See also:
signum0)
template<class T >
T lti::signum0 ( x  )  [inline]

signum of x (for x==0 -> signum = 0) (

See also:
signum)
template<class T >
T lti::sqr ( const T &  x  )  [inline]

square (x*x)

double lti::sqrt ( const double &  x  )  [inline]

square root

References lti::sqrt().

float lti::sqrt ( float  x  )  [inline]

square root

References lti::sqrt().

unsigned int lti::sqrt ( unsigned int  x  )  [inline]

square root

References lti::sqrt().

int lti::sqrt ( int  x  )  [inline]

square root of integer type.

Equals floor(sqrt(x))

References lti::sqrt().


Variable Documentation

const double lti::Inf = tan(Pi/2.0)

Constant Infinity (Inf) (double precision).

const double lti::NaN = log(-1.0)

Constant Not a Number (NaN) (doble precision).

const double lti::Pi = 3.1415926535897932

Constant Pi (double precision).

Referenced by lti::degToRad(), lti::radToDeg(), and lti::draw3D< T >::parameters::setCamera().


Generated on Sat Apr 10 15:26:31 2010 for LTI-Lib by Doxygen 1.6.1