Own support for isnan()
authorAlpar Juttner <alpar@cs.elte.hu>
Wed, 14 Jan 2009 15:55:29 +0000
changeset 47081627fa1b007
parent 469 04c0631fd332
child 471 fb5af0411793
Own support for isnan()
lemon/lp_base.h
lemon/math.h
     1.1 --- a/lemon/lp_base.h	Mon Jan 12 13:37:37 2009 +0000
     1.2 +++ b/lemon/lp_base.h	Wed Jan 14 15:55:29 2009 +0000
     1.3 @@ -597,11 +597,11 @@
     1.4        const Value &upperBound() const { return _ub; }
     1.5        ///Is the constraint lower bounded?
     1.6        bool lowerBounded() const {
     1.7 -        return _lb != -INF && !std::isnan(_lb);
     1.8 +        return _lb != -INF && !isnan(_lb);
     1.9        }
    1.10        ///Is the constraint upper bounded?
    1.11        bool upperBounded() const {
    1.12 -        return _ub != INF && !std::isnan(_ub);
    1.13 +        return _ub != INF && !isnan(_ub);
    1.14        }
    1.15  
    1.16      };
    1.17 @@ -1666,7 +1666,7 @@
    1.18    inline LpBase::Constr operator<=(const LpBase::Value &n,
    1.19                                     const LpBase::Constr &c) {
    1.20      LpBase::Constr tmp(c);
    1.21 -    LEMON_ASSERT(std::isnan(tmp.lowerBound()), "Wrong LP constraint");
    1.22 +    LEMON_ASSERT(isnan(tmp.lowerBound()), "Wrong LP constraint");
    1.23      tmp.lowerBound()=n;
    1.24      return tmp;
    1.25    }
    1.26 @@ -1678,7 +1678,7 @@
    1.27                                     const LpBase::Value &n)
    1.28    {
    1.29      LpBase::Constr tmp(c);
    1.30 -    LEMON_ASSERT(std::isnan(tmp.upperBound()), "Wrong LP constraint");
    1.31 +    LEMON_ASSERT(isnan(tmp.upperBound()), "Wrong LP constraint");
    1.32      tmp.upperBound()=n;
    1.33      return tmp;
    1.34    }
    1.35 @@ -1690,7 +1690,7 @@
    1.36    inline LpBase::Constr operator>=(const LpBase::Value &n,
    1.37                                     const LpBase::Constr &c) {
    1.38      LpBase::Constr tmp(c);
    1.39 -    LEMON_ASSERT(std::isnan(tmp.upperBound()), "Wrong LP constraint");
    1.40 +    LEMON_ASSERT(isnan(tmp.upperBound()), "Wrong LP constraint");
    1.41      tmp.upperBound()=n;
    1.42      return tmp;
    1.43    }
    1.44 @@ -1702,7 +1702,7 @@
    1.45                                     const LpBase::Value &n)
    1.46    {
    1.47      LpBase::Constr tmp(c);
    1.48 -    LEMON_ASSERT(std::isnan(tmp.lowerBound()), "Wrong LP constraint");
    1.49 +    LEMON_ASSERT(isnan(tmp.lowerBound()), "Wrong LP constraint");
    1.50      tmp.lowerBound()=n;
    1.51      return tmp;
    1.52    }
     2.1 --- a/lemon/math.h	Mon Jan 12 13:37:37 2009 +0000
     2.2 +++ b/lemon/math.h	Wed Jan 14 15:55:29 2009 +0000
     2.3 @@ -55,6 +55,15 @@
     2.4    /// 1/sqrt(2)
     2.5    const long double SQRT1_2 = 0.7071067811865475244008443621048490L;
     2.6  
     2.7 +  ///Check whether the parameter is NaN or not
     2.8 +  
     2.9 +  ///This function checks whether the parameter is NaN or not.
    2.10 +  ///Is should be equivalent with std::isnan(), but it is not
    2.11 +  ///provided by all compilers.
    2.12 +  inline bool isnan(double v)
    2.13 +    {
    2.14 +      return v!=v;
    2.15 +    }
    2.16  
    2.17    /// @}
    2.18