[Lemon-commits] ladanyi: r3335 - lemon/trunk/lemon
Lemon SVN
svn at lemon.cs.elte.hu
Sat Oct 13 10:48:07 CEST 2007
Author: ladanyi
Date: Sat Oct 13 10:48:07 2007
New Revision: 3335
Modified:
lemon/trunk/lemon/lp_base.h
Log:
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.
Modified: lemon/trunk/lemon/lp_base.h
==============================================================================
--- lemon/trunk/lemon/lp_base.h (original)
+++ lemon/trunk/lemon/lp_base.h Sat Oct 13 10:48:07 2007
@@ -35,6 +35,23 @@
///\ingroup lp_group
namespace lemon {
+ /// Function to decide whether a floating point value is finite or not.
+
+ /// Retruns true if the argument is not infinity, minus infinity or NaN.
+ /// It does the same as the isfinite() function defined by C99.
+ template <typename T>
+ bool isFinite(T value)
+ {
+ typedef std::numeric_limits<T> Lim;
+ if (Lim::has_infinity && (value == Lim::infinity() || value ==
+ -Lim::infinity()) ||
+ (Lim::has_quiet_NaN || Lim::has_signaling_NaN) && value != value)
+ {
+ return false;
+ }
+ return true;
+ }
+
///Common base class for LP solvers
///\todo Much more docs
@@ -457,13 +474,11 @@
const Value &upperBound() const { return _ub; }
///Is the constraint lower bounded?
bool lowerBounded() const {
- using namespace std;
- return finite(_lb);
+ return isFinite(_lb);
}
///Is the constraint upper bounded?
bool upperBounded() const {
- using namespace std;
- return finite(_ub);
+ return isFinite(_ub);
}
void prettyPrint(std::ostream &os) {
More information about the Lemon-commits
mailing list