dune-common 2.9.0
|
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 > | |
I | round (const ValueType &val) const |
round using epsilon | |
template<class I > | |
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. | |
Class encapsulating a default epsilon.
T | Type of the values to compare |
cstyle_ | How to compare |
rstyle_ | How to round |
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>
typedef T Dune::FloatCmpOps< T, cstyle_, rstyle_ >::ValueType |
Type of the values to compare.
Dune::FloatCmpOps< T, cstyle_, rstyle_ >::FloatCmpOps | ( | EpsilonType | epsilon = DefaultEpsilon::value() | ) |
construct an operations object
epsilon | Use the specified epsilon for comparing |
FloatCmpOps< T, cstyle_, rstyle_ >::EpsilonType Dune::FloatCmpOps< T, cstyle_, rstyle_ >::epsilon | ( | ) | const |
return the current epsilon
void Dune::FloatCmpOps< T, cstyle_, rstyle_ >::epsilon | ( | EpsilonType | epsilon__ | ) |
set new epsilon
bool Dune::FloatCmpOps< T, cstyle_, rstyle_ >::eq | ( | const ValueType & | first, |
const ValueType & | second | ||
) | const |
test for equality using epsilon
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
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
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
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
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)
I Dune::FloatCmpOps< T, cstyle_, rstyle_ >::round | ( | const ValueType & | val | ) | const |
round using epsilon
I | The integral type to round to |
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.
I Dune::FloatCmpOps< T, cstyle_, rstyle_ >::trunc | ( | const ValueType & | val | ) | const |
truncate using epsilon
I | The integral type to truncate to |
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.
|
static |
How comparisons are done.
|
static |
How rounding is done.