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 "Minuit2/MnTiny.h"
12#include <limits>
13
14namespace ROOT {
15
16namespace Minuit2 {
17
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}
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
void ComputePrecision()
compute Machine precision directly instead of using default values from std::numeric_limits
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.