lemon/tolerance.h
changeset 42 3a98515e9bc3
parent 39 0a01d811071f
child 49 9a556af88710
equal deleted inserted replaced
2:0f96db393aaa 3:150880e30176
    39   ///Tolerance is a class to provide a basic way to
    39   ///Tolerance is a class to provide a basic way to
    40   ///handle the comparison of numbers that are obtained
    40   ///handle the comparison of numbers that are obtained
    41   ///as a result of a probably inexact computation.
    41   ///as a result of a probably inexact computation.
    42   ///
    42   ///
    43   ///This is an abstract class, it should be specialized for all numerical
    43   ///This is an abstract class, it should be specialized for all numerical
    44   ///data types. These specialized classes like \ref Tolerance\<double\>
    44   ///data types. These specialized classes like Tolerance<double>
    45   ///may offer additional tuning parameters.
    45   ///may offer additional tuning parameters.
    46   ///
    46   ///
    47   ///\sa Tolerance<float>
    47   ///\sa Tolerance<float>
    48   ///\sa Tolerance<double>
    48   ///\sa Tolerance<double>
    49   ///\sa Tolerance<long double>
    49   ///\sa Tolerance<long double>
    89     //   static Value big() {}
    89     //   static Value big() {}
    90     //   static Value negativeBig() {}
    90     //   static Value negativeBig() {}
    91   };
    91   };
    92 
    92 
    93 
    93 
    94   ///Float specialization of \ref Tolerance.
    94   ///Float specialization of Tolerance.
    95 
    95 
    96   ///Float specialization of \ref Tolerance.
    96   ///Float specialization of Tolerance.
    97   ///\sa Tolerance
    97   ///\sa Tolerance
    98   ///\relates Tolerance
    98   ///\relates Tolerance
    99   template<>
    99   template<>
   100   class Tolerance<float>
   100   class Tolerance<float>
   101   {
   101   {
   140 
   140 
   141     ///Returns zero
   141     ///Returns zero
   142     static Value zero() {return 0;}
   142     static Value zero() {return 0;}
   143   };
   143   };
   144 
   144 
   145   ///Double specialization of \ref Tolerance.
   145   ///Double specialization of Tolerance.
   146 
   146 
   147   ///Double specialization of \ref Tolerance.
   147   ///Double specialization of Tolerance.
   148   ///\sa Tolerance
   148   ///\sa Tolerance
   149   ///\relates Tolerance
   149   ///\relates Tolerance
   150   template<>
   150   template<>
   151   class Tolerance<double>
   151   class Tolerance<double>
   152   {
   152   {
   191 
   191 
   192     ///Returns zero
   192     ///Returns zero
   193     static Value zero() {return 0;}
   193     static Value zero() {return 0;}
   194   };
   194   };
   195 
   195 
   196   ///Long double specialization of \ref Tolerance.
   196   ///Long double specialization of Tolerance.
   197 
   197 
   198   ///Long double specialization of \ref Tolerance.
   198   ///Long double specialization of Tolerance.
   199   ///\sa Tolerance
   199   ///\sa Tolerance
   200   ///\relates Tolerance
   200   ///\relates Tolerance
   201   template<>
   201   template<>
   202   class Tolerance<long double>
   202   class Tolerance<long double>
   203   {
   203   {
   242 
   242 
   243     ///Returns zero
   243     ///Returns zero
   244     static Value zero() {return 0;}
   244     static Value zero() {return 0;}
   245   };
   245   };
   246 
   246 
   247   ///Integer specialization of \ref Tolerance.
   247   ///Integer specialization of Tolerance.
   248 
   248 
   249   ///Integer specialization of \ref Tolerance.
   249   ///Integer specialization of Tolerance.
   250   ///\sa Tolerance
   250   ///\sa Tolerance
   251   template<>
   251   template<>
   252   class Tolerance<int>
   252   class Tolerance<int>
   253   {
   253   {
   254   public:
   254   public:
   255     ///\e
   255     ///\e
   256     typedef int Value;
   256     typedef int Value;
   257 
   257 
   258     ///\name Comparisons
   258     ///\name Comparisons
   259     ///See \ref Tolerance for more details.
   259     ///See Tolerance for more details.
   260 
   260 
   261     ///@{
   261     ///@{
   262 
   262 
   263     ///Returns \c true if \c a is \e surely strictly less than \c b
   263     ///Returns \c true if \c a is \e surely strictly less than \c b
   264     static bool less(Value a,Value b) { return a<b;}
   264     static bool less(Value a,Value b) { return a<b;}
   275 
   275 
   276     ///Returns zero
   276     ///Returns zero
   277     static Value zero() {return 0;}
   277     static Value zero() {return 0;}
   278   };
   278   };
   279 
   279 
       
   280   ///Unsigned integer specialization of Tolerance.
       
   281 
   280   ///Unsigned integer specialization of \ref Tolerance.
   282   ///Unsigned integer specialization of \ref Tolerance.
   281 
       
   282   ///Unsigned integer specialization of \ref Tolerance.
       
   283   ///\sa Tolerance
   283   ///\sa Tolerance
   284   template<>
   284   template<>
   285   class Tolerance<unsigned int>
   285   class Tolerance<unsigned int>
   286   {
   286   {
   287   public:
   287   public:
   288     ///\e
   288     ///\e
   289     typedef unsigned int Value;
   289     typedef unsigned int Value;
   290 
   290 
   291     ///\name Comparisons
   291     ///\name Comparisons
   292     ///See \ref Tolerance for more details.
   292     ///See Tolerance for more details.
   293 
   293 
   294     ///@{
   294     ///@{
   295 
   295 
   296     ///Returns \c true if \c a is \e surely strictly less than \c b
   296     ///Returns \c true if \c a is \e surely strictly less than \c b
   297     static bool less(Value a,Value b) { return a<b;}
   297     static bool less(Value a,Value b) { return a<b;}
   309     ///Returns zero
   309     ///Returns zero
   310     static Value zero() {return 0;}
   310     static Value zero() {return 0;}
   311   };
   311   };
   312   
   312   
   313 
   313 
   314   ///Long integer specialization of \ref Tolerance.
   314   ///Long integer specialization of Tolerance.
   315 
   315 
   316   ///Long integer specialization of \ref Tolerance.
   316   ///Long integer specialization of Tolerance.
   317   ///\sa Tolerance
   317   ///\sa Tolerance
   318   template<>
   318   template<>
   319   class Tolerance<long int>
   319   class Tolerance<long int>
   320   {
   320   {
   321   public:
   321   public:
   322     ///\e
   322     ///\e
   323     typedef long int Value;
   323     typedef long int Value;
   324 
   324 
   325     ///\name Comparisons
   325     ///\name Comparisons
   326     ///See \ref Tolerance for more details.
   326     ///See Tolerance for more details.
   327 
   327 
   328     ///@{
   328     ///@{
   329 
   329 
   330     ///Returns \c true if \c a is \e surely strictly less than \c b
   330     ///Returns \c true if \c a is \e surely strictly less than \c b
   331     static bool less(Value a,Value b) { return a<b;}
   331     static bool less(Value a,Value b) { return a<b;}
   342 
   342 
   343     ///Returns zero
   343     ///Returns zero
   344     static Value zero() {return 0;}
   344     static Value zero() {return 0;}
   345   };
   345   };
   346 
   346 
       
   347   ///Unsigned long integer specialization of Tolerance.
       
   348 
   347   ///Unsigned long integer specialization of \ref Tolerance.
   349   ///Unsigned long integer specialization of \ref Tolerance.
   348 
       
   349   ///Unsigned long integer specialization of \ref Tolerance.
       
   350   ///\sa Tolerance
   350   ///\sa Tolerance
   351   template<>
   351   template<>
   352   class Tolerance<unsigned long int>
   352   class Tolerance<unsigned long int>
   353   {
   353   {
   354   public:
   354   public:
   355     ///\e
   355     ///\e
   356     typedef unsigned long int Value;
   356     typedef unsigned long int Value;
   357 
   357 
   358     ///\name Comparisons
   358     ///\name Comparisons
   359     ///See \ref Tolerance for more details.
   359     ///See Tolerance for more details.
   360 
   360 
   361     ///@{
   361     ///@{
   362 
   362 
   363     ///Returns \c true if \c a is \e surely strictly less than \c b
   363     ///Returns \c true if \c a is \e surely strictly less than \c b
   364     static bool less(Value a,Value b) { return a<b;}
   364     static bool less(Value a,Value b) { return a<b;}
   377     static Value zero() {return 0;}
   377     static Value zero() {return 0;}
   378   };
   378   };
   379 
   379 
   380 #if defined __GNUC__ && !defined __STRICT_ANSI__
   380 #if defined __GNUC__ && !defined __STRICT_ANSI__
   381 
   381 
   382   ///Long long integer specialization of \ref Tolerance.
   382   ///Long long integer specialization of Tolerance.
   383 
   383 
   384   ///Long long integer specialization of \ref Tolerance.
   384   ///Long long integer specialization of \ref Tolerance.
   385   ///\warning This class (more exactly, type <tt>long long</tt>)
   385   ///\warning This class (more exactly, type <tt>long long</tt>)
   386   ///is not ansi compatible.
   386   ///is not ansi compatible.
   387   ///\sa Tolerance
   387   ///\sa Tolerance
   412 
   412 
   413     ///Returns zero
   413     ///Returns zero
   414     static Value zero() {return 0;}
   414     static Value zero() {return 0;}
   415   };
   415   };
   416 
   416 
   417   ///Unsigned long long integer specialization of \ref Tolerance.
   417   ///Unsigned long long integer specialization of Tolerance.
   418 
   418 
   419   ///Unsigned long long integer specialization of \ref Tolerance.
   419   ///Unsigned long long integer specialization of \ref Tolerance.
   420   ///\warning This class (more exactly, type <tt>unsigned long long</tt>)
   420   ///\warning This class (more exactly, type <tt>unsigned long long</tt>)
   421   ///is not ansi compatible.
   421   ///is not ansi compatible.
   422   ///\sa Tolerance
   422   ///\sa Tolerance