|
Gaudi Framework, version v23r2 |
| Home | Generated: Thu Jun 28 2012 |
00001 // $Id: Lomont.h,v 1.2 2009/07/06 08:57:16 cattanem Exp $ 00002 // ============================================================================ 00003 #ifndef GAUDIKERNEL_LOMONT_H 00004 #define GAUDIKERNEL_LOMONT_H 1 00005 // ============================================================================ 00006 // Include file 00007 // ============================================================================ 00008 // STD & STL 00009 // ============================================================================ 00010 #include <functional> 00011 // ============================================================================ 00012 // GaudiKernel 00013 // ============================================================================ 00014 #include "GaudiKernel/Kernel.h" 00015 // ============================================================================ 00016 namespace Gaudi 00017 { 00018 // ========================================================================== 00019 namespace Math 00020 { 00021 // ======================================================================== 00040 template <class TYPE> class Lomont ; 00041 // ======================================================================== 00089 GAUDI_API 00090 bool lomont_compare_float 00091 ( const float af , 00092 const float bf , 00093 const unsigned short maxULPs ) ; 00094 // ======================================================================== 00130 GAUDI_API 00131 bool lomont_compare_double 00132 ( const double af , 00133 const double bf , 00134 const unsigned int maxULPs ) ; 00135 // ======================================================================== 00155 template <> 00156 class Lomont<float> : public std::binary_function<float,float,bool> 00157 { 00158 // ====================================================================== 00159 public: 00160 // ====================================================================== 00162 Lomont ( const unsigned short ulps ) : m_ulps ( ulps ) {} 00163 // ====================================================================== 00164 public: 00165 // ====================================================================== 00167 inline bool operator () ( const float a , const float b ) const 00168 { return lomont_compare_float ( a , b , m_ulps ) ; } 00169 // ====================================================================== 00170 private: 00171 // ====================================================================== 00173 Lomont() ; // the default constructor is disabled 00174 // ====================================================================== 00175 private: 00176 // ====================================================================== 00178 unsigned short m_ulps ; // the precision in "units in last place" 00179 // ====================================================================== 00180 }; 00181 // ======================================================================== 00201 template <> 00202 class Lomont<double> : public std::binary_function<double,double,bool> 00203 { 00204 // ====================================================================== 00205 public: 00206 // ====================================================================== 00208 Lomont ( const unsigned int ulps ) : m_ulps ( ulps ) {} 00209 // ====================================================================== 00210 public: 00211 // ====================================================================== 00213 inline bool operator () ( const double a , const double b ) const 00214 { return lomont_compare_double ( a , b , m_ulps ) ; } 00215 // ====================================================================== 00216 private: 00217 // ====================================================================== 00219 Lomont () ; // the default constructor is disabled 00220 // ====================================================================== 00221 private: 00222 // ====================================================================== 00224 unsigned int m_ulps ; // the precision in "units in last place" 00225 // ====================================================================== 00226 }; 00227 // ======================================================================== 00244 GAUDI_API 00245 float next_float ( const float af , const short ulps ) ; 00246 // ======================================================================== 00263 GAUDI_API 00264 double next_double ( const double af , const short ulps ) ; 00265 // ======================================================================== 00266 } // end of namespace Gaudi::Math 00267 // ========================================================================== 00268 } // end of namespace Gaudi 00269 // ============================================================================ 00270 // The END 00271 // ============================================================================ 00272 #endif // GAUDIKERNEL_LOMONT_H 00273 // ============================================================================