COIN-OR::LEMON - Graph Library

Changeset 2495:e4f8367beb41 in lemon-0.x


Ignore:
Timestamp:
10/13/07 10:48:07 (17 years ago)
Author:
Akos Ladanyi
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3334
Message:

Added the function isFinite(), and replaced the calls to finite() with it.
This was necessary because finite() is not a standard function. Neither can
we use its standard counterpart isfinite(), because it was introduced only
in C99, and therefore it is not supplied by all C++ implementations.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/lp_base.h

    r2435 r2495  
    3535///\ingroup lp_group
    3636namespace lemon {
     37
     38  /// Function to decide whether a floating point value is finite or not.
     39
     40  /// Retruns true if the argument is not infinity, minus infinity or NaN.
     41  /// It does the same as the isfinite() function defined by C99.
     42  template <typename T>
     43  bool isFinite(T value)
     44  {
     45    typedef std::numeric_limits<T> Lim;
     46    if (Lim::has_infinity && (value == Lim::infinity() || value ==
     47          -Lim::infinity()) ||
     48        (Lim::has_quiet_NaN || Lim::has_signaling_NaN) && value != value)
     49    {
     50      return false;
     51    }
     52    return true;
     53  }
    3754
    3855  ///Common base class for LP solvers
     
    458475      ///Is the constraint lower bounded?
    459476      bool lowerBounded() const {
    460         using namespace std;
    461         return finite(_lb);
     477        return isFinite(_lb);
    462478      }
    463479      ///Is the constraint upper bounded?
    464480      bool upperBounded() const {
    465         using namespace std;
    466         return finite(_ub);
     481        return isFinite(_ub);
    467482      }
    468483
Note: See TracChangeset for help on using the changeset viewer.