Some clean files added.
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/doc/namespaces.dox Thu Aug 10 14:56:36 2006 +0000
1.3 @@ -0,0 +1,12 @@
1.4 +/// The namespace of LEMON
1.5 +
1.6 +/// The namespace of LEMON
1.7 +///
1.8 +namespace lemon {
1.9 +
1.10 + /// The namespace of LEMON concepts and concept checking classes
1.11 +
1.12 + /// The namespace of LEMON concepts and concept checking classes
1.13 + ///
1.14 + namespace concept {}
1.15 +}
2.1 --- a/lemon/Makefile.am Wed Jul 19 13:08:10 2006 +0000
2.2 +++ b/lemon/Makefile.am Thu Aug 10 14:56:36 2006 +0000
2.3 @@ -6,10 +6,11 @@
2.4
2.5 lib_LTLIBRARIES += lemon/libemon.la
2.6
2.7 -lemon_libemon_la_SOURCES =
2.8 +lemon_libemon_la_SOURCES = \
2.9 ## lemon/lp_base.cc \
2.10 ## lemon/lp_skeleton.cc \
2.11 -## lemon/base.cc \
2.12 + lemon/base.cc \
2.13 + lemon/color.cc
2.14 ## lemon/eps.cc \
2.15 ## lemon/bits/mingw32_rand.cc \
2.16 ## lemon/bits/mingw32_time.cc
2.17 @@ -25,7 +26,7 @@
2.18 ##lemon_libemon_la_SOURCES += lemon/lp_cplex.cc
2.19 endif
2.20
2.21 -lemon_HEADERS +=
2.22 +lemon_HEADERS += \
2.23 ## lemon/bellman_ford.h \
2.24 ## lemon/bezier.h \
2.25 ## lemon/bfs.h \
2.26 @@ -33,7 +34,7 @@
2.27 ## lemon/bipartite_matching.h \
2.28 ## lemon/bpugraph_adaptor.h \
2.29 ## lemon/bucket_heap.h \
2.30 -## lemon/color.h \
2.31 + lemon/color.h \
2.32 ## lemon/config.h \
2.33 ## lemon/counter.h \
2.34 ## lemon/dag_shortest_path.h \
2.35 @@ -86,7 +87,7 @@
2.36 ## lemon/suurballe.h \
2.37 ## lemon/tabu_search.h \
2.38 ## lemon/time_measure.h \
2.39 -## lemon/tolerance.h \
2.40 + lemon/tolerance.h
2.41 ## lemon/topology.h \
2.42 ## lemon/ugraph_adaptor.h \
2.43 ## lemon/unionfind.h \
2.44 @@ -100,7 +101,7 @@
2.45 ## lemon/bits/edge_set_extender.h \
2.46 ## lemon/bits/graph_adaptor_extender.h \
2.47 ## lemon/bits/graph_extender.h \
2.48 -## lemon/bits/invalid.h \
2.49 + lemon/bits/invalid.h
2.50 ## lemon/bits/item_reader.h \
2.51 ## lemon/bits/item_writer.h \
2.52 ## lemon/bits/map_extender.h \
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/lemon/base.cc Thu Aug 10 14:56:36 2006 +0000
3.3 @@ -0,0 +1,34 @@
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-2006
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 +///\file
3.23 +///\brief Some basic non inline function and static global data.
3.24 +
3.25 +#include<lemon/tolerance.h>
3.26 +#include<lemon/bits/invalid.h>
3.27 +namespace lemon {
3.28 +
3.29 + float Tolerance<float>::def_epsilon = 1e-4;
3.30 + double Tolerance<double>::def_epsilon = 1e-10;
3.31 + long double Tolerance<long double>::def_epsilon = 1e-14;
3.32 +
3.33 +#ifndef LEMON_ONLY_TEMPLATES
3.34 + const Invalid INVALID = Invalid();
3.35 +#endif
3.36 +
3.37 +} //namespace lemon
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/lemon/bits/invalid.h Thu Aug 10 14:56:36 2006 +0000
4.3 @@ -0,0 +1,54 @@
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-2006
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 +#ifndef LEMON_BITS_INVALID_H
4.23 +#define LEMON_BITS_INVALID_H
4.24 +
4.25 +///\file
4.26 +///\brief Definition of INVALID.
4.27 +
4.28 +namespace lemon {
4.29 +
4.30 + /// \brief Dummy type to make it easier to make invalid iterators.
4.31 + ///
4.32 + /// See \ref INVALID for the usage.
4.33 + struct Invalid {
4.34 + public:
4.35 + bool operator==(Invalid) { return true; }
4.36 + bool operator!=(Invalid) { return false; }
4.37 + bool operator< (Invalid) { return false; }
4.38 + };
4.39 +
4.40 + /// Invalid iterators.
4.41 +
4.42 + /// \ref Invalid is a global type that converts to each iterator
4.43 + /// in such a way that the value of the target iterator will be invalid.
4.44 +
4.45 + //Some people didn't like this:
4.46 + //const Invalid &INVALID = *(Invalid *)0;
4.47 +
4.48 +#ifdef LEMON_ONLY_TEMPLATES
4.49 + const Invalid INVALID = Invalid();
4.50 +#else
4.51 + extern const Invalid INVALID;
4.52 +#endif
4.53 +
4.54 +} //namespace lemon
4.55 +
4.56 +#endif
4.57 +
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/lemon/color.cc Thu Aug 10 14:56:36 2006 +0000
5.3 @@ -0,0 +1,44 @@
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-2006
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 +///\file
5.23 +///\brief Color constants
5.24 +
5.25 +#include<lemon/color.h>
5.26 +
5.27 +namespace lemon {
5.28 +
5.29 + const Color WHITE(1,1,1);
5.30 +
5.31 + const Color BLACK(0,0,0);
5.32 + const Color RED(1,0,0);
5.33 + const Color GREEN(0,1,0);
5.34 + const Color BLUE(0,0,1);
5.35 + const Color YELLOW(1,1,0);
5.36 + const Color MAGENTA(1,0,1);
5.37 + const Color CYAN(0,1,1);
5.38 +
5.39 + const Color GREY(0,0,0);
5.40 + const Color DARK_RED(.5,0,0);
5.41 + const Color DARK_GREEN(0,.5,0);
5.42 + const Color DARK_BLUE(0,0,.5);
5.43 + const Color DARK_YELLOW(.5,.5,0);
5.44 + const Color DARK_MAGENTA(.5,0,.5);
5.45 + const Color DARK_CYAN(0,.5,.5);
5.46 +
5.47 +} //namespace lemon
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/lemon/color.h Thu Aug 10 14:56:36 2006 +0000
6.3 @@ -0,0 +1,211 @@
6.4 +/* -*- C++ -*-
6.5 + *
6.6 + * This file is a part of LEMON, a generic C++ optimization library
6.7 + *
6.8 + * Copyright (C) 2003-2006
6.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
6.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
6.11 + *
6.12 + * Permission to use, modify and distribute this software is granted
6.13 + * provided that this copyright notice appears in all copies. For
6.14 + * precise terms see the accompanying LICENSE file.
6.15 + *
6.16 + * This software is provided "AS IS" with no warranty of any kind,
6.17 + * express or implied, and with no claim as to its suitability for any
6.18 + * purpose.
6.19 + *
6.20 + */
6.21 +
6.22 +#ifndef LEMON_COLOR_H
6.23 +#define LEMON_COLOR_H
6.24 +
6.25 +#include <sys/time.h>
6.26 +
6.27 +#include<iostream>
6.28 +#include<fstream>
6.29 +#include<sstream>
6.30 +#include<algorithm>
6.31 +#include<vector>
6.32 +
6.33 +#include <ctime>
6.34 +#include <cmath>
6.35 +
6.36 +#include<lemon/bits/invalid.h>
6.37 +#include<lemon/xy.h>
6.38 +#include<lemon/maps.h>
6.39 +#include<lemon/bezier.h>
6.40 +
6.41 +
6.42 +///\ingroup misc
6.43 +///\file
6.44 +///\brief Tools to manage RGB colors.
6.45 +///
6.46 +///\author Alpar Juttner
6.47 +
6.48 +namespace lemon {
6.49 +
6.50 + /// \addtogroup misc
6.51 + /// @{
6.52 +
6.53 +///Data structure representing RGB colors.
6.54 +
6.55 +///Data structure representing RGB colors.
6.56 +///\ingroup misc
6.57 +class Color
6.58 +{
6.59 + double _r,_g,_b;
6.60 +public:
6.61 + ///Default constructor
6.62 + Color() {}
6.63 + ///Constructor
6.64 + Color(double r,double g,double b) :_r(r),_g(g),_b(b) {};
6.65 + ///Set the red component
6.66 + double & red() {return _r;}
6.67 + ///Return the red component
6.68 + const double & red() const {return _r;}
6.69 + ///Set the green component
6.70 + double & green() {return _g;}
6.71 + ///Return the green component
6.72 + const double & green() const {return _g;}
6.73 + ///Set the blue component
6.74 + double & blue() {return _b;}
6.75 + ///Return the blue component
6.76 + const double & blue() const {return _b;}
6.77 + ///Set the color components
6.78 + void set(double r,double g,double b) { _r=r;_g=g;_b=b; };
6.79 +};
6.80 +
6.81 + /// White color constant
6.82 + extern const Color WHITE;
6.83 + /// Black color constant
6.84 + extern const Color BLACK;
6.85 + /// Red color constant
6.86 + extern const Color RED;
6.87 + /// Green color constant
6.88 + extern const Color GREEN;
6.89 + /// Blue color constant
6.90 + extern const Color BLUE;
6.91 + /// Yellow color constant
6.92 + extern const Color YELLOW;
6.93 + /// Magenta color constant
6.94 + extern const Color MAGENTA;
6.95 + /// Cyan color constant
6.96 + extern const Color CYAN;
6.97 + /// Grey color constant
6.98 + extern const Color GREY;
6.99 + /// Dark red color constant
6.100 + extern const Color DARK_RED;
6.101 + /// Dark green color constant
6.102 + extern const Color DARK_GREEN;
6.103 + /// Drak blue color constant
6.104 + extern const Color DARK_BLUE;
6.105 + /// Dark yellow color constant
6.106 + extern const Color DARK_YELLOW;
6.107 + /// Dark magenta color constant
6.108 + extern const Color DARK_MAGENTA;
6.109 + /// Dark cyan color constant
6.110 + extern const Color DARK_CYAN;
6.111 +
6.112 +///Maps <tt>int</tt>s to different \ref Color "Color"s
6.113 +
6.114 +///This map assigns one of the predefined \ref Color "Color"s
6.115 +///to each <tt>int</tt>. It is possible to change the colors as well as their
6.116 +///number. The integer range is cyclically mapped to the provided set of colors.
6.117 +///
6.118 +///This is a true \ref concept::ReferenceMap "reference map", so you can also
6.119 +///change the actual colors.
6.120 +
6.121 +class Palette : public MapBase<int,Color>
6.122 +{
6.123 + std::vector<Color> colors;
6.124 +public:
6.125 + ///Constructor
6.126 +
6.127 + ///Constructor
6.128 + ///\param have_white indicates whether white is
6.129 + ///amongst the provided color (\c true) or not (\c false). If it is true,
6.130 + ///white will be assigned to \c 0.
6.131 + ///\param num the number of the allocated colors. If it is \c 0,
6.132 + ///the default color configuration is set up (26 color plus the white).
6.133 + ///If \c num is less then 26/27 then the default color list is cut. Otherwise
6.134 + ///the color list is filled repeatedly with the default color list.
6.135 + ///(The colors can be changed later on.)
6.136 + Palette(bool have_white=false,int num=0)
6.137 + {
6.138 + do {
6.139 + if(have_white) colors.push_back(Color(1,1,1));
6.140 +
6.141 + colors.push_back(Color(0,0,0));
6.142 + colors.push_back(Color(1,0,0));
6.143 + colors.push_back(Color(0,1,0));
6.144 + colors.push_back(Color(0,0,1));
6.145 + colors.push_back(Color(1,1,0));
6.146 + colors.push_back(Color(1,0,1));
6.147 + colors.push_back(Color(0,1,1));
6.148 +
6.149 + colors.push_back(Color(.5,0,0));
6.150 + colors.push_back(Color(0,.5,0));
6.151 + colors.push_back(Color(0,0,.5));
6.152 + colors.push_back(Color(.5,.5,0));
6.153 + colors.push_back(Color(.5,0,.5));
6.154 + colors.push_back(Color(0,.5,.5));
6.155 +
6.156 + colors.push_back(Color(.5,.5,.5));
6.157 + colors.push_back(Color(1,.5,.5));
6.158 + colors.push_back(Color(.5,1,.5));
6.159 + colors.push_back(Color(.5,.5,1));
6.160 + colors.push_back(Color(1,1,.5));
6.161 + colors.push_back(Color(1,.5,1));
6.162 + colors.push_back(Color(.5,1,1));
6.163 +
6.164 + colors.push_back(Color(1,.5,0));
6.165 + colors.push_back(Color(.5,1,0));
6.166 + colors.push_back(Color(1,0,.5));
6.167 + colors.push_back(Color(0,1,.5));
6.168 + colors.push_back(Color(0,.5,1));
6.169 + colors.push_back(Color(.5,0,1));
6.170 + } while(int(colors.size())<num);
6.171 + // colors.push_back(Color(1,1,1));
6.172 + if(num>0) colors.resize(num);
6.173 + }
6.174 + ///\e
6.175 + Color &operator[](int i)
6.176 + {
6.177 + return colors[i%colors.size()];
6.178 + }
6.179 + ///\e
6.180 + const Color &operator[](int i) const
6.181 + {
6.182 + return colors[i%colors.size()];
6.183 + }
6.184 + ///\e
6.185 + void set(int i,const Color &c)
6.186 + {
6.187 + colors[i%colors.size()]=c;
6.188 + }
6.189 + ///Sets the number of the exiting colors.
6.190 + void resize(int s) { colors.resize(s);}
6.191 + ///Returns the number of the existing colors.
6.192 + std::size_t size() const { return colors.size();}
6.193 +};
6.194 +
6.195 +///Returns a visible distinct \ref Color
6.196 +
6.197 +///Returns a \ref Color which is as different from the given parameter
6.198 +///as it is possible.
6.199 +inline Color distantColor(const Color &c)
6.200 +{
6.201 + return Color(c.red()<.5?1:0,c.green()<.5?1:0,c.blue()<.5?1:0);
6.202 +}
6.203 +///Returns black for light colors and white for the dark ones.
6.204 +
6.205 +///Returns black for light colors and white for the dark ones.
6.206 +inline Color distantBW(const Color &c){
6.207 + return (.2125*c.red()+.7154*c.green()+.0721*c.blue())<.5 ? WHITE : BLACK;
6.208 +}
6.209 +
6.210 +/// @}
6.211 +
6.212 +} //END OF NAMESPACE LEMON
6.213 +
6.214 +#endif // LEMON_COLOR_H
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/lemon/tolerance.h Thu Aug 10 14:56:36 2006 +0000
7.3 @@ -0,0 +1,387 @@
7.4 +/* -*- C++ -*-
7.5 + *
7.6 + * This file is a part of LEMON, a generic C++ optimization library
7.7 + *
7.8 + * Copyright (C) 2003-2006
7.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
7.11 + *
7.12 + * Permission to use, modify and distribute this software is granted
7.13 + * provided that this copyright notice appears in all copies. For
7.14 + * precise terms see the accompanying LICENSE file.
7.15 + *
7.16 + * This software is provided "AS IS" with no warranty of any kind,
7.17 + * express or implied, and with no claim as to its suitability for any
7.18 + * purpose.
7.19 + *
7.20 + */
7.21 +
7.22 +#ifndef LEMON_TOLERANCE_H
7.23 +#define LEMON_TOLERANCE_H
7.24 +
7.25 +///\ingroup misc
7.26 +///\file
7.27 +///\brief A basic tool to handle the anomalies of calculation with
7.28 +///floating point numbers.
7.29 +///
7.30 +///\todo It should be in a module like "Basic tools"
7.31 +
7.32 +
7.33 +namespace lemon {
7.34 +
7.35 + /// \addtogroup misc
7.36 + /// @{
7.37 +
7.38 + ///\brief A class to provide a basic way to
7.39 + ///handle the comparison of numbers that are obtained
7.40 + ///as a result of a probably inexact computation.
7.41 + ///
7.42 + ///Tolerance is a class to provide a basic way to
7.43 + ///handle the comparison of numbers that are obtained
7.44 + ///as a result of a probably inexact computation.
7.45 + ///
7.46 + ///This is an abstract class, it should be specialized for all numerical
7.47 + ///data types. These specialized classes like \ref Tolerance\<double\>
7.48 + ///may offer additional tuning parameters.
7.49 + ///
7.50 + ///\sa Tolerance<float>
7.51 + ///\sa Tolerance<double>
7.52 + ///\sa Tolerance<long double>
7.53 + ///\sa Tolerance<int>
7.54 + ///\sa Tolerance<long long int>
7.55 + ///\sa Tolerance<unsigned int>
7.56 + ///\sa Tolerance<unsigned long long int>
7.57 +
7.58 + template<class T>
7.59 + class Tolerance
7.60 + {
7.61 + public:
7.62 + typedef T Value;
7.63 +
7.64 + ///\name Comparisons
7.65 + ///The concept is that these bool functions return with \c true only if
7.66 + ///the related comparisons hold even if some numerical error appeared
7.67 + ///during the computations.
7.68 +
7.69 + ///@{
7.70 +
7.71 + ///Returns \c true if \c a is \e surely strictly less than \c b
7.72 + static bool less(Value a,Value b) {return false;}
7.73 + ///Returns \c true if \c a is \e surely different from \c b
7.74 + static bool different(Value a,Value b) {return false;}
7.75 + ///Returns \c true if \c a is \e surely positive
7.76 + static bool positive(Value a) {return false;}
7.77 + ///Returns \c true if \c a is \e surely negative
7.78 + static bool negative(Value a) {return false;}
7.79 + ///Returns \c true if \c a is \e surely non-zero
7.80 + static bool nonZero(Value a) {return false;}
7.81 +
7.82 + ///@}
7.83 +
7.84 + ///Returns the zero value.
7.85 + static Value zero() {return T();}
7.86 +
7.87 + // static bool finite(Value a) {}
7.88 + // static Value big() {}
7.89 + // static Value negativeBig() {}
7.90 + };
7.91 +
7.92 +
7.93 + ///Float specialization of \ref Tolerance.
7.94 +
7.95 + ///Float specialization of \ref Tolerance.
7.96 + ///\sa Tolerance
7.97 + ///\relates Tolerance
7.98 + template<>
7.99 + class Tolerance<float>
7.100 + {
7.101 + static float def_epsilon;
7.102 + float _epsilon;
7.103 + public:
7.104 + ///\e
7.105 + typedef float Value;
7.106 +
7.107 + ///Constructor setting the epsilon tolerance to the default value.
7.108 + Tolerance() : _epsilon(def_epsilon) {}
7.109 + ///Constructor setting the epsilon tolerance.
7.110 + Tolerance(float e) : _epsilon(e) {}
7.111 +
7.112 + ///Return the epsilon value.
7.113 + Value epsilon() const {return _epsilon;}
7.114 + ///Set the epsilon value.
7.115 + void epsilon(Value e) {_epsilon=e;}
7.116 +
7.117 + ///Return the default epsilon value.
7.118 + static Value defaultEpsilon() {return def_epsilon;}
7.119 + ///Set the default epsilon value.
7.120 + static void defaultEpsilon(Value e) {def_epsilon=e;}
7.121 +
7.122 + ///\name Comparisons
7.123 + ///See class Tolerance for more details.
7.124 +
7.125 + ///@{
7.126 +
7.127 + ///Returns \c true if \c a is \e surely strictly less than \c b
7.128 + bool less(Value a,Value b) const {return a+_epsilon<b;}
7.129 + ///Returns \c true if \c a is \e surely different from \c b
7.130 + bool different(Value a,Value b) const { return less(a,b)||less(b,a); }
7.131 + ///Returns \c true if \c a is \e surely positive
7.132 + bool positive(Value a) const { return _epsilon<a; }
7.133 + ///Returns \c true if \c a is \e surely negative
7.134 + bool negative(Value a) const { return -_epsilon>a; }
7.135 + ///Returns \c true if \c a is \e surely non-zero
7.136 + bool nonZero(Value a) const { return positive(a)||negative(a); };
7.137 +
7.138 + ///@}
7.139 +
7.140 + ///Returns zero
7.141 + static Value zero() {return 0;}
7.142 + };
7.143 +
7.144 + ///Double specialization of \ref Tolerance.
7.145 +
7.146 + ///Double specialization of \ref Tolerance.
7.147 + ///\sa Tolerance
7.148 + ///\relates Tolerance
7.149 + template<>
7.150 + class Tolerance<double>
7.151 + {
7.152 + static double def_epsilon;
7.153 + double _epsilon;
7.154 + public:
7.155 + ///\e
7.156 + typedef double Value;
7.157 +
7.158 + ///Constructor setting the epsilon tolerance to the default value.
7.159 + Tolerance() : _epsilon(def_epsilon) {}
7.160 + ///Constructor setting the epsilon tolerance.
7.161 + Tolerance(double e) : _epsilon(e) {}
7.162 +
7.163 + ///Return the epsilon value.
7.164 + Value epsilon() const {return _epsilon;}
7.165 + ///Set the epsilon value.
7.166 + void epsilon(Value e) {_epsilon=e;}
7.167 +
7.168 + ///Return the default epsilon value.
7.169 + static Value defaultEpsilon() {return def_epsilon;}
7.170 + ///Set the default epsilon value.
7.171 + static void defaultEpsilon(Value e) {def_epsilon=e;}
7.172 +
7.173 + ///\name Comparisons
7.174 + ///See class Tolerance for more details.
7.175 +
7.176 + ///@{
7.177 +
7.178 + ///Returns \c true if \c a is \e surely strictly less than \c b
7.179 + bool less(Value a,Value b) const {return a+_epsilon<b;}
7.180 + ///Returns \c true if \c a is \e surely different from \c b
7.181 + bool different(Value a,Value b) const { return less(a,b)||less(b,a); }
7.182 + ///Returns \c true if \c a is \e surely positive
7.183 + bool positive(Value a) const { return _epsilon<a; }
7.184 + ///Returns \c true if \c a is \e surely negative
7.185 + bool negative(Value a) const { return -_epsilon>a; }
7.186 + ///Returns \c true if \c a is \e surely non-zero
7.187 + bool nonZero(Value a) const { return positive(a)||negative(a); };
7.188 +
7.189 + ///@}
7.190 +
7.191 + ///Returns zero
7.192 + static Value zero() {return 0;}
7.193 + };
7.194 +
7.195 + ///Long double specialization of \ref Tolerance.
7.196 +
7.197 + ///Long double specialization of \ref Tolerance.
7.198 + ///\sa Tolerance
7.199 + ///\relates Tolerance
7.200 + template<>
7.201 + class Tolerance<long double>
7.202 + {
7.203 + static long double def_epsilon;
7.204 + long double _epsilon;
7.205 + public:
7.206 + ///\e
7.207 + typedef long double Value;
7.208 +
7.209 + ///Constructor setting the epsilon tolerance to the default value.
7.210 + Tolerance() : _epsilon(def_epsilon) {}
7.211 + ///Constructor setting the epsilon tolerance.
7.212 + Tolerance(long double e) : _epsilon(e) {}
7.213 +
7.214 + ///Return the epsilon value.
7.215 + Value epsilon() const {return _epsilon;}
7.216 + ///Set the epsilon value.
7.217 + void epsilon(Value e) {_epsilon=e;}
7.218 +
7.219 + ///Return the default epsilon value.
7.220 + static Value defaultEpsilon() {return def_epsilon;}
7.221 + ///Set the default epsilon value.
7.222 + static void defaultEpsilon(Value e) {def_epsilon=e;}
7.223 +
7.224 + ///\name Comparisons
7.225 + ///See class Tolerance for more details.
7.226 +
7.227 + ///@{
7.228 +
7.229 + ///Returns \c true if \c a is \e surely strictly less than \c b
7.230 + bool less(Value a,Value b) const {return a+_epsilon<b;}
7.231 + ///Returns \c true if \c a is \e surely different from \c b
7.232 + bool different(Value a,Value b) const { return less(a,b)||less(b,a); }
7.233 + ///Returns \c true if \c a is \e surely positive
7.234 + bool positive(Value a) const { return _epsilon<a; }
7.235 + ///Returns \c true if \c a is \e surely negative
7.236 + bool negative(Value a) const { return -_epsilon>a; }
7.237 + ///Returns \c true if \c a is \e surely non-zero
7.238 + bool nonZero(Value a) const { return positive(a)||negative(a); };
7.239 +
7.240 + ///@}
7.241 +
7.242 + ///Returns zero
7.243 + static Value zero() {return 0;}
7.244 + };
7.245 +
7.246 + ///Integer specialization of \ref Tolerance.
7.247 +
7.248 + ///Integer specialization of \ref Tolerance.
7.249 + ///\sa Tolerance
7.250 + template<>
7.251 + class Tolerance<int>
7.252 + {
7.253 + public:
7.254 + ///\e
7.255 + typedef int Value;
7.256 +
7.257 + ///\name Comparisons
7.258 + ///See \ref Tolerance for more details.
7.259 +
7.260 + ///@{
7.261 +
7.262 + ///Returns \c true if \c a is \e surely strictly less than \c b
7.263 + static bool less(Value a,Value b) { return a<b;}
7.264 + ///Returns \c true if \c a is \e surely different from \c b
7.265 + static bool different(Value a,Value b) { return a!=b; }
7.266 + ///Returns \c true if \c a is \e surely positive
7.267 + static bool positive(Value a) { return 0<a; }
7.268 + ///Returns \c true if \c a is \e surely negative
7.269 + static bool negative(Value a) { return 0>a; }
7.270 + ///Returns \c true if \c a is \e surely non-zero
7.271 + static bool nonZero(Value a) { return a!=0; };
7.272 +
7.273 + ///@}
7.274 +
7.275 + ///Returns zero
7.276 + static Value zero() {return 0;}
7.277 + };
7.278 +
7.279 + ///Unsigned integer specialization of \ref Tolerance.
7.280 +
7.281 + ///Unsigned integer specialization of \ref Tolerance.
7.282 + ///\sa Tolerance
7.283 + template<>
7.284 + class Tolerance<unsigned int>
7.285 + {
7.286 + public:
7.287 + ///\e
7.288 + typedef unsigned int Value;
7.289 +
7.290 + ///\name Comparisons
7.291 + ///See \ref Tolerance for more details.
7.292 +
7.293 + ///@{
7.294 +
7.295 + ///Returns \c true if \c a is \e surely strictly less than \c b
7.296 + static bool less(Value a,Value b) { return a<b;}
7.297 + ///Returns \c true if \c a is \e surely different from \c b
7.298 + static bool different(Value a,Value b) { return a!=b; }
7.299 + ///Returns \c true if \c a is \e surely positive
7.300 + static bool positive(Value a) { return 0<a; }
7.301 + ///Returns \c true if \c a is \e surely negative
7.302 + static bool negative(Value) { return false; }
7.303 + ///Returns \c true if \c a is \e surely non-zero
7.304 + static bool nonZero(Value a) { return a!=0; };
7.305 +
7.306 + ///@}
7.307 +
7.308 + ///Returns zero
7.309 + static Value zero() {return 0;}
7.310 + };
7.311 +
7.312 +#ifndef __STRICT_ANSI__
7.313 +
7.314 + ///Long long integer specialization of \ref Tolerance.
7.315 +
7.316 + ///Long long integer specialization of \ref Tolerance.
7.317 + ///\warning This class (more exactly, type <tt>long long</tt>)
7.318 + ///is not ansi compatible.
7.319 + ///\sa Tolerance
7.320 + template<>
7.321 + class Tolerance<long long int>
7.322 + {
7.323 + public:
7.324 + ///\e
7.325 + typedef long long int Value;
7.326 +
7.327 + ///\name Comparisons
7.328 + ///See \ref Tolerance for more details.
7.329 +
7.330 + ///@{
7.331 +
7.332 + ///Returns \c true if \c a is \e surely strictly less than \c b
7.333 + static bool less(Value a,Value b) { return a<b;}
7.334 + ///Returns \c true if \c a is \e surely different from \c b
7.335 + static bool different(Value a,Value b) { return a!=b; }
7.336 + ///Returns \c true if \c a is \e surely positive
7.337 + static bool positive(Value a) { return 0<a; }
7.338 + ///Returns \c true if \c a is \e surely negative
7.339 + static bool negative(Value a) { return 0>a; }
7.340 + ///Returns \c true if \c a is \e surely non-zero
7.341 + static bool nonZero(Value a) { return a!=0;};
7.342 +
7.343 + ///@}
7.344 +
7.345 + ///Returns zero
7.346 + static Value zero() {return 0;}
7.347 + };
7.348 +
7.349 + ///Unsigned long long integer specialization of \ref Tolerance.
7.350 +
7.351 + ///Unsigned long long integer specialization of \ref Tolerance.
7.352 + ///\warning This class (more exactly, type <tt>unsigned long long</tt>)
7.353 + ///is not ansi compatible.
7.354 + ///\sa Tolerance
7.355 + template<>
7.356 + class Tolerance<unsigned long long int>
7.357 + {
7.358 + public:
7.359 + ///\e
7.360 + typedef unsigned long long int Value;
7.361 +
7.362 + ///\name Comparisons
7.363 + ///See \ref Tolerance for more details.
7.364 +
7.365 + ///@{
7.366 +
7.367 + ///Returns \c true if \c a is \e surely strictly less than \c b
7.368 + static bool less(Value a,Value b) { return a<b;}
7.369 + ///Returns \c true if \c a is \e surely different from \c b
7.370 + static bool different(Value a,Value b) { return a!=b; }
7.371 + ///Returns \c true if \c a is \e surely positive
7.372 + static bool positive(Value a) { return 0<a; }
7.373 + ///Returns \c true if \c a is \e surely negative
7.374 + static bool negative(Value) { return false; }
7.375 + ///Returns \c true if \c a is \e surely non-zero
7.376 + static bool nonZero(Value a) { return a!=0;};
7.377 +
7.378 + ///@}
7.379 +
7.380 + ///Returns zero
7.381 + static Value zero() {return 0;}
7.382 + };
7.383 +
7.384 +#endif
7.385 +
7.386 + /// @}
7.387 +
7.388 +} //namespace lemon
7.389 +
7.390 +#endif //LEMON_TOLERANCE_H