3 #ifndef DUNE_COMMON_FLOAT_CMP_HH
4 #define DUNE_COMMON_FLOAT_CMP_HH
128 template<
class T>
struct EpsilonType;
136 template<
class T, CmpStyle style = defaultCmpStyle>
156 bool eq(
const T &first,
169 bool ne(
const T &first,
185 bool gt(
const T &first,
201 bool lt(
const T &first,
217 bool ge(
const T &first,
233 bool le(
const T &first,
294 static const CmpStyle cstyle = cstyle_;
296 static const RoundingStyle
rstyle = rstyle_;
306 EpsilonType epsilon_;
320 void epsilon(EpsilonType epsilon__);
323 bool eq(
const ValueType &first,
const ValueType &second)
const;
328 bool ne(
const ValueType &first,
const ValueType &second)
const;
334 bool gt(
const ValueType &first,
const ValueType &second)
const;
340 bool lt(
const ValueType &first,
const ValueType &second)
const;
346 bool ge(
const ValueType &first,
const ValueType &second)
const;
352 bool le(
const ValueType &first,
const ValueType &second)
const;
365 I
round(
const ValueType &val)
const;
378 I
trunc(
const ValueType &val)
const;
386 #endif //DUNE_COMMON_FLOAT_CMP_HH
bool gt(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
test if first greater than second
Definition: float_cmp.cc:132
bool lt(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
test if first lesser than second
Definition: float_cmp.cc:139
round toward
Definition: float_cmp.hh:121
static EpsilonType< T >::Type value()
Returns the default epsilon for the given value type and compare style.
FloatCmpOps(EpsilonType epsilon=DefaultEpsilon::value())
construct an operations object
Definition: float_cmp.cc:405
bool eq(const ValueType &first, const ValueType &second) const
test for equality using epsilon
Definition: float_cmp.cc:425
RoundingStyle
Definition: float_cmp.hh:115
bool ne(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
test for inequality using epsilon
Definition: float_cmp.cc:125
FloatCmp::EpsilonType< T >::Type EpsilonType
Type of the epsilon.
Definition: float_cmp.hh:303
the global default rounding style (toward_zero)
Definition: float_cmp.hh:125
I trunc(const ValueType &val) const
truncate using epsilon
Definition: float_cmp.cc:477
|a-b|/|a| <= epsilon || |a-b|/|b| <= epsilon
Definition: float_cmp.hh:105
mapping from a value type and a compare style to a default epsilon
Definition: float_cmp.hh:137
bool ge(const ValueType &first, const ValueType &second) const
test if first greater or equal second
Definition: float_cmp.cc:453
bool le(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
test if first lesser or equal second
Definition: float_cmp.cc:153
the global default compare style (relative_weak)
Definition: float_cmp.hh:111
T Type
The epsilon type corresponding to value type T.
Definition: float_cmp.cc:23
Dune namespace.
Definition: alignment.hh:9
Class encapsulating a default epsilon.
Definition: float_cmp.hh:287
|a-b| <= epsilon
Definition: float_cmp.hh:109
I round(const ValueType &val) const
round using epsilon
Definition: float_cmp.cc:469
round toward
Definition: float_cmp.hh:123
bool ne(const ValueType &first, const ValueType &second) const
test for inequality using epsilon
Definition: float_cmp.cc:432
bool lt(const ValueType &first, const ValueType &second) const
test if first lesser than second
Definition: float_cmp.cc:446
bool ge(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
test if first greater or equal second
Definition: float_cmp.cc:146
I round(const T &val, typename EpsilonType< T >::Type epsilon)
round using epsilon
Definition: float_cmp.cc:285
|a-b|/|a| <= epsilon && |a-b|/|b| <= epsilon
Definition: float_cmp.hh:107
bool le(const ValueType &first, const ValueType &second) const
test if first lesser or equal second
Definition: float_cmp.cc:460
EpsilonType epsilon() const
return the current epsilon
Definition: float_cmp.cc:410
T ValueType
Type of the values to compare.
Definition: float_cmp.hh:298
I trunc(const T &val, typename EpsilonType< T >::Type epsilon)
truncate using epsilon
Definition: float_cmp.cc:381
always round away from 0
Definition: float_cmp.hh:119
static const RoundingStyle rstyle
How rounding is done.
Definition: float_cmp.hh:296
CmpStyle
Definition: float_cmp.hh:103
always round toward 0
Definition: float_cmp.hh:117
bool gt(const ValueType &first, const ValueType &second) const
test if first greater than second
Definition: float_cmp.cc:439
bool eq(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
test for equality using epsilon
Definition: float_cmp.cc:118