Main Page | Modules | Alphabetical List | Class List | File List | Class Members | File Members

Mathematical helper functions


Functions

bool approx (double a, double b, double epsilon=1e-5)
bool abs_approx (double a, double b, double epsilon=1e-5)
int intfloor (double arg)
int planck_nint (double arg)
long nlong (double arg)
template<typename T>
weak_modulo (T v1, T v2)
double modulo (double v1, double v2)
int modulo (int v1, int v2)
long modulo (long v1, long v2)
template<typename T>
sign (const T &signvalue)
unsigned int isqrt (unsigned int arg)
double safe_atan2 (double y, double x)
template<typename T>
int interpol_left (const T *begin, int len, const T &val)
template<typename T>
int interpol_nearest (const T *begin, int len, const T &val)

Function Documentation

bool approx double  a,
double  b,
double  epsilon = 1e-5
[inline]
 

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

Definition at line 48 of file cxxutils.h.

bool abs_approx double  a,
double  b,
double  epsilon = 1e-5
[inline]
 

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

Definition at line 55 of file cxxutils.h.

int intfloor double  arg  )  [inline]
 

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

Definition at line 62 of file cxxutils.h.

int planck_nint double  arg  )  [inline]
 

Returns the integer which is nearest to arg.

Definition at line 68 of file cxxutils.h.

long nlong double  arg  )  [inline]
 

Returns the long integer which is nearest to arg.

Definition at line 75 of file cxxutils.h.

template<typename T>
T weak_modulo v1,
v2
[inline]
 

Returns v1+v2 if v1<0, v1-v2 if v1>=v2, else v1.

v1 can be positive or negative; v2 must be positive.

Definition at line 83 of file cxxutils.h.

double modulo 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 89 of file cxxutils.h.

int modulo int  v1,
int  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 98 of file cxxutils.h.

long modulo long  v1,
long  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 104 of file cxxutils.h.

template<typename T>
T sign const T &  signvalue  )  [inline]
 

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

Definition at line 109 of file cxxutils.h.

unsigned int isqrt unsigned int  arg  )  [inline]
 

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

Definition at line 113 of file cxxutils.h.

double safe_atan2 double  y,
double  x
[inline]
 

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

Definition at line 120 of file cxxutils.h.

template<typename T>
int interpol_left const T *  begin,
int  len,
const T &  val
[inline]
 

Returns an index to the left of two interpolation values.

begin points to an array containing a sequence of values sorted in ascending order. The length of the array is len. If val is lower than the first element, 0 is returned. If val is higher than the last element, len-2 is returned. Else, the index of the largest element smaller than val is returned.

Definition at line 134 of file cxxutils.h.

template<typename T>
int interpol_nearest const T *  begin,
int  len,
const T &  val
[inline]
 

Returns an index to the nearest interpolation value.

begin points to an array containing a sequence of values sorted in ascending order. The length of the array is len. If val is lower than the first element, 0 is returned. If val is higher than the last element, len-1 is returned. Else, the index of the nearest element within the sequence of values is returned.

Definition at line 151 of file cxxutils.h.


Generated on Fri Jul 8 09:37:14 2005 for LevelS C++ support library