LevelS C++ support library  3.83
Functions
Mathematical helper functions

Functions

template<typename F >
bool approx (F a, F b, F epsilon=1e-5)
 
template<typename F >
bool abs_approx (F a, F b, F epsilon=1e-5)
 
template<typename I , typename F >
ifloor (F arg)
 
template<typename I , typename F >
nearest (F arg)
 
double fmodulo (double v1, double v2)
 
template<typename I >
imodulo (I v1, I v2)
 
template<typename T >
sign (const T &signvalue)
 
template<typename T , typename I >
xpow (I m, T val)
 
template<typename I >
uint32 isqrt (I arg)
 
template<typename I >
int ilog2 (I arg)
 
double safe_atan2 (double y, double x)
 
template<typename T , typename Iter , typename Comp >
void interpol_helper (const Iter &begin, const Iter &end, const T &val, Comp comp, tsize &idx, T &frac)
 
template<typename T , typename Iter >
void interpol_helper (const Iter &begin, const Iter &end, const T &val, tsize &idx, T &frac)
 

Detailed Description

Function Documentation

◆ approx()

template<typename F >
bool approx ( a,
b,
epsilon = 1e-5 
)
inline

Returns true if | a-b | <= epsilon * | b |, else false.

Definition at line 44 of file math_utils.h.

◆ abs_approx()

template<typename F >
bool abs_approx ( a,
b,
epsilon = 1e-5 
)
inline

Returns true if | a-b | <= epsilon, else false.

Definition at line 51 of file math_utils.h.

◆ ifloor()

template<typename I , typename F >
I ifloor ( arg)
inline

Returns the largest integer which is smaller than (or equal to) arg.

Definition at line 58 of file math_utils.h.

◆ nearest()

template<typename I , typename F >
I nearest ( arg)
inline

Returns the integer which is nearest to arg.

Definition at line 65 of file math_utils.h.

◆ fmodulo()

double fmodulo ( double  v1,
double  v2 
)
inline

Returns the remainder of the division v1/v2. The result is non-negative. v1 can be positive or negative; v2 must be positive.

Definition at line 71 of file math_utils.h.

◆ imodulo()

template<typename I >
I imodulo ( v1,
v2 
)
inline

Returns the remainder of the division v1/v2. The result is non-negative. v1 can be positive or negative; v2 must be positive.

Definition at line 84 of file math_utils.h.

◆ sign()

template<typename T >
T sign ( const T &  signvalue)
inline

Returns -1 if signvalue is negative, else +1.

Definition at line 88 of file math_utils.h.

◆ xpow()

template<typename T , typename I >
T xpow ( m,
val 
)
inline

Returns val*pow(-1,m)

Definition at line 92 of file math_utils.h.

◆ isqrt()

template<typename I >
uint32 isqrt ( arg)
inline

Returns the integer n, which fulfills n*n<=arg<(n+1)*(n+1).

Definition at line 121 of file math_utils.h.

◆ ilog2()

template<typename I >
int ilog2 ( arg)
inline

Returns the largest integer n that fulfills 2^n<=arg.

Definition at line 125 of file math_utils.h.

◆ safe_atan2()

double safe_atan2 ( double  y,
double  x 
)
inline

Returns atan2(y,x) if x!=0 or y!=0; else returns 0.

Definition at line 179 of file math_utils.h.

◆ interpol_helper() [1/2]

template<typename T , typename Iter , typename Comp >
void interpol_helper ( const Iter &  begin,
const Iter &  end,
const T &  val,
Comp  comp,
tsize idx,
T &  frac 
)
inline

Helper function for linear interpolation (or extrapolation). The array must be ordered in ascending order; no two values may be equal.

Definition at line 188 of file math_utils.h.

◆ interpol_helper() [2/2]

template<typename T , typename Iter >
void interpol_helper ( const Iter &  begin,
const Iter &  end,
const T &  val,
tsize idx,
T &  frac 
)
inline

Helper function for linear interpolation (or extrapolation). The array must be ordered in ascending order; no two values may be equal.

Definition at line 202 of file math_utils.h.


Generated on Wed Nov 13 2024 12:18:16 for LevelS C++ support library