dune-common 2.9.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Attributes | List of all members
Dune::FloatCmpOps< T, cstyle_, rstyle_ > Class Template Reference

Class encapsulating a default epsilon. More...

#include <dune/common/float_cmp.hh>

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
TType of the values to compare
cstyle_How to compare
rstyle_How to round

Member Typedef Documentation

◆ EpsilonType

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>

◆ ValueType

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

◆ FloatCmpOps()

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

construct an operations object

Parameters
epsilonUse the specified epsilon for comparing

Member Function Documentation

◆ epsilon() [1/2]

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

return the current epsilon

◆ epsilon() [2/2]

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

set new epsilon

◆ eq()

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

test for equality using epsilon

◆ ge()

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

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

◆ gt()

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

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

◆ le()

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

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

◆ lt()

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

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

◆ ne()

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

test for inequality using epsilon

this is exactly !eq(first, second)

◆ round()

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

round using epsilon

Template Parameters
IThe integral type to round to
Parameters
valThe 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.

◆ trunc()

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

truncate using epsilon

Template Parameters
IThe integral type to truncate to
Parameters
valThe 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

◆ cstyle

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.

◆ rstyle

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: