Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooNumber.cxx
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * @(#)root/roofitcore:$Id$
5 * Authors: *
6 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8 * *
9 * Copyright (c) 2000-2005, Regents of the University of California *
10 * and Stanford University. All rights reserved. *
11 * *
12 * Redistribution and use in source and binary forms, *
13 * with or without modification, are permitted according to the terms *
14 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15 *****************************************************************************/
16
17/**
18\file RooNumber.cxx
19\class RooNumber
20\ingroup Roofitcore
21
22Provides numeric constants used in \ref Roofitmain.
23**/
24
25#include <RooNumber.h>
26
27/// @brief Returns an std::to_string compatible number (i.e. rounds infinities back to the nearest representable
28/// value). This function is primarily used in the code-squashing for AD and as such encodes infinities to double's
29/// maximum value. We do this because 1, std::to_string cannot handle infinities correctly on some platforms
30/// (e.g. 32 bit debian) and 2, Clad (the AD tool) cannot handle differentiating std::numeric_limits::infinity directly.
31std::string RooNumber::toString(double x)
32{
33 int sign = isInfinite(x);
34 double out = x;
35 if (sign)
36 out = sign == 1 ? std::numeric_limits<double>::max() : std::numeric_limits<double>::min();
37 return std::to_string(out);
38}
39
41{
42 static double epsRel = 0.0;
43 return epsRel;
44}
45
47{
48 static double epsAbs = 0.0;
49 return epsAbs;
50}
static double & staticRangeEpsRel()
Definition RooNumber.cxx:40
static constexpr int isInfinite(double x)
Return true if x is infinite by RooNumber internal specification.
Definition RooNumber.h:27
static double & staticRangeEpsAbs()
Definition RooNumber.cxx:46
static std::string toString(double x)
Returns an std::to_string compatible number (i.e.
Definition RooNumber.cxx:31
Double_t x[n]
Definition legend1.C:17