1.1 --- a/lemon/Makefile.am Wed Dec 19 11:33:49 2007 +0000
1.2 +++ b/lemon/Makefile.am Thu Dec 20 15:59:06 2007 +0000
1.3 @@ -6,14 +6,18 @@
1.4
1.5 lib_LTLIBRARIES += lemon/libemon.la
1.6
1.7 -lemon_libemon_la_SOURCES =
1.8 +lemon_libemon_la_SOURCES = \
1.9 + lemon/base.cc
1.10
1.11 lemon_libemon_la_CXXFLAGS = $(GLPK_CFLAGS) $(CPLEX_CFLAGS) $(SOPLEX_CXXFLAGS)
1.12 lemon_libemon_la_LDFLAGS = $(GLPK_LIBS) $(CPLEX_LIBS) $(SOPLEX_LIBS)
1.13
1.14 lemon_HEADERS += \
1.15 - lemon/list_graph.h
1.16 + lemon/list_graph.h \
1.17 + lemon/tolerance.h
1.18
1.19 -bits_HEADERS +=
1.20 +bits_HEADERS += \
1.21 + lemon/bits/invalid.h \
1.22 + lemon/bits/utility.h
1.23
1.24 concept_HEADERS +=
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/lemon/base.cc Thu Dec 20 15:59:06 2007 +0000
2.3 @@ -0,0 +1,34 @@
2.4 +/* -*- C++ -*-
2.5 + *
2.6 + * This file is a part of LEMON, a generic C++ optimization library
2.7 + *
2.8 + * Copyright (C) 2003-2007
2.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
2.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
2.11 + *
2.12 + * Permission to use, modify and distribute this software is granted
2.13 + * provided that this copyright notice appears in all copies. For
2.14 + * precise terms see the accompanying LICENSE file.
2.15 + *
2.16 + * This software is provided "AS IS" with no warranty of any kind,
2.17 + * express or implied, and with no claim as to its suitability for any
2.18 + * purpose.
2.19 + *
2.20 + */
2.21 +
2.22 +///\file
2.23 +///\brief Some basic non inline function and static global data.
2.24 +
2.25 +#include<lemon/tolerance.h>
2.26 +#include<lemon/bits/invalid.h>
2.27 +namespace lemon {
2.28 +
2.29 + float Tolerance<float>::def_epsilon = 1e-4;
2.30 + double Tolerance<double>::def_epsilon = 1e-10;
2.31 + long double Tolerance<long double>::def_epsilon = 1e-14;
2.32 +
2.33 +#ifndef LEMON_ONLY_TEMPLATES
2.34 + const Invalid INVALID = Invalid();
2.35 +#endif
2.36 +
2.37 +} //namespace lemon
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/lemon/bits/invalid.h Thu Dec 20 15:59:06 2007 +0000
3.3 @@ -0,0 +1,54 @@
3.4 +/* -*- C++ -*-
3.5 + *
3.6 + * This file is a part of LEMON, a generic C++ optimization library
3.7 + *
3.8 + * Copyright (C) 2003-2007
3.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
3.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
3.11 + *
3.12 + * Permission to use, modify and distribute this software is granted
3.13 + * provided that this copyright notice appears in all copies. For
3.14 + * precise terms see the accompanying LICENSE file.
3.15 + *
3.16 + * This software is provided "AS IS" with no warranty of any kind,
3.17 + * express or implied, and with no claim as to its suitability for any
3.18 + * purpose.
3.19 + *
3.20 + */
3.21 +
3.22 +#ifndef LEMON_BITS_INVALID_H
3.23 +#define LEMON_BITS_INVALID_H
3.24 +
3.25 +///\file
3.26 +///\brief Definition of INVALID.
3.27 +
3.28 +namespace lemon {
3.29 +
3.30 + /// \brief Dummy type to make it easier to make invalid iterators.
3.31 + ///
3.32 + /// See \ref INVALID for the usage.
3.33 + struct Invalid {
3.34 + public:
3.35 + bool operator==(Invalid) { return true; }
3.36 + bool operator!=(Invalid) { return false; }
3.37 + bool operator< (Invalid) { return false; }
3.38 + };
3.39 +
3.40 + /// Invalid iterators.
3.41 +
3.42 + /// \ref Invalid is a global type that converts to each iterator
3.43 + /// in such a way that the value of the target iterator will be invalid.
3.44 +
3.45 + //Some people didn't like this:
3.46 + //const Invalid &INVALID = *(Invalid *)0;
3.47 +
3.48 +#ifdef LEMON_ONLY_TEMPLATES
3.49 + const Invalid INVALID = Invalid();
3.50 +#else
3.51 + extern const Invalid INVALID;
3.52 +#endif
3.53 +
3.54 +} //namespace lemon
3.55 +
3.56 +#endif
3.57 +
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/lemon/bits/utility.h Thu Dec 20 15:59:06 2007 +0000
4.3 @@ -0,0 +1,140 @@
4.4 +/* -*- C++ -*-
4.5 + *
4.6 + * This file is a part of LEMON, a generic C++ optimization library
4.7 + *
4.8 + * Copyright (C) 2003-2007
4.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
4.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
4.11 + *
4.12 + * Permission to use, modify and distribute this software is granted
4.13 + * provided that this copyright notice appears in all copies. For
4.14 + * precise terms see the accompanying LICENSE file.
4.15 + *
4.16 + * This software is provided "AS IS" with no warranty of any kind,
4.17 + * express or implied, and with no claim as to its suitability for any
4.18 + * purpose.
4.19 + *
4.20 + */
4.21 +
4.22 +// This file contains a modified version of the enable_if library from BOOST.
4.23 +// See the appropriate copyright notice below.
4.24 +
4.25 +// Boost enable_if library
4.26 +
4.27 +// Copyright 2003 © The Trustees of Indiana University.
4.28 +
4.29 +// Use, modification, and distribution is subject to the Boost Software
4.30 +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
4.31 +// http://www.boost.org/LICENSE_1_0.txt)
4.32 +
4.33 +// Authors: Jaakko Järvi (jajarvi at osl.iu.edu)
4.34 +// Jeremiah Willcock (jewillco at osl.iu.edu)
4.35 +// Andrew Lumsdaine (lums at osl.iu.edu)
4.36 +
4.37 +
4.38 +#ifndef LEMON_BITS_UTILITY_H
4.39 +#define LEMON_BITS_UTILITY_H
4.40 +
4.41 +///\file
4.42 +///\brief Miscellaneous basic utilities
4.43 +///
4.44 +///\todo Please rethink the organisation of the basic files like this.
4.45 +///E.g. this file might be merged with invalid.h.
4.46 +
4.47 +
4.48 +namespace lemon
4.49 +{
4.50 +
4.51 + /// Basic type for defining "tags". A "YES" condition for \c enable_if.
4.52 +
4.53 + /// Basic type for defining "tags". A "YES" condition for \c enable_if.
4.54 + ///
4.55 + ///\sa False
4.56 + ///
4.57 + /// \todo This should go to a separate "basic_types.h" (or something)
4.58 + /// file.
4.59 + struct True {
4.60 + ///\e
4.61 + static const bool value = true;
4.62 + };
4.63 +
4.64 + /// Basic type for defining "tags". A "NO" condition for \c enable_if.
4.65 +
4.66 + /// Basic type for defining "tags". A "NO" condition for \c enable_if.
4.67 + ///
4.68 + ///\sa True
4.69 + struct False {
4.70 + ///\e
4.71 + static const bool value = false;
4.72 + };
4.73 +
4.74 +
4.75 + struct InvalidType {
4.76 + };
4.77 +
4.78 + template <typename T>
4.79 + struct Wrap {
4.80 + const T &value;
4.81 + Wrap(const T &t) : value(t) {}
4.82 + };
4.83 +
4.84 + /**************** dummy class to avoid ambiguity ****************/
4.85 +
4.86 + template<int T> struct dummy { dummy(int) {} };
4.87 +
4.88 + /**************** enable_if from BOOST ****************/
4.89 +
4.90 + template <typename Type, typename T = void>
4.91 + struct exists {
4.92 + typedef T type;
4.93 + };
4.94 +
4.95 +
4.96 + template <bool B, class T = void>
4.97 + struct enable_if_c {
4.98 + typedef T type;
4.99 + };
4.100 +
4.101 + template <class T>
4.102 + struct enable_if_c<false, T> {};
4.103 +
4.104 + template <class Cond, class T = void>
4.105 + struct enable_if : public enable_if_c<Cond::value, T> {};
4.106 +
4.107 + template <bool B, class T>
4.108 + struct lazy_enable_if_c {
4.109 + typedef typename T::type type;
4.110 + };
4.111 +
4.112 + template <class T>
4.113 + struct lazy_enable_if_c<false, T> {};
4.114 +
4.115 + template <class Cond, class T>
4.116 + struct lazy_enable_if : public lazy_enable_if_c<Cond::value, T> {};
4.117 +
4.118 +
4.119 + template <bool B, class T = void>
4.120 + struct disable_if_c {
4.121 + typedef T type;
4.122 + };
4.123 +
4.124 + template <class T>
4.125 + struct disable_if_c<true, T> {};
4.126 +
4.127 + template <class Cond, class T = void>
4.128 + struct disable_if : public disable_if_c<Cond::value, T> {};
4.129 +
4.130 + template <bool B, class T>
4.131 + struct lazy_disable_if_c {
4.132 + typedef typename T::type type;
4.133 + };
4.134 +
4.135 + template <class T>
4.136 + struct lazy_disable_if_c<true, T> {};
4.137 +
4.138 + template <class Cond, class T>
4.139 + struct lazy_disable_if : public lazy_disable_if_c<Cond::value, T> {};
4.140 +
4.141 +} // namespace lemon
4.142 +
4.143 +#endif
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/lemon/tolerance.h Thu Dec 20 15:59:06 2007 +0000
5.3 @@ -0,0 +1,454 @@
5.4 +/* -*- C++ -*-
5.5 + *
5.6 + * This file is a part of LEMON, a generic C++ optimization library
5.7 + *
5.8 + * Copyright (C) 2003-2007
5.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
5.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
5.11 + *
5.12 + * Permission to use, modify and distribute this software is granted
5.13 + * provided that this copyright notice appears in all copies. For
5.14 + * precise terms see the accompanying LICENSE file.
5.15 + *
5.16 + * This software is provided "AS IS" with no warranty of any kind,
5.17 + * express or implied, and with no claim as to its suitability for any
5.18 + * purpose.
5.19 + *
5.20 + */
5.21 +
5.22 +#ifndef LEMON_TOLERANCE_H
5.23 +#define LEMON_TOLERANCE_H
5.24 +
5.25 +///\ingroup misc
5.26 +///\file
5.27 +///\brief A basic tool to handle the anomalies of calculation with
5.28 +///floating point numbers.
5.29 +///
5.30 +///\todo It should be in a module like "Basic tools"
5.31 +
5.32 +
5.33 +namespace lemon {
5.34 +
5.35 + /// \addtogroup misc
5.36 + /// @{
5.37 +
5.38 + ///\brief A class to provide a basic way to
5.39 + ///handle the comparison of numbers that are obtained
5.40 + ///as a result of a probably inexact computation.
5.41 + ///
5.42 + ///Tolerance is a class to provide a basic way to
5.43 + ///handle the comparison of numbers that are obtained
5.44 + ///as a result of a probably inexact computation.
5.45 + ///
5.46 + ///This is an abstract class, it should be specialized for all numerical
5.47 + ///data types. These specialized classes like \ref Tolerance\<double\>
5.48 + ///may offer additional tuning parameters.
5.49 + ///
5.50 + ///\sa Tolerance<float>
5.51 + ///\sa Tolerance<double>
5.52 + ///\sa Tolerance<long double>
5.53 + ///\sa Tolerance<int>
5.54 + ///\sa Tolerance<long long int>
5.55 + ///\sa Tolerance<unsigned int>
5.56 + ///\sa Tolerance<unsigned long long int>
5.57 +
5.58 + template<class T>
5.59 + class Tolerance
5.60 + {
5.61 + public:
5.62 + typedef T Value;
5.63 +
5.64 + ///\name Comparisons
5.65 + ///The concept is that these bool functions return with \c true only if
5.66 + ///the related comparisons hold even if some numerical error appeared
5.67 + ///during the computations.
5.68 +
5.69 + ///@{
5.70 +
5.71 + ///Returns \c true if \c a is \e surely strictly less than \c b
5.72 + static bool less(Value a,Value b) {return false;}
5.73 + ///Returns \c true if \c a is \e surely different from \c b
5.74 + static bool different(Value a,Value b) {return false;}
5.75 + ///Returns \c true if \c a is \e surely positive
5.76 + static bool positive(Value a) {return false;}
5.77 + ///Returns \c true if \c a is \e surely negative
5.78 + static bool negative(Value a) {return false;}
5.79 + ///Returns \c true if \c a is \e surely non-zero
5.80 + static bool nonZero(Value a) {return false;}
5.81 +
5.82 + ///@}
5.83 +
5.84 + ///Returns the zero value.
5.85 + static Value zero() {return T();}
5.86 +
5.87 + // static bool finite(Value a) {}
5.88 + // static Value big() {}
5.89 + // static Value negativeBig() {}
5.90 + };
5.91 +
5.92 +
5.93 + ///Float specialization of \ref Tolerance.
5.94 +
5.95 + ///Float specialization of \ref Tolerance.
5.96 + ///\sa Tolerance
5.97 + ///\relates Tolerance
5.98 + template<>
5.99 + class Tolerance<float>
5.100 + {
5.101 + static float def_epsilon;
5.102 + float _epsilon;
5.103 + public:
5.104 + ///\e
5.105 + typedef float Value;
5.106 +
5.107 + ///Constructor setting the epsilon tolerance to the default value.
5.108 + Tolerance() : _epsilon(def_epsilon) {}
5.109 + ///Constructor setting the epsilon tolerance.
5.110 + Tolerance(float e) : _epsilon(e) {}
5.111 +
5.112 + ///Return the epsilon value.
5.113 + Value epsilon() const {return _epsilon;}
5.114 + ///Set the epsilon value.
5.115 + void epsilon(Value e) {_epsilon=e;}
5.116 +
5.117 + ///Return the default epsilon value.
5.118 + static Value defaultEpsilon() {return def_epsilon;}
5.119 + ///Set the default epsilon value.
5.120 + static void defaultEpsilon(Value e) {def_epsilon=e;}
5.121 +
5.122 + ///\name Comparisons
5.123 + ///See class Tolerance for more details.
5.124 +
5.125 + ///@{
5.126 +
5.127 + ///Returns \c true if \c a is \e surely strictly less than \c b
5.128 + bool less(Value a,Value b) const {return a+_epsilon<b;}
5.129 + ///Returns \c true if \c a is \e surely different from \c b
5.130 + bool different(Value a,Value b) const { return less(a,b)||less(b,a); }
5.131 + ///Returns \c true if \c a is \e surely positive
5.132 + bool positive(Value a) const { return _epsilon<a; }
5.133 + ///Returns \c true if \c a is \e surely negative
5.134 + bool negative(Value a) const { return -_epsilon>a; }
5.135 + ///Returns \c true if \c a is \e surely non-zero
5.136 + bool nonZero(Value a) const { return positive(a)||negative(a); };
5.137 +
5.138 + ///@}
5.139 +
5.140 + ///Returns zero
5.141 + static Value zero() {return 0;}
5.142 + };
5.143 +
5.144 + ///Double specialization of \ref Tolerance.
5.145 +
5.146 + ///Double specialization of \ref Tolerance.
5.147 + ///\sa Tolerance
5.148 + ///\relates Tolerance
5.149 + template<>
5.150 + class Tolerance<double>
5.151 + {
5.152 + static double def_epsilon;
5.153 + double _epsilon;
5.154 + public:
5.155 + ///\e
5.156 + typedef double Value;
5.157 +
5.158 + ///Constructor setting the epsilon tolerance to the default value.
5.159 + Tolerance() : _epsilon(def_epsilon) {}
5.160 + ///Constructor setting the epsilon tolerance.
5.161 + Tolerance(double e) : _epsilon(e) {}
5.162 +
5.163 + ///Return the epsilon value.
5.164 + Value epsilon() const {return _epsilon;}
5.165 + ///Set the epsilon value.
5.166 + void epsilon(Value e) {_epsilon=e;}
5.167 +
5.168 + ///Return the default epsilon value.
5.169 + static Value defaultEpsilon() {return def_epsilon;}
5.170 + ///Set the default epsilon value.
5.171 + static void defaultEpsilon(Value e) {def_epsilon=e;}
5.172 +
5.173 + ///\name Comparisons
5.174 + ///See class Tolerance for more details.
5.175 +
5.176 + ///@{
5.177 +
5.178 + ///Returns \c true if \c a is \e surely strictly less than \c b
5.179 + bool less(Value a,Value b) const {return a+_epsilon<b;}
5.180 + ///Returns \c true if \c a is \e surely different from \c b
5.181 + bool different(Value a,Value b) const { return less(a,b)||less(b,a); }
5.182 + ///Returns \c true if \c a is \e surely positive
5.183 + bool positive(Value a) const { return _epsilon<a; }
5.184 + ///Returns \c true if \c a is \e surely negative
5.185 + bool negative(Value a) const { return -_epsilon>a; }
5.186 + ///Returns \c true if \c a is \e surely non-zero
5.187 + bool nonZero(Value a) const { return positive(a)||negative(a); };
5.188 +
5.189 + ///@}
5.190 +
5.191 + ///Returns zero
5.192 + static Value zero() {return 0;}
5.193 + };
5.194 +
5.195 + ///Long double specialization of \ref Tolerance.
5.196 +
5.197 + ///Long double specialization of \ref Tolerance.
5.198 + ///\sa Tolerance
5.199 + ///\relates Tolerance
5.200 + template<>
5.201 + class Tolerance<long double>
5.202 + {
5.203 + static long double def_epsilon;
5.204 + long double _epsilon;
5.205 + public:
5.206 + ///\e
5.207 + typedef long double Value;
5.208 +
5.209 + ///Constructor setting the epsilon tolerance to the default value.
5.210 + Tolerance() : _epsilon(def_epsilon) {}
5.211 + ///Constructor setting the epsilon tolerance.
5.212 + Tolerance(long double e) : _epsilon(e) {}
5.213 +
5.214 + ///Return the epsilon value.
5.215 + Value epsilon() const {return _epsilon;}
5.216 + ///Set the epsilon value.
5.217 + void epsilon(Value e) {_epsilon=e;}
5.218 +
5.219 + ///Return the default epsilon value.
5.220 + static Value defaultEpsilon() {return def_epsilon;}
5.221 + ///Set the default epsilon value.
5.222 + static void defaultEpsilon(Value e) {def_epsilon=e;}
5.223 +
5.224 + ///\name Comparisons
5.225 + ///See class Tolerance for more details.
5.226 +
5.227 + ///@{
5.228 +
5.229 + ///Returns \c true if \c a is \e surely strictly less than \c b
5.230 + bool less(Value a,Value b) const {return a+_epsilon<b;}
5.231 + ///Returns \c true if \c a is \e surely different from \c b
5.232 + bool different(Value a,Value b) const { return less(a,b)||less(b,a); }
5.233 + ///Returns \c true if \c a is \e surely positive
5.234 + bool positive(Value a) const { return _epsilon<a; }
5.235 + ///Returns \c true if \c a is \e surely negative
5.236 + bool negative(Value a) const { return -_epsilon>a; }
5.237 + ///Returns \c true if \c a is \e surely non-zero
5.238 + bool nonZero(Value a) const { return positive(a)||negative(a); };
5.239 +
5.240 + ///@}
5.241 +
5.242 + ///Returns zero
5.243 + static Value zero() {return 0;}
5.244 + };
5.245 +
5.246 + ///Integer specialization of \ref Tolerance.
5.247 +
5.248 + ///Integer specialization of \ref Tolerance.
5.249 + ///\sa Tolerance
5.250 + template<>
5.251 + class Tolerance<int>
5.252 + {
5.253 + public:
5.254 + ///\e
5.255 + typedef int Value;
5.256 +
5.257 + ///\name Comparisons
5.258 + ///See \ref Tolerance for more details.
5.259 +
5.260 + ///@{
5.261 +
5.262 + ///Returns \c true if \c a is \e surely strictly less than \c b
5.263 + static bool less(Value a,Value b) { return a<b;}
5.264 + ///Returns \c true if \c a is \e surely different from \c b
5.265 + static bool different(Value a,Value b) { return a!=b; }
5.266 + ///Returns \c true if \c a is \e surely positive
5.267 + static bool positive(Value a) { return 0<a; }
5.268 + ///Returns \c true if \c a is \e surely negative
5.269 + static bool negative(Value a) { return 0>a; }
5.270 + ///Returns \c true if \c a is \e surely non-zero
5.271 + static bool nonZero(Value a) { return a!=0; };
5.272 +
5.273 + ///@}
5.274 +
5.275 + ///Returns zero
5.276 + static Value zero() {return 0;}
5.277 + };
5.278 +
5.279 + ///Unsigned integer specialization of \ref Tolerance.
5.280 +
5.281 + ///Unsigned integer specialization of \ref Tolerance.
5.282 + ///\sa Tolerance
5.283 + template<>
5.284 + class Tolerance<unsigned int>
5.285 + {
5.286 + public:
5.287 + ///\e
5.288 + typedef unsigned int Value;
5.289 +
5.290 + ///\name Comparisons
5.291 + ///See \ref Tolerance for more details.
5.292 +
5.293 + ///@{
5.294 +
5.295 + ///Returns \c true if \c a is \e surely strictly less than \c b
5.296 + static bool less(Value a,Value b) { return a<b;}
5.297 + ///Returns \c true if \c a is \e surely different from \c b
5.298 + static bool different(Value a,Value b) { return a!=b; }
5.299 + ///Returns \c true if \c a is \e surely positive
5.300 + static bool positive(Value a) { return 0<a; }
5.301 + ///Returns \c true if \c a is \e surely negative
5.302 + static bool negative(Value) { return false; }
5.303 + ///Returns \c true if \c a is \e surely non-zero
5.304 + static bool nonZero(Value a) { return a!=0; };
5.305 +
5.306 + ///@}
5.307 +
5.308 + ///Returns zero
5.309 + static Value zero() {return 0;}
5.310 + };
5.311 +
5.312 +
5.313 + ///Long integer specialization of \ref Tolerance.
5.314 +
5.315 + ///Long integer specialization of \ref Tolerance.
5.316 + ///\sa Tolerance
5.317 + template<>
5.318 + class Tolerance<long int>
5.319 + {
5.320 + public:
5.321 + ///\e
5.322 + typedef long int Value;
5.323 +
5.324 + ///\name Comparisons
5.325 + ///See \ref Tolerance for more details.
5.326 +
5.327 + ///@{
5.328 +
5.329 + ///Returns \c true if \c a is \e surely strictly less than \c b
5.330 + static bool less(Value a,Value b) { return a<b;}
5.331 + ///Returns \c true if \c a is \e surely different from \c b
5.332 + static bool different(Value a,Value b) { return a!=b; }
5.333 + ///Returns \c true if \c a is \e surely positive
5.334 + static bool positive(Value a) { return 0<a; }
5.335 + ///Returns \c true if \c a is \e surely negative
5.336 + static bool negative(Value a) { return 0>a; }
5.337 + ///Returns \c true if \c a is \e surely non-zero
5.338 + static bool nonZero(Value a) { return a!=0;};
5.339 +
5.340 + ///@}
5.341 +
5.342 + ///Returns zero
5.343 + static Value zero() {return 0;}
5.344 + };
5.345 +
5.346 + ///Unsigned long integer specialization of \ref Tolerance.
5.347 +
5.348 + ///Unsigned long integer specialization of \ref Tolerance.
5.349 + ///\sa Tolerance
5.350 + template<>
5.351 + class Tolerance<unsigned long int>
5.352 + {
5.353 + public:
5.354 + ///\e
5.355 + typedef unsigned long int Value;
5.356 +
5.357 + ///\name Comparisons
5.358 + ///See \ref Tolerance for more details.
5.359 +
5.360 + ///@{
5.361 +
5.362 + ///Returns \c true if \c a is \e surely strictly less than \c b
5.363 + static bool less(Value a,Value b) { return a<b;}
5.364 + ///Returns \c true if \c a is \e surely different from \c b
5.365 + static bool different(Value a,Value b) { return a!=b; }
5.366 + ///Returns \c true if \c a is \e surely positive
5.367 + static bool positive(Value a) { return 0<a; }
5.368 + ///Returns \c true if \c a is \e surely negative
5.369 + static bool negative(Value) { return false; }
5.370 + ///Returns \c true if \c a is \e surely non-zero
5.371 + static bool nonZero(Value a) { return a!=0;};
5.372 +
5.373 + ///@}
5.374 +
5.375 + ///Returns zero
5.376 + static Value zero() {return 0;}
5.377 + };
5.378 +
5.379 +#if defined __GNUC__ && !defined __STRICT_ANSI__
5.380 +
5.381 + ///Long long integer specialization of \ref Tolerance.
5.382 +
5.383 + ///Long long integer specialization of \ref Tolerance.
5.384 + ///\warning This class (more exactly, type <tt>long long</tt>)
5.385 + ///is not ansi compatible.
5.386 + ///\sa Tolerance
5.387 + template<>
5.388 + class Tolerance<long long int>
5.389 + {
5.390 + public:
5.391 + ///\e
5.392 + typedef long long int Value;
5.393 +
5.394 + ///\name Comparisons
5.395 + ///See \ref Tolerance for more details.
5.396 +
5.397 + ///@{
5.398 +
5.399 + ///Returns \c true if \c a is \e surely strictly less than \c b
5.400 + static bool less(Value a,Value b) { return a<b;}
5.401 + ///Returns \c true if \c a is \e surely different from \c b
5.402 + static bool different(Value a,Value b) { return a!=b; }
5.403 + ///Returns \c true if \c a is \e surely positive
5.404 + static bool positive(Value a) { return 0<a; }
5.405 + ///Returns \c true if \c a is \e surely negative
5.406 + static bool negative(Value a) { return 0>a; }
5.407 + ///Returns \c true if \c a is \e surely non-zero
5.408 + static bool nonZero(Value a) { return a!=0;};
5.409 +
5.410 + ///@}
5.411 +
5.412 + ///Returns zero
5.413 + static Value zero() {return 0;}
5.414 + };
5.415 +
5.416 + ///Unsigned long long integer specialization of \ref Tolerance.
5.417 +
5.418 + ///Unsigned long long integer specialization of \ref Tolerance.
5.419 + ///\warning This class (more exactly, type <tt>unsigned long long</tt>)
5.420 + ///is not ansi compatible.
5.421 + ///\sa Tolerance
5.422 + template<>
5.423 + class Tolerance<unsigned long long int>
5.424 + {
5.425 + public:
5.426 + ///\e
5.427 + typedef unsigned long long int Value;
5.428 +
5.429 + ///\name Comparisons
5.430 + ///See \ref Tolerance for more details.
5.431 +
5.432 + ///@{
5.433 +
5.434 + ///Returns \c true if \c a is \e surely strictly less than \c b
5.435 + static bool less(Value a,Value b) { return a<b;}
5.436 + ///Returns \c true if \c a is \e surely different from \c b
5.437 + static bool different(Value a,Value b) { return a!=b; }
5.438 + ///Returns \c true if \c a is \e surely positive
5.439 + static bool positive(Value a) { return 0<a; }
5.440 + ///Returns \c true if \c a is \e surely negative
5.441 + static bool negative(Value) { return false; }
5.442 + ///Returns \c true if \c a is \e surely non-zero
5.443 + static bool nonZero(Value a) { return a!=0;};
5.444 +
5.445 + ///@}
5.446 +
5.447 + ///Returns zero
5.448 + static Value zero() {return 0;}
5.449 + };
5.450 +
5.451 +#endif
5.452 +
5.453 + /// @}
5.454 +
5.455 +} //namespace lemon
5.456 +
5.457 +#endif //LEMON_TOLERANCE_H