COIN-OR::LEMON - Graph Library

Changeset 1897:dd90f57b01d1 in lemon-0.x for lemon


Ignore:
Timestamp:
01/18/06 10:40:53 (14 years ago)
Author:
Alpar Juttner
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2472
Message:

Tolerance<long double> added

Location:
lemon
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lemon/base.cc

    r1875 r1897  
    2222namespace lemon {
    2323
     24  float Tolerance<float>::def_epsilon = 1e-4;
    2425  double Tolerance<double>::def_epsilon = 1e-10;
    25   float Tolerance<float>::def_epsilon = 1e-4;
     26  long double Tolerance<long double>::def_epsilon = 1e-14;
    2627
    2728#ifndef LEMON_ONLY_TEMPLATES
  • lemon/tolerance.h

    r1875 r1897  
    4545  ///\sa Tolerance<float>
    4646  ///\sa Tolerance<double>
     47  ///\sa Tolerance<long double>
    4748  ///\sa Tolerance<int>
    4849  ///\sa Tolerance<long long int>
     
    8283  };
    8384
     85
     86  ///Float specialization of \ref Tolerance.
     87
     88  ///Float specialization of \ref Tolerance.
     89  ///\sa Tolerance
     90  ///\relates Tolerance
     91  template<>
     92  class Tolerance<float>
     93  {
     94    static float def_epsilon;
     95    float _epsilon;
     96  public:
     97    ///\e
     98    typedef float Value;
     99
     100    ///Constructor setting the epsilon tolerance to the default value.
     101    Tolerance() : _epsilon(def_epsilon) {}
     102    ///Constructor setting the epsilon tolerance.
     103    Tolerance(float e) : _epsilon(e) {}
     104
     105    ///Return the epsilon value.
     106    Value epsilon() {return _epsilon;}
     107    ///Set the epsilon value.
     108    void epsilon(Value e) {_epsilon=e;}
     109
     110    ///Return the default epsilon value.
     111    static Value defaultEpsilon() {return def_epsilon;}
     112    ///Set the default epsilon value.
     113    static void defaultEpsilon(Value e) {def_epsilon=e;}
     114
     115    ///\name Comparisons
     116    ///See class Tolerance for more details.
     117
     118    ///@{
     119
     120    ///Returns \c true if \c a is \e surely strictly less than \c b
     121    bool less(Value a,Value b) {return a+_epsilon<b;}
     122    ///Returns \c true if \c a is \e surely different from \c b
     123    bool different(Value a,Value b) { return less(a,b)||less(b,a); }
     124    ///Returns \c true if \c a is \e surely positive
     125    bool positive(Value a) { return _epsilon<a; }
     126    ///Returns \c true if \c a is \e surely negative
     127    bool negative(Value a) { return -_epsilon>a; }
     128    ///Returns \c true if \c a is \e surely non-zero
     129    Value nonZero(Value a) { return positive(a)||negative(a); };
     130
     131    ///@}
     132
     133    ///Returns zero
     134    static Value zero() {return 0;}
     135  };
    84136
    85137  ///Double specialization of \ref Tolerance.
     
    134186  };
    135187
    136   ///Float specialization of \ref Tolerance.
    137 
    138   ///Float specialization of \ref Tolerance.
     188  ///Long double specialization of \ref Tolerance.
     189
     190  ///Long double specialization of \ref Tolerance.
    139191  ///\sa Tolerance
    140192  ///\relates Tolerance
    141193  template<>
    142   class Tolerance<float>
    143   {
    144     static float def_epsilon;
    145     float _epsilon;
    146   public:
    147     ///\e
    148     typedef float Value;
     194  class Tolerance<long double>
     195  {
     196    static long double def_epsilon;
     197    long double _epsilon;
     198  public:
     199    ///\e
     200    typedef long double Value;
    149201
    150202    ///Constructor setting the epsilon tolerance to the default value.
    151203    Tolerance() : _epsilon(def_epsilon) {}
    152204    ///Constructor setting the epsilon tolerance.
    153     Tolerance(float e) : _epsilon(e) {}
     205    Tolerance(long double e) : _epsilon(e) {}
    154206
    155207    ///Return the epsilon value.
Note: See TracChangeset for help on using the changeset viewer.