Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
MnMachinePrecision.h
Go to the documentation of this file.
1 // @(#)root/minuit2:$Id$
2 // Authors: M. Winkler, F. James, L. Moneta, A. Zsenei 2003-2005
3 
4 /**********************************************************************
5  * *
6  * Copyright (c) 2005 LCG ROOT Math team, CERN/PH-SFT *
7  * *
8  **********************************************************************/
9 
10 #ifndef ROOT_Minuit2_MnMachinePrecision
11 #define ROOT_Minuit2_MnMachinePrecision
12 
13 #include <math.h>
14 
15 namespace ROOT {
16 
17  namespace Minuit2 {
18 
19 
20 /**
21  determines the relative floating point arithmetic precision. The
22  SetPrecision() method can be used to override Minuit's own determination,
23  when the user knows that the {FCN} function Value is not calculated to
24  the nominal machine accuracy.
25  */
26 
27 class MnMachinePrecision {
28 
29 public:
30 
31  MnMachinePrecision();
32 
33  ~MnMachinePrecision() {}
34 
35  MnMachinePrecision(const MnMachinePrecision& prec) : fEpsMac(prec.fEpsMac), fEpsMa2(prec.fEpsMa2) {}
36 
37  MnMachinePrecision& operator=(const MnMachinePrecision& prec) {
38  fEpsMac = prec.fEpsMac;
39  fEpsMa2 = prec.fEpsMa2;
40  return *this;
41  }
42 
43  /// eps returns the smallest possible number so that 1.+eps > 1.
44  double Eps() const {return fEpsMac;}
45 
46  /// eps2 returns 2*sqrt(eps)
47  double Eps2() const {return fEpsMa2;}
48 
49  /// override Minuit's own determination
50  void SetPrecision(double prec) {
51  fEpsMac = prec;
52  fEpsMa2 = 2.*sqrt(fEpsMac);
53  }
54 
55 private:
56 
57  double fEpsMac;
58  double fEpsMa2;
59 };
60 
61  } // namespace Minuit2
62 
63 } // namespace ROOT
64 
65 #endif // ROOT_Minuit2_MnMachinePrecision