utils_math.h File Reference

Useful math equations in CCGL. More...

#include <cmath>
#include "basic.h"
#include "utils_array.h"

Go to the source code of this file.

Namespaces

namespace  ccgl
 Common Cross-platform Geographic Library (CCGL)
 
namespace  ccgl::utils_math
 Basic mathematics related functions.
 

Macros

#define Max(a, b)   ((a) >= (b) ? (a) : (b))
 Return maximum value.
 
#define Min(a, b)   ((a) >= (b) ? (b) : (a))
 Return minimum value.
 
#define Abs(x)   ((x) >= 0 ? (x) : -(x))
 Return absolute value.
 

Functions

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

Detailed Description

Useful math equations in CCGL.

Remarks
  • 1. 2018-05-02 - lj - Make part of CCGL.
  • 2. 2021-07-15 - lj - Integrate pal.math for fast pow, exp, and ln
Author
Liangjun Zhu, zlj(a)lreis.ac.cn
Version
1.1