diff -r c35afa9e89e7 -r ef88c0a30f85 lemon/tolerance.h --- a/lemon/tolerance.h Mon Jan 12 23:11:39 2009 +0100 +++ b/lemon/tolerance.h Thu Nov 05 15:48:01 2009 +0100 @@ -38,17 +38,14 @@ ///handle the comparison of numbers that are obtained ///as a result of a probably inexact computation. /// - ///This is an abstract class, it should be specialized for all - ///numerical data types. These specialized classes like + ///The general implementation is suitable only if the data type is exact, + ///like the integer types, otherwise a specialized version must be + ///implemented. These specialized classes like ///Tolerance may offer additional tuning parameters. /// ///\sa Tolerance ///\sa Tolerance ///\sa Tolerance - ///\sa Tolerance - ///\sa Tolerance - ///\sa Tolerance - ///\sa Tolerance template class Tolerance @@ -64,20 +61,20 @@ ///@{ ///Returns \c true if \c a is \e surely strictly less than \c b - static bool less(Value a,Value b) {return false;} + static bool less(Value a,Value b) {return a(0) < a;} ///Returns \c true if \c a is \e surely negative - static bool negative(Value a) {return false;} + static bool negative(Value a) {return a < static_cast(0);} ///Returns \c true if \c a is \e surely non-zero - static bool nonZero(Value a) {return false;} + static bool nonZero(Value a) {return a != static_cast(0);} ///@} ///Returns the zero value. - static Value zero() {return T();} + static Value zero() {return static_cast(0);} // static bool finite(Value a) {} // static Value big() {} @@ -238,213 +235,6 @@ static Value zero() {return 0;} }; - ///Integer specialization of Tolerance. - - ///Integer specialization of Tolerance. - ///\sa Tolerance - template<> - class Tolerance - { - public: - ///\e - typedef int Value; - - ///\name Comparisons - ///See \ref lemon::Tolerance "Tolerance" for more details. - - ///@{ - - ///Returns \c true if \c a is \e surely strictly less than \c b - static bool less(Value a,Value b) { return aa; } - ///Returns \c true if \c a is \e surely non-zero - static bool nonZero(Value a) { return a!=0; } - - ///@} - - ///Returns zero - static Value zero() {return 0;} - }; - - ///Unsigned integer specialization of Tolerance. - - ///Unsigned integer specialization of Tolerance. - ///\sa Tolerance - template<> - class Tolerance - { - public: - ///\e - typedef unsigned int Value; - - ///\name Comparisons - ///See \ref lemon::Tolerance "Tolerance" for more details. - - ///@{ - - ///Returns \c true if \c a is \e surely strictly less than \c b - static bool less(Value a,Value b) { return a - class Tolerance - { - public: - ///\e - typedef long int Value; - - ///\name Comparisons - ///See \ref lemon::Tolerance "Tolerance" for more details. - - ///@{ - - ///Returns \c true if \c a is \e surely strictly less than \c b - static bool less(Value a,Value b) { return aa; } - ///Returns \c true if \c a is \e surely non-zero - static bool nonZero(Value a) { return a!=0;} - - ///@} - - ///Returns zero - static Value zero() {return 0;} - }; - - ///Unsigned long integer specialization of Tolerance. - - ///Unsigned long integer specialization of Tolerance. - ///\sa Tolerance - template<> - class Tolerance - { - public: - ///\e - typedef unsigned long int Value; - - ///\name Comparisons - ///See \ref lemon::Tolerance "Tolerance" for more details. - - ///@{ - - ///Returns \c true if \c a is \e surely strictly less than \c b - static bool less(Value a,Value b) { return along long) - ///is not ansi compatible. - ///\sa Tolerance - template<> - class Tolerance - { - public: - ///\e - typedef long long int Value; - - ///\name Comparisons - ///See \ref lemon::Tolerance "Tolerance" for more details. - - ///@{ - - ///Returns \c true if \c a is \e surely strictly less than \c b - static bool less(Value a,Value b) { return aa; } - ///Returns \c true if \c a is \e surely non-zero - static bool nonZero(Value a) { return a!=0;} - - ///@} - - ///Returns zero - static Value zero() {return 0;} - }; - - ///Unsigned long long integer specialization of Tolerance. - - ///Unsigned long long integer specialization of Tolerance. - ///\warning This class (more exactly, type unsigned long long) - ///is not ansi compatible. - ///\sa Tolerance - template<> - class Tolerance - { - public: - ///\e - typedef unsigned long long int Value; - - ///\name Comparisons - ///See \ref lemon::Tolerance "Tolerance" for more details. - - ///@{ - - ///Returns \c true if \c a is \e surely strictly less than \c b - static bool less(Value a,Value b) { return a