Basic mathematics related functions. More...
Functions | |
float | Expo (float xx, float upper=20.f, float lower=-20.f) |
Check the argument against upper and lower boundary values prior to doing Exponential function. | |
float | Power (float a, float n) |
deal with positive and negative float numbers | |
float | ApprSqrt (float z) |
approximate sqrt More... | |
double | ApprSqrt (const double z) |
float | ApprLn (float z) |
Approximates the natural logarithm, (where the base is 'e'=2.71828) | |
double | ApprLn (const double z) |
float | pow_lookup (const float exp, const float log_base) |
lookup for pow(a, b) function More... | |
template<typename T1 , typename T2 > | |
bool | FloatEqual (T1 v1, T2 v2) |
Whether v1 is equal to v2. More... | |
template<typename T > | |
T | MaxInArray (const T *a, int n) |
Get maximum value in a numeric array with size n. More... | |
template<typename T > | |
T | MinInArray (const T *a, int n) |
Get minimum value in a numeric array with size n. More... | |
template<typename T > | |
T | Sum (int row, const T *data) |
Sum of a numeric array Get sum value of a double array with size row. More... | |
template<typename T > | |
T | Sum (int row, int *&idx, const T *data) |
Sum of a numeric array Get sum value of a double array with size row and real index idx. More... | |
template<typename T > | |
void | BasicStatistics (const T *values, int num, double **derivedvalues, T exclude=static_cast< T >(NODATA_VALUE)) |
calculate basic statistics at one time_funcs More... | |
template<typename T > | |
void | BasicStatistics (const T *const *values, int num, int lyrs, double ***derivedvalues, T exclude=static_cast< T >(NODATA_VALUE)) |
calculate basic statistics at one time_funcs for 2D raster data More... | |
template<typename T > | |
T | CalSqrt (T val) |
template<typename T > | |
T | CalExp (T val) |
template<typename T > | |
T | CalLn (T val) |
float | ApprPow (float a, float b) |
Approximates pow(a, b) based on the work of Harrison Ainsworth. More... | |
template<typename T1 , typename T2 > | |
double | CalPow (T1 a, T2 b) |
Variables | |
const vuint32_t | pow_mantissa_table_shift = 11 |
vuint32_t const | pow_mantissa_table [] |
Basic mathematics related functions.
|
inline |
Approximates pow(a, b) based on the work of Harrison Ainsworth.
Refers to http://www.hxa.name/articles/content/fast-pow-adjustable_hxa7241_2007.html Copyright (c) 2007, Harrison Ainsworth / HXA7241.
float ccgl::utils_math::ApprSqrt | ( | float | z | ) |
approximate sqrt
This uses a method to approximate sqrt which only applies to IEEE 754 floating point numbers, described in [1]. The optimized magic constant is from Chris Lomont[2]
References: 1: http://en.wikipedia.org/wiki/Fast_inverse_square_root 2: http://www.lomont.org/Math/Papers/2003/InvSqrt.pdf
[in] | z | float or double value |
void ccgl::utils_math::BasicStatistics | ( | const T *const * | values, |
int | num, | ||
int | lyrs, | ||
double *** | derivedvalues, | ||
T | exclude = static_cast<T>(NODATA_VALUE) |
||
) |
calculate basic statistics at one time_funcs for 2D raster data
[in] | values | data array |
[in] | num | data length |
[in] | lyrs | layer number |
[out] | derivedvalues | double array, value number, mean, max, min, std, range |
[in] | exclude | optional, excluded value, e.g. NoDATA, the default is -9999 |
valid number
mean
maximum
minimum
std
range
valid number
mean
maximum
minimum
std
range
void ccgl::utils_math::BasicStatistics | ( | const T * | values, |
int | num, | ||
double ** | derivedvalues, | ||
T | exclude = static_cast<T>(NODATA_VALUE) |
||
) |
calculate basic statistics at one time_funcs
[in] | values | data array |
[in] | num | data length |
[out] | derivedvalues | double array, value number, mean, max, min, std, range |
[in] | exclude | optional, excluded value, e.g. NoDATA, the default is -9999 |
bool ccgl::utils_math::FloatEqual | ( | T1 | v1, |
T2 | v2 | ||
) |
Whether v1 is equal to v2.
[in] | v1 | Numeric value of data type 1 |
[in] | v2 | Numeric value of data type 2 |
T ccgl::utils_math::MaxInArray | ( | const T * | a, |
int | n | ||
) |
Get maximum value in a numeric array with size n.
[in] | a,n |
T ccgl::utils_math::MinInArray | ( | const T * | a, |
int | n | ||
) |
Get minimum value in a numeric array with size n.
[in] | a,n |
float ccgl::utils_math::pow_lookup | ( | const float | exp, |
const float | log_base | ||
) |
lookup for pow(a, b) function
[in] | exp | power to raise radix to (exponent), i.e., b in pow(a, b) |
[in] | log_base | one over log, to required radix, of two (ln(base)) |
T ccgl::utils_math::Sum | ( | int | row, |
const T * | data | ||
) |
Sum of a numeric array Get sum value of a double array with size row.
[in] | row | |
[in] | data |
T ccgl::utils_math::Sum | ( | int | row, |
int *& | idx, | ||
const T * | data | ||
) |
Sum of a numeric array Get sum value of a double array with size row and real index idx.
[in] | row | |
[in] | idx | |
[in] | data |