# HG changeset patch
# User Alpar Juttner <alpar@cs.elte.hu>
# Date 1231781058 0
# Node ID 03ce6078f568f2189fa1e0d90f32248a572ca3d9
# Parent 04c0631fd33241997b26542eec78715709d11003
Own support for isnan
diff --git a/lemon/bits/isnan.h b/lemon/bits/isnan.h
new file mode 100644
-
|
+
|
|
| 1 | /* -*- mode: C++; indent-tabs-mode: nil; -*- |
| 2 | * |
| 3 | * This file is a part of LEMON, a generic C++ optimization library. |
| 4 | * |
| 5 | * Copyright (C) 2003-2009 |
| 6 | * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
| 7 | * (Egervary Research Group on Combinatorial Optimization, EGRES). |
| 8 | * |
| 9 | * Permission to use, modify and distribute this software is granted |
| 10 | * provided that this copyright notice appears in all copies. For |
| 11 | * precise terms see the accompanying LICENSE file. |
| 12 | * |
| 13 | * This software is provided "AS IS" with no warranty of any kind, |
| 14 | * express or implied, and with no claim as to its suitability for any |
| 15 | * purpose. |
| 16 | * |
| 17 | */ |
| 18 | |
| 19 | #ifndef LEMON_BITS_ISNAN_H |
| 20 | #define LEMON_BITS_ISNAN_H |
| 21 | |
| 22 | namespace lemon |
| 23 | { |
| 24 | inline bool isnan(double v) |
| 25 | { |
| 26 | return v!=v; |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | #endif |
diff --git a/lemon/lp_base.h b/lemon/lp_base.h
a
|
b
|
|
30 | 30 | |
31 | 31 | #include<lemon/core.h> |
32 | 32 | #include<lemon/bits/solver_bits.h> |
| 33 | #include<lemon/bits/isnan.h> |
33 | 34 | |
34 | 35 | ///\file |
35 | 36 | ///\brief The interface of the LP solver interface. |
… |
… |
|
597 | 598 | const Value &upperBound() const { return _ub; } |
598 | 599 | ///Is the constraint lower bounded? |
599 | 600 | bool lowerBounded() const { |
600 | | return _lb != -INF && !std::isnan(_lb); |
| 601 | return _lb != -INF && !isnan(_lb); |
601 | 602 | } |
602 | 603 | ///Is the constraint upper bounded? |
603 | 604 | bool upperBounded() const { |
604 | | return _ub != INF && !std::isnan(_ub); |
| 605 | return _ub != INF && !isnan(_ub); |
605 | 606 | } |
606 | 607 | |
607 | 608 | }; |
… |
… |
|
1666 | 1667 | inline LpBase::Constr operator<=(const LpBase::Value &n, |
1667 | 1668 | const LpBase::Constr &c) { |
1668 | 1669 | LpBase::Constr tmp(c); |
1669 | | LEMON_ASSERT(std::isnan(tmp.lowerBound()), "Wrong LP constraint"); |
| 1670 | LEMON_ASSERT(isnan(tmp.lowerBound()), "Wrong LP constraint"); |
1670 | 1671 | tmp.lowerBound()=n; |
1671 | 1672 | return tmp; |
1672 | 1673 | } |
… |
… |
|
1678 | 1679 | const LpBase::Value &n) |
1679 | 1680 | { |
1680 | 1681 | LpBase::Constr tmp(c); |
1681 | | LEMON_ASSERT(std::isnan(tmp.upperBound()), "Wrong LP constraint"); |
| 1682 | LEMON_ASSERT(isnan(tmp.upperBound()), "Wrong LP constraint"); |
1682 | 1683 | tmp.upperBound()=n; |
1683 | 1684 | return tmp; |
1684 | 1685 | } |
… |
… |
|
1690 | 1691 | inline LpBase::Constr operator>=(const LpBase::Value &n, |
1691 | 1692 | const LpBase::Constr &c) { |
1692 | 1693 | LpBase::Constr tmp(c); |
1693 | | LEMON_ASSERT(std::isnan(tmp.upperBound()), "Wrong LP constraint"); |
| 1694 | LEMON_ASSERT(isnan(tmp.upperBound()), "Wrong LP constraint"); |
1694 | 1695 | tmp.upperBound()=n; |
1695 | 1696 | return tmp; |
1696 | 1697 | } |
… |
… |
|
1702 | 1703 | const LpBase::Value &n) |
1703 | 1704 | { |
1704 | 1705 | LpBase::Constr tmp(c); |
1705 | | LEMON_ASSERT(std::isnan(tmp.lowerBound()), "Wrong LP constraint"); |
| 1706 | LEMON_ASSERT(isnan(tmp.lowerBound()), "Wrong LP constraint"); |
1706 | 1707 | tmp.lowerBound()=n; |
1707 | 1708 | return tmp; |
1708 | 1709 | } |