DUNE-FEM (unstable)

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. More...
 

Public Member Functions

 FloatCmpOps (EpsilonType epsilon=DefaultEpsilon::value())
 construct an operations object More...
 
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 More...
 
bool gt (const ValueType &first, const ValueType &second) const
 test if first greater than second More...
 
bool lt (const ValueType &first, const ValueType &second) const
 test if first lesser than second More...
 
bool ge (const ValueType &first, const ValueType &second) const
 test if first greater or equal second More...
 
bool le (const ValueType &first, const ValueType &second) const
 test if first lesser or equal second More...
 
template<class I >
round (const ValueType &val) const
 round using epsilon More...
 
template<class I >
trunc (const ValueType &val) const
 truncate using epsilon More...
 

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>

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

◆ 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.


The documentation for this class was generated from the following files:
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 20, 23:30, 2024)