ROOT
v6-22
Reference Guide
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
19
MnMachinePrecision::MnMachinePrecision
() {
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.*
sqrt
(
fEpsMac
);
28
}
29
void
MnMachinePrecision::ComputePrecision
() {
30
fEpsMac
= 4.0E-7;
31
fEpsMa2
= 2.*
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.*sqrt(fEpsMac);
39
*/
40
41
MnTiny
mytiny;
42
43
//calculate machine precision
44
double
epstry = 0.5;
45
double
epsbak = 0.;
46
volatile
double
epsp1 = 0.;
// allow to run this method with fast-math
47
double
one = 1.0;
48
for
(
int
i = 0; i < 100; i++) {
49
epstry *= 0.5;
50
epsp1 = one + epstry;
51
epsbak = mytiny(epsp1);
52
if
(epsbak < epstry) {
53
fEpsMac
= 8.*epstry;
54
fEpsMa2
= 2.*
sqrt
(
fEpsMac
);
55
break
;
56
}
57
}
58
59
}
60
61
}
// namespace Minuit2
62
63
}
// namespace ROOT
MnMachinePrecision.h
MnTiny.h
sqrt
double sqrt(double)
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:58
ROOT::Minuit2::MnMachinePrecision::MnMachinePrecision
MnMachinePrecision()
Definition:
MnMachinePrecision.cxx:19
ROOT::Minuit2::MnMachinePrecision::fEpsMa2
double fEpsMa2
Definition:
MnMachinePrecision.h:59
ROOT::Minuit2::MnTiny
Definition:
MnTiny.h:18
ROOT
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition:
StringConv.hxx:21
epsilon
REAL epsilon
Definition:
triangle.c:617
math
minuit2
src
MnMachinePrecision.cxx
ROOT v6-22 - Reference Guide Generated on Fri Apr 1 2022 11:52:16 (GVA Time) using Doxygen 1.9.4