All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Lomont.h
Go to the documentation of this file.
1 // $Id: Lomont.h,v 1.2 2009/07/06 08:57:16 cattanem Exp $
2 // ============================================================================
3 #ifndef GAUDIKERNEL_LOMONT_H
4 #define GAUDIKERNEL_LOMONT_H 1
5 // ============================================================================
6 // Include file
7 // ============================================================================
8 // STD & STL
9 // ============================================================================
10 #include <functional>
11 // ============================================================================
12 // GaudiKernel
13 // ============================================================================
14 #include "GaudiKernel/Kernel.h"
15 // ============================================================================
16 namespace Gaudi
17 {
18  // ==========================================================================
19  namespace Math
20  {
21  // ========================================================================
40  template <class TYPE> class Lomont ;
41  // ========================================================================
89  GAUDI_API
91  ( const float af ,
92  const float bf ,
93  const unsigned short maxULPs ) ;
94  // ========================================================================
130  GAUDI_API
132  ( const double af ,
133  const double bf ,
134  const unsigned int maxULPs ) ;
135  // ========================================================================
155  template <>
156  class Lomont<float> : public std::binary_function<float,float,bool>
157  {
158  // ======================================================================
159  public:
160  // ======================================================================
162  Lomont ( const unsigned short ulps ) : m_ulps ( ulps ) {}
163  // ======================================================================
164  public:
165  // ======================================================================
167  inline bool operator () ( const float a , const float b ) const
168  { return lomont_compare_float ( a , b , m_ulps ) ; }
169  // ======================================================================
170  private:
171  // ======================================================================
173  Lomont() ; // the default constructor is disabled
174  // ======================================================================
175  private:
176  // ======================================================================
178  unsigned short m_ulps ; // the precision in "units in last place"
179  // ======================================================================
180  };
181  // ========================================================================
201  template <>
202  class Lomont<double> : public std::binary_function<double,double,bool>
203  {
204  // ======================================================================
205  public:
206  // ======================================================================
208  Lomont ( const unsigned int ulps ) : m_ulps ( ulps ) {}
209  // ======================================================================
210  public:
211  // ======================================================================
213  inline bool operator () ( const double a , const double b ) const
214  { return lomont_compare_double ( a , b , m_ulps ) ; }
215  // ======================================================================
216  private:
217  // ======================================================================
219  Lomont () ; // the default constructor is disabled
220  // ======================================================================
221  private:
222  // ======================================================================
224  unsigned int m_ulps ; // the precision in "units in last place"
225  // ======================================================================
226  };
227  // ========================================================================
244  GAUDI_API
245  float next_float ( const float af , const short ulps ) ;
246  // ========================================================================
263  GAUDI_API
264  double next_double ( const double af , const short ulps ) ;
265  // ========================================================================
266  } // end of namespace Gaudi::Math
267  // ==========================================================================
268 } // end of namespace Gaudi
269 // ============================================================================
270 // The END
271 // ============================================================================
272 #endif // GAUDIKERNEL_LOMONT_H
273 // ============================================================================
unsigned short m_ulps
the precision in "units in last place"
Definition: Lomont.h:178
GAUDI_API bool lomont_compare_float(const float af, const float bf, const unsigned short maxULPs)
equality comparison of float numbers using as the metric the maximal number of Units in the Last Plac...
Definition: Lomont.cpp:195
GAUDI_API float next_float(const float af, const short ulps)
Get the floating number that representation is different with respect to the argument for the certain...
Definition: Lomont.cpp:247
Lomont(const unsigned int ulps)
constructor from ULPS:
Definition: Lomont.h:208
unsigned int m_ulps
the precision in "units in last place"
Definition: Lomont.h:224
GAUDI_API bool lomont_compare_double(const double af, const double bf, const unsigned int maxULPs)
equality comparison of double numbers using as the metric the maximal number of Units in the Last Pla...
Definition: Lomont.cpp:291
The equality comparison of double numbers using as the metric the maximal number of Units in the Last...
Definition: Lomont.h:40
This is a number of static methods for bootstrapping the Gaudi framework.
Definition: Bootstrap.h:15
#define GAUDI_API
Definition: Kernel.h:108
Lomont(const unsigned short ulps)
constructor from ULPS:
Definition: Lomont.h:162
GAUDI_API double next_double(const double af, const short ulps)
Get the floating number that representation is different with respect to the argument for the certain...
Definition: Lomont.cpp:344