ccgl::utils_math 命名空间参考

Basic mathematics related functions 更多...

函数

template<typename T1 , typename T2 >
bool FloatEqual (T1 v1, T2 v2)
 Whether v1 is equal to v2 更多...
 
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
 
template<typename T >
MaxInArray (const T *a, int n)
 Get maximum value in a numeric array with size n. 更多...
 
template<typename T >
MinInArray (const T *a, int n)
 Get minimum value in a numeric array with size n. 更多...
 
template<typename T >
Sum (int row, const T *data)
 Sum of a numeric array Get sum value of a double array with size row. 更多...
 
template<typename 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. 更多...
 
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 更多...
 
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 更多...
 
float ApprSqrt (float z)
 approximate sqrt 更多...
 
float ApprLn (float z)
 Approximates the natural logarithm, (where the base is 'e'=2.71828)
 
float pow_lookup (const float exp, const float log_base)
 lookup for pow(a, b) function 更多...
 
float ApprPow (float a, float b)
 Approximates pow(a, b) based on the work of Harrison Ainsworth. 更多...
 

详细描述

Basic mathematics related functions

函数说明

◆ ApprPow()

float ccgl::utils_math::ApprPow ( float  a,
float  b 
)

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.

◆ ApprSqrt()

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]zfloat or double value
返回
approximation of sqrt

◆ BasicStatistics() [1/2]

template<typename T >
void ccgl::utils_math::BasicStatistics ( const T *const *  values,
int  num,
int  lyrs,
double ***  derivedvalues,
exclude = static_cast<T>(NODATA_VALUE) 
)

calculate basic statistics at one time_funcs for 2D raster data

参数
[in]valuesdata array
[in]numdata length
[in]lyrslayer number
[out]derivedvaluesdouble array, value number, mean, max, min, std, range
[in]excludeoptional, excluded value, e.g. NoDATA, the default is -9999

valid number

mean

maximum

minimum

std

range

valid number

mean

maximum

minimum

std

range

◆ BasicStatistics() [2/2]

template<typename T >
void ccgl::utils_math::BasicStatistics ( const T *  values,
int  num,
double **  derivedvalues,
exclude = static_cast<T>(NODATA_VALUE) 
)

calculate basic statistics at one time_funcs

参数
[in]valuesdata array
[in]numdata length
[out]derivedvaluesdouble array, value number, mean, max, min, std, range
[in]excludeoptional, excluded value, e.g. NoDATA, the default is -9999

◆ FloatEqual()

template<typename T1 , typename T2 >
bool ccgl::utils_math::FloatEqual ( T1  v1,
T2  v2 
)

Whether v1 is equal to v2

参数
[in]v1Numeric value of data type 1
[in]v2Numeric value of data type 2
返回
true or false

◆ MaxInArray()

template<typename T >
T ccgl::utils_math::MaxInArray ( const T *  a,
int  n 
)

Get maximum value in a numeric array with size n.

参数
[in]a,n
返回
max value

◆ MinInArray()

template<typename T >
T ccgl::utils_math::MinInArray ( const T *  a,
int  n 
)

Get minimum value in a numeric array with size n.

参数
[in]a,n
返回
min value

◆ pow_lookup()

float ccgl::utils_math::pow_lookup ( const float  exp,
const float  log_base 
)

lookup for pow(a, b) function

参数
[in]exppower to raise radix to (exponent), i.e., b in pow(a, b)
[in]log_baseone over log, to required radix, of two (ln(base))

◆ Sum() [1/2]

template<typename T >
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
返回
sum

◆ Sum() [2/2]

template<typename T >
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
返回
sum