Logo ROOT  
Reference Guide
NumericalDerivator.h
Go to the documentation of this file.
1// @(#)root/mathcore:$Id$
2// Authors: L. Moneta, J.T. Offermann, E.G.P. Bos 2013-2018
3//
4/**********************************************************************
5 * *
6 * Copyright (c) 2013 , LCG ROOT MathLib Team *
7 * *
8 **********************************************************************/
9/*
10 * NumericalDerivator.h
11 *
12 * Original version created on: Aug 14, 2013
13 * Authors: L. Moneta, J. T. Offermann
14 * Modified version created on: Sep 27, 2017
15 * Author: E. G. P. Bos
16 */
17
18#ifndef ROOT_Minuit2_NumericalDerivator
19#define ROOT_Minuit2_NumericalDerivator
20
21#include <Math/IFunctionfwd.h>
22
23#include <vector>
29
30namespace ROOT {
31namespace Minuit2 {
32
33// Holds all necessary derivatives and associated numbers (per parameter) used in the NumericalDerivator class.
35 double derivative;
37 double step_size;
38};
39
41public:
42 explicit NumericalDerivator(bool always_exactly_mimic_minuit2 = true);
44 NumericalDerivator(double step_tolerance, double grad_tolerance, unsigned int ncycles, double error_level,
45 bool always_exactly_mimic_minuit2 = true);
46
48 const std::vector<ROOT::Fit::ParameterSettings> &parameters);
49 std::vector<DerivatorElement> Differentiate(const ROOT::Math::IBaseFunctionMultiDim *function, const double *x,
50 const std::vector<ROOT::Fit::ParameterSettings> &parameters,
51 const std::vector<DerivatorElement> &previous_gradient);
52
54 const std::vector<ROOT::Fit::ParameterSettings> &parameters,
55 unsigned int i_component, DerivatorElement previous);
57 const std::vector<ROOT::Fit::ParameterSettings> &parameters,
58 unsigned int i_component, const DerivatorElement &previous);
60 const std::vector<ROOT::Fit::ParameterSettings> &parameters, unsigned int i_component,
61 const DerivatorElement &previous);
62
63 double GetValue() const { return fVal; }
64 inline void SetStepTolerance(double value) { fStepTolerance = value; }
65 inline void SetGradTolerance(double value) { fGradTolerance = value; }
66 inline void SetNCycles(unsigned int value) { fNCycles = value; }
67 inline void SetErrorLevel(double value) { fUp = value; }
68
69 double Int2ext(const ROOT::Fit::ParameterSettings &parameter, double val) const;
70 double Ext2int(const ROOT::Fit::ParameterSettings &parameter, double val) const;
71 double DInt2Ext(const ROOT::Fit::ParameterSettings &parameter, double val) const;
72
74 const std::vector<ROOT::Fit::ParameterSettings> &parameters,
75 std::vector<DerivatorElement> &gradient);
76
79
80private:
81 double fStepTolerance = 0.5;
82 double fGradTolerance = 0.1;
83 double fUp = 1;
84 double fVal = 0;
85
86 std::vector<double> fVx;
87 std::vector<double> fVxExternal;
88 std::vector<double> fVxFValCache;
89 double fDfmin;
90 double fVrysml;
91
92 // MODIFIED: Minuit2 determines machine precision in a slightly different way than
93 // std::numeric_limits<double>::epsilon()). We go with the Minuit2 one.
95
99
100 unsigned int fNCycles = 2;
102
103};
104
105std::ostream &operator<<(std::ostream &out, const DerivatorElement &value);
106
107} // namespace Minuit2
108} // namespace ROOT
109
110#endif // ROOT_Minuit2_NumericalDerivator
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Class, describing value, limits and step size of the parameters Provides functionality also to set/re...
Sets the relative floating point (double) arithmetic precision.
DerivatorElement operator()(const ROOT::Math::IBaseFunctionMultiDim *function, const double *x, const std::vector< ROOT::Fit::ParameterSettings > &parameters, unsigned int i_component, const DerivatorElement &previous)
double Int2ext(const ROOT::Fit::ParameterSettings &parameter, double val) const
NumericalDerivator(const NumericalDerivator &other)
ROOT::Minuit2::SqrtUpParameterTransformation fUpperLimTrafo
ROOT::Minuit2::MnMachinePrecision fPrecision
DerivatorElement PartialDerivative(const ROOT::Math::IBaseFunctionMultiDim *function, const double *x, const std::vector< ROOT::Fit::ParameterSettings > &parameters, unsigned int i_component, DerivatorElement previous)
void SetupDifferentiate(const ROOT::Math::IBaseFunctionMultiDim *function, const double *cx, const std::vector< ROOT::Fit::ParameterSettings > &parameters)
This function sets internal state based on input parameters.
void SetNCycles(unsigned int value)
void SetInitialGradient(const ROOT::Math::IBaseFunctionMultiDim *function, const std::vector< ROOT::Fit::ParameterSettings > &parameters, std::vector< DerivatorElement > &gradient)
This function was not implemented as in Minuit2.
NumericalDerivator(bool always_exactly_mimic_minuit2=true)
double DInt2Ext(const ROOT::Fit::ParameterSettings &parameter, double val) const
double Ext2int(const ROOT::Fit::ParameterSettings &parameter, double val) const
ROOT::Minuit2::SinParameterTransformation fDoubleLimTrafo
DerivatorElement FastPartialDerivative(const ROOT::Math::IBaseFunctionMultiDim *function, const std::vector< ROOT::Fit::ParameterSettings > &parameters, unsigned int i_component, const DerivatorElement &previous)
ROOT::Minuit2::SqrtLowParameterTransformation fLowerLimTrafo
std::vector< DerivatorElement > Differentiate(const ROOT::Math::IBaseFunctionMultiDim *function, const double *x, const std::vector< ROOT::Fit::ParameterSettings > &parameters, const std::vector< DerivatorElement > &previous_gradient)
class for the transformation for double-limited parameter Using a sin function one goes from a double...
Transformation from external to internal Parameter based on sqrt(1 + x**2)
Transformation from external to internal Parameter based on sqrt(1 + x**2)
Double_t x[n]
Definition: legend1.C:17
std::ostream & operator<<(std::ostream &, const FunctionMinimum &)
Definition: MnPrint.cxx:335
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
Definition: RExports.h:167
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.