Dune::FloatCmpOps< T, cstyle_, rstyle_ > Class Template Reference
[FloatCmp]

Class encapsulating a default epsilon. More...

#include <dune/common/float_cmp.hh>

List of all members.

Public Types

typedef T ValueType
 Type of the values to compare.
typedef FloatCmp::EpsilonType
< T >::Type 
EpsilonType
 Type of the epsilon.

Public Member Functions

 FloatCmpOps (EpsilonType epsilon=DefaultEpsilon::value())
 construct an operations object
EpsilonType epsilon () const
 return the current epsilon
void epsilon (EpsilonType epsilon__)
 set new epsilon
bool eq (const ValueType &first, const ValueType &second) const
 test for equality using epsilon
bool ne (const ValueType &first, const ValueType &second) const
 test for inequality using epsilon
bool gt (const ValueType &first, const ValueType &second) const
 test if first greater than second
bool lt (const ValueType &first, const ValueType &second) const
 test if first lesser than second
bool ge (const ValueType &first, const ValueType &second) const
 test if first greater or equal second
bool le (const ValueType &first, const ValueType &second) const
 test if first lesser or equal second
template<class I >
round (const ValueType &val) const
 round using epsilon
template<class I >
trunc (const ValueType &val) const
 truncate using epsilon

Static Public Attributes

static const CmpStyle cstyle = cstyle_
 How comparisons are done.
static const RoundingStyle rstyle = rstyle_
 How rounding is done.

Detailed Description

template<class T, FloatCmp::CmpStyle cstyle_ = FloatCmp::defaultCmpStyle, FloatCmp::RoundingStyle rstyle_ = FloatCmp::defaultRoundingStyle>
class Dune::FloatCmpOps< T, cstyle_, rstyle_ >

Class encapsulating a default epsilon.

Template Parameters:
T Type of the values to compare
cstyle_ How to compare
rstyle_ How to round

Member Typedef Documentation

template<class T, FloatCmp::CmpStyle cstyle_ = FloatCmp::defaultCmpStyle, FloatCmp::RoundingStyle rstyle_ = FloatCmp::defaultRoundingStyle>
typedef FloatCmp::EpsilonType<T>::Type Dune::FloatCmpOps< T, cstyle_, rstyle_ >::EpsilonType

Type of the epsilon.

May be different from the value type, for example for complex<double>

template<class T, FloatCmp::CmpStyle cstyle_ = FloatCmp::defaultCmpStyle, FloatCmp::RoundingStyle rstyle_ = FloatCmp::defaultRoundingStyle>
typedef T Dune::FloatCmpOps< T, cstyle_, rstyle_ >::ValueType

Type of the values to compare.


Constructor & Destructor Documentation

template<class T , FloatCmp::CmpStyle cstyle_, FloatCmp::RoundingStyle rstyle_>
Dune::FloatCmpOps< T, cstyle_, rstyle_ >::FloatCmpOps ( EpsilonType  epsilon = DefaultEpsilon::value()  )  [inline]

construct an operations object

Parameters:
epsilon Use the specified epsilon for comparing

Member Function Documentation

template<class T , FloatCmp::CmpStyle cstyle_, FloatCmp::RoundingStyle rstyle_>
void Dune::FloatCmpOps< T, cstyle_, rstyle_ >::epsilon ( EpsilonType  epsilon__  )  [inline]

set new epsilon

template<class T , FloatCmp::CmpStyle cstyle_, FloatCmp::RoundingStyle rstyle_>
FloatCmpOps< T, cstyle_, rstyle_ >::EpsilonType Dune::FloatCmpOps< T, cstyle_, rstyle_ >::epsilon (  )  const [inline]

return the current epsilon

template<class T , FloatCmp::CmpStyle cstyle_, FloatCmp::RoundingStyle rstyle_>
bool Dune::FloatCmpOps< T, cstyle_, rstyle_ >::eq ( const ValueType first,
const ValueType second 
) const [inline]

test for equality using epsilon

template<class T , FloatCmp::CmpStyle cstyle_, FloatCmp::RoundingStyle rstyle_>
bool Dune::FloatCmpOps< T, cstyle_, rstyle_ >::ge ( const ValueType first,
const ValueType second 
) const [inline]

test if first greater or equal second

this is exactly eq(first, second) || first > second, i.e. greater but the region that compares equal with an epsilon is also included

template<class T , FloatCmp::CmpStyle cstyle_, FloatCmp::RoundingStyle rstyle_>
bool Dune::FloatCmpOps< T, cstyle_, rstyle_ >::gt ( const ValueType first,
const ValueType second 
) const [inline]

test if first greater than second

this is exactly ne(first, second) && first > second, i.e. greater but the region that compares equal with an epsilon is excluded

template<class T , FloatCmp::CmpStyle cstyle_, FloatCmp::RoundingStyle rstyle_>
bool Dune::FloatCmpOps< T, cstyle_, rstyle_ >::le ( const ValueType first,
const ValueType second 
) const [inline]

test if first lesser or equal second

this is exactly eq(first, second) || first > second, i.e. lesser but the region that compares equal with an epsilon is also included

template<class T , FloatCmp::CmpStyle cstyle_, FloatCmp::RoundingStyle rstyle_>
bool Dune::FloatCmpOps< T, cstyle_, rstyle_ >::lt ( const ValueType first,
const ValueType second 
) const [inline]

test if first lesser than second

this is exactly ne(first, second) && first < second, i.e. lesser but the region that compares equal with an epsilon is excluded

template<class T , FloatCmp::CmpStyle cstyle_, FloatCmp::RoundingStyle rstyle_>
bool Dune::FloatCmpOps< T, cstyle_, rstyle_ >::ne ( const ValueType first,
const ValueType second 
) const [inline]

test for inequality using epsilon

this is exactly !eq(first, second)

template<class T , FloatCmp::CmpStyle cstyle_, FloatCmp::RoundingStyle rstyle_>
template<class I >
I Dune::FloatCmpOps< T, cstyle_, rstyle_ >::round ( const ValueType val  )  const [inline]

round using epsilon

Template Parameters:
I The integral type to round to
Parameters:
val The value to round

Round according to rstyle. If val is already near the mean of two adjacent integers in terms of epsilon, the result will be the rounded mean.

template<class T , FloatCmp::CmpStyle cstyle_, FloatCmp::RoundingStyle rstyle_>
template<class I >
I Dune::FloatCmpOps< T, cstyle_, rstyle_ >::trunc ( const ValueType val  )  const [inline]

truncate using epsilon

Template Parameters:
I The integral type to truncate to
Parameters:
val The value to truncate

Truncate according to rstyle. If val is already near an integer in terms of epsilon, the result will be that integer instead of the real truncated value.


Member Data Documentation

template<class T, FloatCmp::CmpStyle cstyle_ = FloatCmp::defaultCmpStyle, FloatCmp::RoundingStyle rstyle_ = FloatCmp::defaultRoundingStyle>
const CmpStyle Dune::FloatCmpOps< T, cstyle_, rstyle_ >::cstyle = cstyle_ [static]

How comparisons are done.

template<class T, FloatCmp::CmpStyle cstyle_ = FloatCmp::defaultCmpStyle, FloatCmp::RoundingStyle rstyle_ = FloatCmp::defaultRoundingStyle>
const RoundingStyle Dune::FloatCmpOps< T, cstyle_, rstyle_ >::rstyle = rstyle_ [static]

How rounding is done.


The documentation for this class was generated from the following files:
Generated on Mon Apr 26 10:45:23 2010 for dune-common by  doxygen 1.6.3