LTI-Lib latest version v1.9 - last update 24 Nov 2005
Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

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

float lti::abs float  x  )  [inline]
 

absolute value for any type

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
 

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

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

double lti::lnFactorial const int  x  ) 
 

Returns the natural logarithm of the factorial of x.

template<class T>
T lti::lnGamma const T &  x  ) 
 

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.

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

Get the maximum of x and y.

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

Get the minimum of x, y and z.

template<class T>
T lti::min const T  x,
const T  y
[inline]
 

Get the minimum of x and y.

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

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

sigmoid for doubles

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

sigmoid for floats

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

float lti::sqrt float  x  )  [inline]
 

square root

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

square root

int lti::sqrt int  x  )  [inline]
 

square root of integer type.

Equals floor(sqrt(x))


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).


Generated on Thu Nov 24 16:29:54 2005 for LTI-Lib by Doxygen 1.4.4