Changeset 1897:dd90f57b01d1 in lemon0.x for lemon/tolerance.h
 Timestamp:
 01/18/06 10:40:53 (16 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@2472
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

lemon/tolerance.h
r1875 r1897 45 45 ///\sa Tolerance<float> 46 46 ///\sa Tolerance<double> 47 ///\sa Tolerance<long double> 47 48 ///\sa Tolerance<int> 48 49 ///\sa Tolerance<long long int> … … 82 83 }; 83 84 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 nonzero 129 Value nonZero(Value a) { return positive(a)negative(a); }; 130 131 ///@} 132 133 ///Returns zero 134 static Value zero() {return 0;} 135 }; 84 136 85 137 ///Double specialization of \ref Tolerance. … … 134 186 }; 135 187 136 /// Floatspecialization of \ref Tolerance.137 138 /// Floatspecialization of \ref Tolerance.188 ///Long double specialization of \ref Tolerance. 189 190 ///Long double specialization of \ref Tolerance. 139 191 ///\sa Tolerance 140 192 ///\relates Tolerance 141 193 template<> 142 class Tolerance< float>143 { 144 static floatdef_epsilon;145 float_epsilon;146 public: 147 ///\e 148 typedef floatValue;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; 149 201 150 202 ///Constructor setting the epsilon tolerance to the default value. 151 203 Tolerance() : _epsilon(def_epsilon) {} 152 204 ///Constructor setting the epsilon tolerance. 153 Tolerance( floate) : _epsilon(e) {}205 Tolerance(long double e) : _epsilon(e) {} 154 206 155 207 ///Return the epsilon value.
Note: See TracChangeset
for help on using the changeset viewer.