NASA - Jet Propulsion Laboratory
    + View the NASA Portal
Search JPL
Jet Propulsion Laboratory Home Earth Solar System Stars & Galaxies Technology
Introduction Background Software Links

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)
template<typename T>
weak_modulo (T v1, T v2)
double fmodulo (double v1, double v2)
template<typename I>
imodulo (I v1, I v2)
template<typename T>
sign (const T &signvalue)
template<typename I>
unsigned int isqrt (I arg)
template<typename I>
unsigned int ilog2 (I 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)

Detailed Description


Function Documentation

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

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

Definition at line 48 of file cxxutils.h.

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

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

Definition at line 55 of file cxxutils.h.

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

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

Definition at line 62 of file cxxutils.h.

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

Returns the integer which is nearest to arg.

Definition at line 68 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 76 of file cxxutils.h.

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 82 of file cxxutils.h.

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 91 of file cxxutils.h.

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

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

Definition at line 95 of file cxxutils.h.

template<typename I>
unsigned int isqrt ( arg  )  [inline]

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

Definition at line 99 of file cxxutils.h.

template<typename I>
unsigned int ilog2 ( arg  )  [inline]

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

Definition at line 109 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 121 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 135 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 152 of file cxxutils.h.


Generated on Fri Jun 18 16:12:29 2010 for LevelS C++ support library
Privacy / Copyright
FIRST GOV Contact: NASA Home Page Site Manager:
Webmaster:

CL 03-2650