Main Page | Modules | Namespace List | Class Hierarchy | Class List | Namespace Members | Class Members

Common Mathematical Functions

Namespace: Maths More...

Functions

template<typename T>
Maths::abs (const T &t) throw ()
 Return the absolute value of a number.
template<typename T>
Maths::frac (const T &t) throw ()
 Return the fraction of a number.
template<typename T>
Maths::max (const T &a, const T &b) throw ()
 Return the greater of two numbers.
template<typename T>
Maths::max (const T &a, const T &b, const T &ct) throw ()
 Return the greatest of three numbers.
template<typename T>
Maths::min (const T &a, const T &b) throw ()
 Return the smallest of two numbers.
template<typename T>
Maths::min (const T &a, const T &b, const T &ct) throw ()
 Return the smallest of three numbers.
template<typename T>
Maths::round (const T &t) throw ()
 Round a number and return the result.
template<typename T>
Maths::sgn (const T &t) throw ()
 Return the sign of a number.
template<typename T>
bool Maths::isFinite (const T &t) throw ()
 Test whether a number is finite.
template<typename T>
bool Maths::isNan (const T &t) throw ()
 Test whether a value is not a number.
template<typename T>
bool Maths::isInfinite (const T &t) throw ()
 Test whether a number is infinite.
template<typename T>
bool Maths::isZero (const T &t) throw ()
 Test whether a number is zero.
template<typename T>
bool Maths::isNotZero (const T &t) throw ()
 Test whether a number is not zero.
template<typename T1, typename T2>
bool Maths::isEqual (const T1 &a, const T2 &b) throw ()
 Test whether a number is equal to another.
template<typename T1, typename T2>
bool Maths::isNotEqual (const T1 &a, const T2 &b) throw ()
 Test whether a number is not equal to another.
template<typename T1, typename T2>
bool Maths::isLess (const T1 &a, const T2 &b) throw ()
 Test whether a number is less compared to another.
template<typename T1, typename T2>
bool Maths::isLessOrEqual (const T1 &a, const T2 &b) throw ()
 Test whether a number is less or equal compared to another.
template<typename T1, typename T2>
bool Maths::isGreaterOrEqual (const T1 &a, const T2 &b) throw ()
 Test whether a number is greater or equal compared to another.
template<typename T1, typename T2>
bool Maths::isGreater (const T1 &a, const T2 &b) throw ()
 Test whether a number is greater compared to another.
template<typename T>
long Maths::floor (const T &t) throw ()
 Return the floor of a number.
template<typename T>
long Maths::ceiling (const T &t) throw ()
 Return the ceiling of a number.
template<typename T1, typename T2>
Index Maths::compare (const T1 &a, const T2 &b) throw ()
 Compare two numbers to each other.
template<typename T>
bool Maths::isNear (const T &a, const T &b, const T &max_diff) throw ()
 Test whether two numbers are close to each other.
double Maths::rint (double x)
 round to integral value in floating-point format

Detailed Description

Namespace: Maths


Function Documentation

template<typename T>
T abs const T &  t  )  throw ()
 

Return the absolute value of a number.

Parameters:
t the number
Returns:
T the absolute value

template<typename T>
long ceiling const T &  t  )  throw ()
 

Return the ceiling of a number.

Parameters:
t the number
Returns:
T the ceiling

template<typename T1, typename T2>
Index compare const T1 &  a,
const T2 &  b
throw ()
 

Compare two numbers to each other.

Parameters:
a the first number
b the second number
Returns:
Index -1 a < b; 0 a = b; 1 a > b

template<typename T>
long floor const T &  t  )  throw ()
 

Return the floor of a number.

Parameters:
t the number
Returns:
T the floor

template<typename T>
T frac const T &  t  )  throw ()
 

Return the fraction of a number.

Parameters:
t the number
Returns:
T the fraction

template<typename T1, typename T2>
bool isEqual const T1 &  a,
const T2 &  b
throw ()
 

Test whether a number is equal to another.

Parameters:
a the first number
b the second number
Returns:
bool, true if the absolute distance of a and b is below Constants::EPSILON

template<typename T>
bool isFinite const T &  t  )  throw ()
 

Test whether a number is finite.

Parameters:
t the number
Returns:
bool, true if t is finite

template<typename T1, typename T2>
bool isGreater const T1 &  a,
const T2 &  b
throw ()
 

Test whether a number is greater compared to another.

Parameters:
a the first number
b the second number
Returns:
bool, true if a is greater than b

template<typename T1, typename T2>
bool isGreaterOrEqual const T1 &  a,
const T2 &  b
throw ()
 

Test whether a number is greater or equal compared to another.

Parameters:
a the first number
b the second number
Returns:
bool, true if a is greater or equal than b

template<typename T>
bool isInfinite const T &  t  )  throw ()
 

Test whether a number is infinite.

Parameters:
t the number
Returns:
bool, true if t equals inf or -inf

template<typename T1, typename T2>
bool isLess const T1 &  a,
const T2 &  b
throw ()
 

Test whether a number is less compared to another.

Parameters:
a the first number
b the second number
Returns:
bool, true if a is smaller than b

template<typename T1, typename T2>
bool isLessOrEqual const T1 &  a,
const T2 &  b
throw ()
 

Test whether a number is less or equal compared to another.

Parameters:
a the first number
b the second number
Returns:
bool, true if a is less or equal b

template<typename T>
bool isNan const T &  t  )  throw ()
 

Test whether a value is not a number.

Parameters:
t the number
Returns:
bool, true if t equals nan

template<typename T>
bool isNear const T &  a,
const T &  b,
const T &  max_diff
throw ()
 

Test whether two numbers are close to each other.

Parameters:
a the first number
b the second number
max_diff the maximum allowed difference between the two numbers
Returns:
bool, true if the absolute distance between a and b is below max_diff

template<typename T1, typename T2>
bool isNotEqual const T1 &  a,
const T2 &  b
throw ()
 

Test whether a number is not equal to another.

Parameters:
a the first number
b the second number
Returns:
bool, true if the absolute distance of a and b is at least Constants::EPSILON

template<typename T>
bool isNotZero const T &  t  )  throw ()
 

Test whether a number is not zero.

Parameters:
t the number
Returns:
bool, true, if the absolute value of t is at least Constants::EPSILON

template<typename T>
bool isZero const T &  t  )  throw ()
 

Test whether a number is zero.

Parameters:
t the number
Returns:
bool, true if the absolute value of t is below Constants::EPSILON

template<typename T>
T max const T &  a,
const T &  b,
const T &  ct
throw ()
 

Return the greatest of three numbers.

Parameters:
a the first number
b the second number
ct the third number
Returns:
T the greatest number

template<typename T>
T max const T &  a,
const T &  b
throw ()
 

Return the greater of two numbers.

Parameters:
a the first number
b the second number
Returns:
T the greatest number

template<typename T>
T min const T &  a,
const T &  b,
const T &  ct
throw ()
 

Return the smallest of three numbers.

Parameters:
a the first number
b the second number
ct the third number
Returns:
T the smallest number

template<typename T>
T min const T &  a,
const T &  b
throw ()
 

Return the smallest of two numbers.

Parameters:
a the first number
b the second number
Returns:
T the smallest number

template<typename T>
T round const T &  t  )  throw ()
 

Round a number and return the result.

Parameters:
t the number
Returns:
T the result

template<typename T>
T sgn const T &  t  )  throw ()
 

Return the sign of a number.

Parameters:
t the number
Returns:
Index -1 t < 0; 0 t = 0; 1 t > 0