Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
MnMachinePrecision.cxx
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
11#include <limits>
12
13namespace ROOT {
14
15namespace Minuit2 {
16
18{
19 // use double precision values from the numeric_limits standard
20 // and do not determine it anymore using ComputePrecision
21 // epsilon from stundard
22 // note that there is a factor of 2 in the definition of
23 // std::numeric_limitys::epsilon w.r.t DLAMCH epsilon
24
25 fEpsMac = 4. * std::numeric_limits<double>::epsilon();
26 fEpsMa2 = 2. * std::sqrt(fEpsMac);
27}
29{
30 fEpsMac = 4.0E-7;
31 fEpsMa2 = 2. * std::sqrt(fEpsMac);
32
33 // determine machine precision using
34 // code similar to DLAMCH LAPACK Fortran function
35 /*
36 char e[] = {"e"};
37 fEpsMac = 8.*dlamch_(e);
38 fEpsMa2 = 2.*std::sqrt(fEpsMac);
39 */
40
41 // calculate machine precision
42 double epstry = 0.5;
43 double epsbak = 0.;
44 volatile double epsp1 = 0.; // allow to run this method with fast-math
45 double one = 1.0;
46 for (int i = 0; i < 100; i++) {
47 epstry *= 0.5;
48 epsp1 = one + epstry;
49 epsbak = Tiny(epsp1);
50 if (epsbak < epstry) {
51 fEpsMac = 8. * epstry;
52 fEpsMa2 = 2. * std::sqrt(fEpsMac);
53 break;
54 }
55 }
56}
57
59{
60 return fOne;
61}
62
63double MnMachinePrecision::Tiny(double epsp1) const
64{
65 // evaluate minimal difference between two floating points
66 double result = epsp1 - One();
67 return result;
68}
69
70} // namespace Minuit2
71
72} // namespace ROOT
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
void ComputePrecision()
compute Machine precision directly instead of using default values from std::numeric_limits
Namespace for new ROOT classes and functions.