Dune Core Modules (unstable)
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 > | |
I | round (const ValueType &val) const |
round using epsilon More... | |
template<class I > | |
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
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
◆ EpsilonType
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()
Dune::FloatCmpOps< T, cstyle_, rstyle_ >::FloatCmpOps | ( | EpsilonType | epsilon = DefaultEpsilon::value() | ) |
construct an operations object
- Parameters
-
epsilon Use the specified epsilon for comparing
Member Function Documentation
◆ ge()
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()
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()
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()
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()
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()
I Dune::FloatCmpOps< T, cstyle_, rstyle_ >::round | ( | const ValueType & | val | ) | const |
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.
◆ trunc()
I Dune::FloatCmpOps< T, cstyle_, rstyle_ >::trunc | ( | const ValueType & | val | ) | const |
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.
The documentation for this class was generated from the following files:
- dune/common/float_cmp.hh
- dune/common/float_cmp.cc