Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:10:24

0001 // @(#)root/minuit2:$Id$
0002 // Authors: M. Winkler, F. James, L. Moneta, A. Zsenei   2003-2005
0003 
0004 /**********************************************************************
0005  *                                                                    *
0006  * Copyright (c) 2005 LCG ROOT Math team,  CERN/PH-SFT                *
0007  *                                                                    *
0008  **********************************************************************/
0009 
0010 #ifndef ROOT_Minuit2_MnMachinePrecision
0011 #define ROOT_Minuit2_MnMachinePrecision
0012 
0013 #include <cmath>
0014 
0015 namespace ROOT {
0016 
0017 namespace Minuit2 {
0018 
0019 /**
0020     Sets the relative floating point (double) arithmetic precision.
0021     By default the precision values are obtained from the standard functions
0022     std::numeric_limits<double>::epsilon.
0023     The values can optionally be computed directly using the ComputePrecision()
0024     member function. For a IEEE standard floating point arithmetic the computed values and
0025     the one from std::numeric_limits<double>::epsilon  are the same.
0026 
0027     SetPrecision() method can instead be used to override Minuit's own determination,
0028     when the user knows that the {FCN} function Value is not calculated to
0029     the nominal machine accuracy.
0030  */
0031 
0032 class MnMachinePrecision {
0033 
0034 public:
0035    MnMachinePrecision();
0036 
0037    /// eps returns the smallest possible number so that 1.+eps > 1.
0038    double Eps() const { return fEpsMac; }
0039 
0040    /// eps2 returns 2*sqrt(eps)
0041    double Eps2() const { return fEpsMa2; }
0042 
0043    /// override Minuit's own determination
0044    void SetPrecision(double prec)
0045    {
0046       fEpsMac = prec;
0047       fEpsMa2 = 2. * std::sqrt(fEpsMac);
0048    }
0049 
0050    /// compute Machine precision directly instead
0051    /// of using default values from std::numeric_limits
0052    void ComputePrecision();
0053 
0054 private:
0055    double fEpsMac;
0056    double fEpsMa2;
0057 };
0058 
0059 } // namespace Minuit2
0060 
0061 } // namespace ROOT
0062 
0063 #endif // ROOT_Minuit2_MnMachinePrecision