ROOT
git-r3/HEAD
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
10
#include "
Minuit2/MnMachinePrecision.h
"
11
#include <limits>
12
13
namespace
ROOT
{
14
15
namespace
Minuit2
{
16
17
MnMachinePrecision::MnMachinePrecision
()
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
}
28
void
MnMachinePrecision::ComputePrecision
()
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
58
double
MnMachinePrecision::One
()
const
59
{
60
return
fOne
;
61
}
62
63
double
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
MnMachinePrecision.h
ROOT::Minuit2::MnMachinePrecision::ComputePrecision
void ComputePrecision()
compute Machine precision directly instead of using default values from std::numeric_limits
Definition
MnMachinePrecision.cxx:28
ROOT::Minuit2::MnMachinePrecision::One
double One() const
Definition
MnMachinePrecision.cxx:58
ROOT::Minuit2::MnMachinePrecision::fEpsMac
double fEpsMac
Definition
MnMachinePrecision.h:58
ROOT::Minuit2::MnMachinePrecision::MnMachinePrecision
MnMachinePrecision()
Definition
MnMachinePrecision.cxx:17
ROOT::Minuit2::MnMachinePrecision::Tiny
double Tiny(double epsp1) const
Definition
MnMachinePrecision.cxx:63
ROOT::Minuit2::MnMachinePrecision::fEpsMa2
double fEpsMa2
Definition
MnMachinePrecision.h:59
ROOT::Minuit2::MnMachinePrecision::fOne
double fOne
Definition
MnMachinePrecision.h:60
ROOT::Minuit2
Definition
AnalyticalGradientCalculator.h:18
ROOT
Definition
EExecutionPolicy.hxx:4
math
minuit2
src
MnMachinePrecision.cxx
ROOTgit-r3/HEAD - Reference Guide Generated on
(GVA Time) using Doxygen 1.16.1