lemon/tolerance.h
changeset 2119 4cf25c61ea65
parent 1965 71b3bc042c47
child 2154 bbc79b698f62
equal deleted inserted replaced
5:b21f17953cd2 6:029f601228d8
   103     Tolerance() : _epsilon(def_epsilon) {}
   103     Tolerance() : _epsilon(def_epsilon) {}
   104     ///Constructor setting the epsilon tolerance.
   104     ///Constructor setting the epsilon tolerance.
   105     Tolerance(float e) : _epsilon(e) {}
   105     Tolerance(float e) : _epsilon(e) {}
   106 
   106 
   107     ///Return the epsilon value.
   107     ///Return the epsilon value.
   108     Value epsilon() {return _epsilon;}
   108     Value epsilon() const {return _epsilon;}
   109     ///Set the epsilon value.
   109     ///Set the epsilon value.
   110     void epsilon(Value e) {_epsilon=e;}
   110     void epsilon(Value e) {_epsilon=e;}
   111 
   111 
   112     ///Return the default epsilon value.
   112     ///Return the default epsilon value.
   113     static Value defaultEpsilon() {return def_epsilon;}
   113     static Value defaultEpsilon() {return def_epsilon;}
   118     ///See class Tolerance for more details.
   118     ///See class Tolerance for more details.
   119 
   119 
   120     ///@{
   120     ///@{
   121 
   121 
   122     ///Returns \c true if \c a is \e surely strictly less than \c b
   122     ///Returns \c true if \c a is \e surely strictly less than \c b
   123     bool less(Value a,Value b) {return a+_epsilon<b;}
   123     bool less(Value a,Value b) const {return a+_epsilon<b;}
   124     ///Returns \c true if \c a is \e surely different from \c b
   124     ///Returns \c true if \c a is \e surely different from \c b
   125     bool different(Value a,Value b) { return less(a,b)||less(b,a); }
   125     bool different(Value a,Value b) const { return less(a,b)||less(b,a); }
   126     ///Returns \c true if \c a is \e surely positive
   126     ///Returns \c true if \c a is \e surely positive
   127     bool positive(Value a) { return _epsilon<a; }
   127     bool positive(Value a) const { return _epsilon<a; }
   128     ///Returns \c true if \c a is \e surely negative
   128     ///Returns \c true if \c a is \e surely negative
   129     bool negative(Value a) { return -_epsilon>a; }
   129     bool negative(Value a) const { return -_epsilon>a; }
   130     ///Returns \c true if \c a is \e surely non-zero
   130     ///Returns \c true if \c a is \e surely non-zero
   131     Value nonZero(Value a) { return positive(a)||negative(a); };
   131     bool nonZero(Value a) const { return positive(a)||negative(a); };
   132 
   132 
   133     ///@}
   133     ///@}
   134 
   134 
   135     ///Returns zero
   135     ///Returns zero
   136     static Value zero() {return 0;}
   136     static Value zero() {return 0;}
   154     Tolerance() : _epsilon(def_epsilon) {}
   154     Tolerance() : _epsilon(def_epsilon) {}
   155     ///Constructor setting the epsilon tolerance.
   155     ///Constructor setting the epsilon tolerance.
   156     Tolerance(double e) : _epsilon(e) {}
   156     Tolerance(double e) : _epsilon(e) {}
   157 
   157 
   158     ///Return the epsilon value.
   158     ///Return the epsilon value.
   159     Value epsilon() {return _epsilon;}
   159     Value epsilon() const {return _epsilon;}
   160     ///Set the epsilon value.
   160     ///Set the epsilon value.
   161     void epsilon(Value e) {_epsilon=e;}
   161     void epsilon(Value e) {_epsilon=e;}
   162 
   162 
   163     ///Return the default epsilon value.
   163     ///Return the default epsilon value.
   164     static Value defaultEpsilon() {return def_epsilon;}
   164     static Value defaultEpsilon() {return def_epsilon;}
   169     ///See class Tolerance for more details.
   169     ///See class Tolerance for more details.
   170 
   170 
   171     ///@{
   171     ///@{
   172 
   172 
   173     ///Returns \c true if \c a is \e surely strictly less than \c b
   173     ///Returns \c true if \c a is \e surely strictly less than \c b
   174     bool less(Value a,Value b) {return a+_epsilon<b;}
   174     bool less(Value a,Value b) const {return a+_epsilon<b;}
   175     ///Returns \c true if \c a is \e surely different from \c b
   175     ///Returns \c true if \c a is \e surely different from \c b
   176     bool different(Value a,Value b) { return less(a,b)||less(b,a); }
   176     bool different(Value a,Value b) const { return less(a,b)||less(b,a); }
   177     ///Returns \c true if \c a is \e surely positive
   177     ///Returns \c true if \c a is \e surely positive
   178     bool positive(Value a) { return _epsilon<a; }
   178     bool positive(Value a) const { return _epsilon<a; }
   179     ///Returns \c true if \c a is \e surely negative
   179     ///Returns \c true if \c a is \e surely negative
   180     bool negative(Value a) { return -_epsilon>a; }
   180     bool negative(Value a) const { return -_epsilon>a; }
   181     ///Returns \c true if \c a is \e surely non-zero
   181     ///Returns \c true if \c a is \e surely non-zero
   182     Value nonZero(Value a) { return positive(a)||negative(a); };
   182     bool nonZero(Value a) const { return positive(a)||negative(a); };
   183 
   183 
   184     ///@}
   184     ///@}
   185 
   185 
   186     ///Returns zero
   186     ///Returns zero
   187     static Value zero() {return 0;}
   187     static Value zero() {return 0;}
   205     Tolerance() : _epsilon(def_epsilon) {}
   205     Tolerance() : _epsilon(def_epsilon) {}
   206     ///Constructor setting the epsilon tolerance.
   206     ///Constructor setting the epsilon tolerance.
   207     Tolerance(long double e) : _epsilon(e) {}
   207     Tolerance(long double e) : _epsilon(e) {}
   208 
   208 
   209     ///Return the epsilon value.
   209     ///Return the epsilon value.
   210     Value epsilon() {return _epsilon;}
   210     Value epsilon() const {return _epsilon;}
   211     ///Set the epsilon value.
   211     ///Set the epsilon value.
   212     void epsilon(Value e) {_epsilon=e;}
   212     void epsilon(Value e) {_epsilon=e;}
   213 
   213 
   214     ///Return the default epsilon value.
   214     ///Return the default epsilon value.
   215     static Value defaultEpsilon() {return def_epsilon;}
   215     static Value defaultEpsilon() {return def_epsilon;}
   220     ///See class Tolerance for more details.
   220     ///See class Tolerance for more details.
   221 
   221 
   222     ///@{
   222     ///@{
   223 
   223 
   224     ///Returns \c true if \c a is \e surely strictly less than \c b
   224     ///Returns \c true if \c a is \e surely strictly less than \c b
   225     bool less(Value a,Value b) {return a+_epsilon<b;}
   225     bool less(Value a,Value b) const {return a+_epsilon<b;}
   226     ///Returns \c true if \c a is \e surely different from \c b
   226     ///Returns \c true if \c a is \e surely different from \c b
   227     bool different(Value a,Value b) { return less(a,b)||less(b,a); }
   227     bool different(Value a,Value b) const { return less(a,b)||less(b,a); }
   228     ///Returns \c true if \c a is \e surely positive
   228     ///Returns \c true if \c a is \e surely positive
   229     bool positive(Value a) { return _epsilon<a; }
   229     bool positive(Value a) const { return _epsilon<a; }
   230     ///Returns \c true if \c a is \e surely negative
   230     ///Returns \c true if \c a is \e surely negative
   231     bool negative(Value a) { return -_epsilon>a; }
   231     bool negative(Value a) const { return -_epsilon>a; }
   232     ///Returns \c true if \c a is \e surely non-zero
   232     ///Returns \c true if \c a is \e surely non-zero
   233     Value nonZero(Value a) { return positive(a)||negative(a); };
   233     bool nonZero(Value a) const { return positive(a)||negative(a); };
   234 
   234 
   235     ///@}
   235     ///@}
   236 
   236 
   237     ///Returns zero
   237     ///Returns zero
   238     static Value zero() {return 0;}
   238     static Value zero() {return 0;}
   261     ///Returns \c true if \c a is \e surely positive
   261     ///Returns \c true if \c a is \e surely positive
   262     static bool positive(Value a) { return 0<a; }
   262     static bool positive(Value a) { return 0<a; }
   263     ///Returns \c true if \c a is \e surely negative
   263     ///Returns \c true if \c a is \e surely negative
   264     static bool negative(Value a) { return 0>a; }
   264     static bool negative(Value a) { return 0>a; }
   265     ///Returns \c true if \c a is \e surely non-zero
   265     ///Returns \c true if \c a is \e surely non-zero
   266     static Value nonZero(Value a) { return a!=0;};
   266     static bool nonZero(Value a) { return a!=0; };
   267 
   267 
   268     ///@}
   268     ///@}
   269 
   269 
   270     ///Returns zero
   270     ///Returns zero
   271     static Value zero() {return 0;}
   271     static Value zero() {return 0;}
   297     ///Returns \c true if \c a is \e surely positive
   297     ///Returns \c true if \c a is \e surely positive
   298     static bool positive(Value a) { return 0<a; }
   298     static bool positive(Value a) { return 0<a; }
   299     ///Returns \c true if \c a is \e surely negative
   299     ///Returns \c true if \c a is \e surely negative
   300     static bool negative(Value a) { return 0>a; }
   300     static bool negative(Value a) { return 0>a; }
   301     ///Returns \c true if \c a is \e surely non-zero
   301     ///Returns \c true if \c a is \e surely non-zero
   302     static Value nonZero(Value a) { return a!=0;};
   302     static bool nonZero(Value a) { return a!=0;};
   303 
   303 
   304     ///@}
   304     ///@}
   305 
   305 
   306     ///Returns zero
   306     ///Returns zero
   307     static Value zero() {return 0;}
   307     static Value zero() {return 0;}