Util Namespace Reference


Classes

class  PrintForVector

Functions

template<class C>
vectorMin (std::vector< C > &v)
template<class C>
vectorMax (std::vector< C > &v)
double round (double x)
double safeLog (double x)
double sqr (double x)
template<class C>
void FlushVector (std::vector< C > &v)
template<class Except, class Assertion>
void Assert (Assertion assert)
template<class To, class From>
std::vector< To > vector_cast (std::vector< From > &x)
double round (const double x)
double safeLog (const double x)
double sqr (const double x)

Variables

const double dbl_eps = std::numeric_limits<double>::epsilon()
 minimum representable value of 1.0 - x
const double dbl_max = std::numeric_limits<double>::max()
 maximum value of double
const double dbl_min = std::numeric_limits<double>::min()
 minimum (positive) value of double
const int int_max = std::numeric_limits<int>::max()
 maximum value of integer
const int int_min = std::numeric_limits<int>::min()
 minimum value of integer
const unsigned uint_max = std::numeric_limits<unsigned>::max()
 maximum value of unsigned integer
const long long_max = std::numeric_limits<long>::max()
 maximum value of long integer
const long long_min = std::numeric_limits<long>::min()
 minimum value of long integer
const unsigned long ulong_max = std::numeric_limits<unsigned long>::max()
 maximum value of unsigned long integer
const double log_dbl_max = log(dbl_max)
 log(dbl_max)
const double log_dbl_min = log(dbl_min)
 log(dbl_min)


Detailed Description

Used to isolate utility functions and numerical constants.

Provides a variety of numerical constants related to double precision and integer arithmetic, a small collection of utility functions, and for probability density functions.


Function Documentation

template<class Except, class Assertion>
void Util::Assert ( Assertion  assert  )  [inline]

Assertion template for error checking

Parameters:
assert the assertion to check
This template throws an exception of type Except when the assertion of type Assertion is false. It is shamelessly adapted (stolen) from Stroustrup, The C++ Programming Language, 3rd ed.

Definition at line 115 of file util.h.

template<class C>
void Util::FlushVector ( std::vector< C > &  v  ) 

Empty a vector, and ensure that its capacity is zero

Parameters:
v The vector to be emptied
Uses the trick on p. 487 of Stroustrup (3rd ed.): create a temporary vector with zero capacity and swap it with the one to be erased.

Definition at line 101 of file util.h.

double Util::round ( const double  x  ) 

Round a floating point number

Formula:

\[\mbox{floor}(x + 0.5)\]

Parameters:
x 

Definition at line 48 of file util.cpp.

double Util::round ( const double  x  ) 

Round a floating point number

Formula:

\[\mbox{floor}(x + 0.5)\]

Parameters:
x 

Definition at line 48 of file util.cpp.

double Util::safeLog ( const double  x  ) 

Returns log_dbl_min if x < log_dbl_min

Parameters:
x The logarithm to check

Definition at line 57 of file util.cpp.

References log_dbl_min.

Referenced by logQBeta(), logQDirch(), and logQNorm().

double Util::safeLog ( const double  x  ) 

Returns log_dbl_min if x < log_dbl_min

Parameters:
x The logarithm to check

Definition at line 57 of file util.cpp.

References log_dbl_min.

Referenced by logQBeta(), logQDirch(), and logQNorm().

double Util::sqr ( const double  x  ) 

Returns $x^2$

Parameters:
x 

Definition at line 66 of file util.cpp.

Referenced by keh::Accumulate< true, T >::Accumulate(), and keh::Accumulate< false, T >::Accumulate().

double Util::sqr ( const double  x  ) 

Returns $x^2$

Parameters:
x 

Definition at line 66 of file util.cpp.

Referenced by keh::Accumulate< false, T >::Accumulate(), and keh::Accumulate< true, T >::Accumulate().

template<class To, class From>
std::vector<To> Util::vector_cast ( std::vector< From > &  x  )  [inline]

Cast all elements of a vector from one type to another

Parameters:
x the vector with elements to cast
This template will cast elements of type From to elements of type To and return the resulting vector

Definition at line 127 of file util.h.

template<class C>
C Util::vectorMax ( std::vector< C > &  v  )  [inline]

Returns maximum element in v.

This is a simple wrapper around std::max_element()

Parameters:
v The vector whose maximum element is sought

Definition at line 85 of file util.h.

template<class C>
C Util::vectorMin ( std::vector< C > &  v  )  [inline]

Returns minimum element in v.

This is a simple wrapper around std::min_element()

Parameters:
v The vector whose minimum element is sought

Definition at line 74 of file util.h.


Generated on Tue Mar 27 16:03:53 2007 for mcmc by  doxygen 1.5.1