last update 20 Sep 2009 |
Functions | |
template<class T > | |
bool | cvr::closeTo (const T &a, const T &b, const T epsilon=std::numeric_limits< T >::epsilon()) |
template<class T > | |
bool | cvr::closeToZero (const T &a, const T epsilon=std::numeric_limits< T >::epsilon()) |
template<typename T > | |
T | cvr::min (const T x, const T y) |
template<typename T > | |
T | cvr::max (const T x, const T y) |
template<typename T > | |
T | cvr::min (const T x, const T y, const T z) |
template<typename T > | |
T | cvr::max (const T x, const T y, const T z) |
template<typename T > | |
T | cvr::within (const T x, const T lower, const T upper) |
template<typename T > | |
void | cvr::minmax (const T x, const T y, T &theMin, T &theMax) |
template<typename T > | |
void | cvr::minmax (T &theMin, T &theMax) |
template<typename T > | |
void | cvr::minmax (const T x, T &theMin, T &theMax) |
double | cvr::degToRad (const double °) |
float | cvr::degToRad (const float °) |
double | cvr::degToRad (const int deg) |
double | cvr::radToDeg (const double &rad) |
float | cvr::radToDeg (const float &rad) |
byte | cvr::abs (byte x) |
int | cvr::abs (int x) |
float | cvr::abs (float x) |
double | cvr::abs (const double &x) |
template<typename T > | |
T | cvr::absdiff (const T &x, const T &y) |
double | cvr::reciprocal (const double &x) |
float | cvr::reciprocal (const float &x) |
double | cvr::oneMinus (const double &x) |
float | cvr::oneMinus (const float &x) |
int | cvr::oneMinus (const int x) |
template<typename T > | |
T | cvr::rectify (const T &x) |
template<typename T > | |
T | cvr::sqr (const T &x) |
template<typename T > | |
T | cvr::sqrAbs (const T &x) |
int | cvr::sqrt (int x) |
unsigned int | cvr::sqrt (unsigned int x) |
float | cvr::sqrt (const float &x) |
double | cvr::sqrt (const double &x) |
template<typename T > | |
T | cvr::sqrtrect (const T x) |
float | cvr::sigmoid (const float x) |
double | cvr::sigmoid (const double &x) |
double | cvr::sigmoid (const int x) |
template<typename T > | |
T | cvr::signum (T x) |
template<typename T > | |
T | cvr::signum0 (T x) |
template<typename T > | |
bool | cvr::even (const T x) |
template<typename T > | |
bool | cvr::odd (const T x) |
template<typename T > | |
T | cvr::round (T x) |
template<typename T > | |
int | cvr::iround (T x) |
template<typename T > | |
long | cvr::lround (T x) |
Variables | |
const double | cvr::Pi = 3.1415926535897932 |
const double | cvr::NaN = log(-1.0) |
const double | cvr::Inf = tan(Pi/2.0) |
Operators for complex numbers | |
template<typename T > | |
T | cvr::sqrAbs (const complex< T > &x) |
double cvr::abs | ( | const double & | x | ) | [inline] |
Absolute value for any type.
float cvr::abs | ( | float | x | ) | [inline] |
Absolute value for any type.
int cvr::abs | ( | int | x | ) | [inline] |
Absolute value for integers.
byte cvr::abs | ( | byte | x | ) | [inline] |
Absolute value for signed bytes.
T cvr::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.
bool cvr::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.
a | first value | |
b | second value | |
epsilon | max difference between a and b , default std::numeric_limits<T>::epsilon() |
bool cvr::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.
a | value | |
epsilon | maximum absolute value of a , default std::numeric_limits<T>::epsilon() |
Referenced by cvr::arctanLUT::operator()().
double cvr::degToRad | ( | const int | deg | ) | [inline] |
Convert the given angle in degrees to an angle in radians.
float cvr::degToRad | ( | const float & | deg | ) | [inline] |
Convert the given angle in degrees to an angle in radians.
double cvr::degToRad | ( | const double & | deg | ) | [inline] |
Convert the given angle in degrees to an angle in radians.
bool cvr::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.
int cvr::iround | ( | T | x | ) | [inline] |
Round any float type mathematicly and return an integer.
Referenced by cvr::arctanLUT::operator()().
long cvr::lround | ( | T | x | ) | [inline] |
Round any float type mathematicly and return an long integer.
T cvr::max | ( | const T | x, | |
const T | y, | |||
const T | z | |||
) | [inline] |
Get the maximum of x, y and z.
T cvr::max | ( | const T | x, | |
const T | y | |||
) | [inline] |
Get the maximum of x and y.
T cvr::min | ( | const T | x, | |
const T | y, | |||
const T | z | |||
) | [inline] |
Get the minimum of x, y and z.
T cvr::min | ( | const T | x, | |
const T | y | |||
) | [inline] |
Get the minimum of x and y.
void cvr::minmax | ( | const T | x, | |
T & | theMin, | |||
T & | theMax | |||
) | [inline] |
Store the minimum of x and theMin in theMin and the maximum of x and theMax in theMax, however, making just one comparison each time.
void cvr::minmax | ( | T & | theMin, | |
T & | theMax | |||
) | [inline] |
Ensure that the minimum of the two given values is stored in theMin and the maximum in theMax.
void cvr::minmax | ( | const T | x, | |
const T | y, | |||
T & | theMin, | |||
T & | theMax | |||
) | [inline] |
Store the minimum of x and y in theMin and the maximum in theMax.
bool cvr::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.
int cvr::oneMinus | ( | const int | x | ) | [inline] |
Compute 1 minus the given value.
float cvr::oneMinus | ( | const float & | x | ) | [inline] |
Compute 1 minus the given value.
This function is usually employed to revert a probability value
double cvr::oneMinus | ( | const double & | x | ) | [inline] |
Compute 1 minus the given value.
This function is usually employed to revert a probability value
float cvr::radToDeg | ( | const float & | rad | ) | [inline] |
Convert the given angle in radians to an angle in degrees.
double cvr::radToDeg | ( | const double & | rad | ) | [inline] |
Convert the given angle in radians to an angle in degrees.
float cvr::reciprocal | ( | const float & | x | ) | [inline] |
Compute the reciprocal of the given value x, defined as 1/x.
double cvr::reciprocal | ( | const double & | x | ) | [inline] |
Compute the reciprocal of the given value x, defined as 1/x.
T cvr::rectify | ( | const T & | x | ) | [inline] |
Rectify is 0 if x<0 or x otherwise.
T cvr::round | ( | T | x | ) | [inline] |
Round any float type mathematicly.
double cvr::sigmoid | ( | const int | x | ) | [inline] |
Sigmoid for ints.
The sigmoid is defined as
double cvr::sigmoid | ( | const double & | x | ) | [inline] |
Sigmoid for doubles.
The sigmoid is defined as
float cvr::sigmoid | ( | const float | x | ) | [inline] |
Sigmoid for floats.
The sigmoid is defined as
T cvr::signum | ( | T | x | ) | [inline] |
T cvr::signum0 | ( | T | x | ) | [inline] |
T cvr::sqr | ( | const T & | x | ) | [inline] |
Square (x*x).
T cvr::sqrAbs | ( | const T & | x | ) | [inline] |
Square of the magnitude of a number (|x|*|x|).
This function is useful in generic programming for those cases where complex numbers will occur in products of conjugate pairs.
T cvr::sqrAbs | ( | const complex< T > & | x | ) | [inline] |
Square of the magnitude of a number (|x|*|x|).
This function is useful in generic programming for those cases where complex numbers will occur in products of conjugate pairs.
double cvr::sqrt | ( | const double & | x | ) | [inline] |
Square root.
float cvr::sqrt | ( | const float & | x | ) | [inline] |
Square root.
unsigned int cvr::sqrt | ( | unsigned int | x | ) | [inline] |
Square root.
int cvr::sqrt | ( | int | x | ) | [inline] |
Square root of integer type.
Equals floor(sqrt(x))
T cvr::sqrtrect | ( | const T | x | ) | [inline] |
Square root of rectified value, i.e.
returns 0 if x<=0 or sqrt(x) otherwise.
T cvr::within | ( | const T | x, | |
const T | lower, | |||
const T | upper | |||
) | [inline] |
Check if the x value lies within the lower and upper bounds, and if not return the closest bound.
This is equivalent (but faster than) cvr::max(cvr::min(x,upper),lower).
Referenced by cvr::scale().
const double cvr::Inf = tan(Pi/2.0) |
Constant Infinity (Inf) (double precision).
const double cvr::NaN = log(-1.0) |
Constant Not a Number (NaN) (doble precision).
const double cvr::Pi = 3.1415926535897932 |
Constant Pi (double precision).