ROOT
master
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 "
Minuit2/MnTiny.h
"
12
#include <limits>
13
14
namespace
ROOT
{
15
16
namespace
Minuit2 {
17
18
MnMachinePrecision::MnMachinePrecision
()
19
{
20
// use double precision values from the numeric_limits standard
21
// and do not determine it anymore using ComputePrecision
22
// epsilon from stundard
23
// note that there is a factor of 2 in the definition of
24
// std::numeric_limitys::epsilon w.r.t DLAMCH epsilon
25
26
fEpsMac
= 4. * std::numeric_limits<double>::epsilon();
27
fEpsMa2
= 2. * std::sqrt(
fEpsMac
);
28
}
29
void
MnMachinePrecision::ComputePrecision
()
30
{
31
fEpsMac
= 4.0E-7;
32
fEpsMa2
= 2. * std::sqrt(
fEpsMac
);
33
34
// determine machine precision using
35
// code similar to DLAMCH LAPACK Fortran function
36
/*
37
char e[] = {"e"};
38
fEpsMac = 8.*dlamch_(e);
39
fEpsMa2 = 2.*std::sqrt(fEpsMac);
40
*/
41
42
MnTiny
mytiny;
43
44
// calculate machine precision
45
double
epstry = 0.5;
46
double
epsbak = 0.;
47
volatile
double
epsp1 = 0.;
// allow to run this method with fast-math
48
double
one = 1.0;
49
for
(
int
i = 0; i < 100; i++) {
50
epstry *= 0.5;
51
epsp1 = one + epstry;
52
epsbak = mytiny(epsp1);
53
if
(epsbak < epstry) {
54
fEpsMac
= 8. * epstry;
55
fEpsMa2
= 2. * std::sqrt(
fEpsMac
);
56
break
;
57
}
58
}
59
}
60
61
}
// namespace Minuit2
62
63
}
// namespace ROOT
MnMachinePrecision.h
MnTiny.h
ROOT::Minuit2::MnMachinePrecision::ComputePrecision
void ComputePrecision()
compute Machine precision directly instead of using default values from std::numeric_limits
Definition
MnMachinePrecision.cxx:29
ROOT::Minuit2::MnMachinePrecision::fEpsMac
double fEpsMac
Definition
MnMachinePrecision.h:55
ROOT::Minuit2::MnMachinePrecision::MnMachinePrecision
MnMachinePrecision()
Definition
MnMachinePrecision.cxx:18
ROOT::Minuit2::MnMachinePrecision::fEpsMa2
double fEpsMa2
Definition
MnMachinePrecision.h:56
ROOT::Minuit2::MnTiny
Definition
MnTiny.h:17
ROOT
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition
EExecutionPolicy.hxx:4
math
minuit2
src
MnMachinePrecision.cxx
ROOT master - Reference Guide Generated on Wed Aug 14 2024 14:54:34 (GVA Time) using Doxygen 1.9.8