15 #ifndef ECL_MATH_FUZZY_HPP_    16 #define ECL_MATH_FUZZY_HPP_    26 #include <ecl/type_traits/numeric_limits.hpp>    36 namespace implementations {
    47 template<
typename Scalar,
    49 struct scalar_fuzzy_default_impl {};
    56 template<
typename Scalar>
    57 struct scalar_fuzzy_default_impl<Scalar, false>
    61         template<
typename OtherScalar>
    62         static inline bool isApprox(
const Scalar& x, 
const OtherScalar& y, 
const Precision& prec) {
    64                 return std::abs(x - static_cast<Scalar>(y)) <= std::min( std::abs(x),  std::abs(static_cast<Scalar>(y))) * prec;
    67         template<
typename OtherScalar>
    68         static inline bool isApproxOrLessThan(
const Scalar& x, 
const OtherScalar& y, 
const Precision& prec) {
    69                 return x <= y || 
isApprox(x, y, prec);
    78 template<
typename Scalar>
    79 struct scalar_fuzzy_default_impl<Scalar, true> {
    83         template<
typename OtherScalar>
    84         static inline bool isApprox(
const Scalar& x, 
const OtherScalar& y, 
const Precision& prec) {
    94                                 precision = 
static_cast<OtherScalar
>(prec);
    96                         return std::abs(static_cast<OtherScalar>(x) - y) <= std::min( std::abs(static_cast<OtherScalar>(x)),  std::abs(y)) * precision;
    99         template<
typename OtherScalar>
   100         static inline bool isApproxOrLessThan(
const Scalar& x, 
const OtherScalar& y, 
const Precision&) {
   128 template<
typename Scalar>
   129 struct scalar_fuzzy_impl : implementations::scalar_fuzzy_default_impl<Scalar, numeric_limits<Scalar>::is_integer> {};
   153 template<
typename Scalar, 
typename OtherScalar>
   155         return implementations::scalar_fuzzy_impl<Scalar>::isApprox(x, y, precision);
   171 template<
typename Scalar, 
typename OtherScalar>
   173         return implementations::scalar_fuzzy_impl<Scalar>::isApproxOrLessThan(x, y, precision);
 
bool isApproxOrLessThan(const Scalar &x, const OtherScalar &y, typename numeric_limits< Scalar >::Precision precision=numeric_limits< Scalar >::dummy_precision)
Checks if the first value is less than or approximate to the second. 
Expands the std numeric_limits class. 
bool isApprox(const Scalar &x, const OtherScalar &y, typename numeric_limits< Scalar >::Precision precision=numeric_limits< Scalar >::dummy_precision)
Checks if two values are approximate.