Lomont.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_LOMONT_H
2 #define GAUDIKERNEL_LOMONT_H 1
3 // ============================================================================
4 // Include file
5 // ============================================================================
6 // STD & STL
7 // ============================================================================
8 #include <functional>
9 // ============================================================================
10 // GaudiKernel
11 // ============================================================================
12 #include "GaudiKernel/Kernel.h"
13 // ============================================================================
14 namespace Gaudi
15 {
16  // ==========================================================================
17  namespace Math
18  {
19  // ========================================================================
38  template <class TYPE> class Lomont ;
39  // ========================================================================
87  GAUDI_API
89  ( const float af ,
90  const float bf ,
91  const unsigned short maxULPs ) ;
92  // ========================================================================
128  GAUDI_API
130  ( const double af ,
131  const double bf ,
132  const unsigned int maxULPs ) ;
133  // ========================================================================
153  template <>
154  class Lomont<float> : public std::binary_function<float,float,bool>
155  {
156  // ======================================================================
157  public:
158  // ======================================================================
160  Lomont ( const unsigned short ulps ) : m_ulps ( ulps ) {}
161  // ======================================================================
162  public:
163  // ======================================================================
165  inline bool operator () ( const float a , const float b ) const
166  { return lomont_compare_float ( a , b , m_ulps ) ; }
167  // ======================================================================
168  private:
169  // ======================================================================
171  Lomont() ; // the default constructor is disabled
172  // ======================================================================
173  private:
174  // ======================================================================
176  unsigned short m_ulps ; // the precision in "units in last place"
177  // ======================================================================
178  };
179  // ========================================================================
199  template <>
200  class Lomont<double> : public std::binary_function<double,double,bool>
201  {
202  // ======================================================================
203  public:
204  // ======================================================================
206  Lomont ( const unsigned int ulps ) : m_ulps ( ulps ) {}
207  // ======================================================================
208  public:
209  // ======================================================================
211  inline bool operator () ( const double a , const double b ) const
212  { return lomont_compare_double ( a , b , m_ulps ) ; }
213  // ======================================================================
214  private:
215  // ======================================================================
217  Lomont () ; // the default constructor is disabled
218  // ======================================================================
219  private:
220  // ======================================================================
222  unsigned int m_ulps ; // the precision in "units in last place"
223  // ======================================================================
224  };
225  // ========================================================================
242  GAUDI_API
243  float next_float ( const float af , const short ulps ) ;
244  // ========================================================================
261  GAUDI_API
262  double next_double ( const double af , const short ulps ) ;
263  // ========================================================================
264  } // end of namespace Gaudi::Math
265  // ==========================================================================
266 } // end of namespace Gaudi
267 // ============================================================================
268 // The END
269 // ============================================================================
270 #endif // GAUDIKERNEL_LOMONT_H
271 // ============================================================================
unsigned short m_ulps
the precision in "units in last place"
Definition: Lomont.h:176
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:193
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:245
Lomont(const unsigned int ulps)
constructor from ULPS:
Definition: Lomont.h:206
unsigned int m_ulps
the precision in "units in last place"
Definition: Lomont.h:222
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:289
virtual Out operator()(const vector_of_const_< In > &inputs) const =0
The equality comparison of double numbers using as the metric the maximal number of Units in the Last...
Definition: Lomont.h:38
#define GAUDI_API
Definition: Kernel.h:107
Helper functions to set/get the application return code.
Definition: __init__.py:1
Lomont(const unsigned short ulps)
constructor from ULPS:
Definition: Lomont.h:160
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:342