Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
28
29#include <ROOT/RSpan.hxx>
30
31#include <vector>
32
33namespace ROOT {
34namespace Minuit2 {
35
36// Holds all necessary derivatives and associated numbers (per parameter) used in the NumericalDerivator class.
38 double derivative;
40 double step_size;
41};
42
44public:
45 explicit NumericalDerivator(bool always_exactly_mimic_minuit2 = true);
47 NumericalDerivator(double step_tolerance, double grad_tolerance, unsigned int ncycles, double error_level,
48 bool always_exactly_mimic_minuit2 = true);
49
50 void SetupDifferentiate(const ROOT::Math::IBaseFunctionMultiDim *function, const double *cx,
51 std::span<const ROOT::Fit::ParameterSettings> parameters);
52 std::vector<DerivatorElement> Differentiate(const ROOT::Math::IBaseFunctionMultiDim *function, const double *x,
53 std::span<const ROOT::Fit::ParameterSettings> parameters,
54 std::span<const DerivatorElement> previous_gradient);
55
57 std::span<const ROOT::Fit::ParameterSettings> parameters,
58 unsigned int i_component, DerivatorElement previous);
60 std::span<const ROOT::Fit::ParameterSettings> parameters,
61 unsigned int i_component, const DerivatorElement &previous);
63 std::span<const ROOT::Fit::ParameterSettings> parameters, unsigned int i_component,
64 const DerivatorElement &previous);
65
66 double GetValue() const { return fVal; }
67 inline void SetStepTolerance(double value) { fStepTolerance = value; }
68 inline void SetGradTolerance(double value) { fGradTolerance = value; }
69 inline void SetNCycles(unsigned int value) { fNCycles = value; }
70 inline void SetErrorLevel(double value) { fUp = value; }
71
72 double Int2ext(const ROOT::Fit::ParameterSettings &parameter, double val) const;
73 double Ext2int(const ROOT::Fit::ParameterSettings &parameter, double val) const;
74 double DInt2Ext(const ROOT::Fit::ParameterSettings &parameter, double val) const;
75
77 std::span<const ROOT::Fit::ParameterSettings> parameters,
78 std::vector<DerivatorElement> &gradient);
79
82
83private:
84 double fStepTolerance = 0.5;
85 double fGradTolerance = 0.1;
86 double fUp = 1;
87 double fVal = 0;
88
89 std::vector<double> fVx;
90 std::vector<double> fVxExternal;
91 std::vector<double> fVxFValCache;
92 double fDfmin;
93 double fVrysml;
94
95 // MODIFIED: Minuit2 determines machine precision in a slightly different way than
96 // std::numeric_limits<double>::epsilon()). We go with the Minuit2 one.
98
102
103 unsigned int fNCycles = 2;
105
106};
107
108std::ostream &operator<<(std::ostream &out, const DerivatorElement &value);
109
110} // namespace Minuit2
111} // namespace ROOT
112
113#endif // ROOT_Minuit2_NumericalDerivator
TBuffer & operator<<(TBuffer &buf, const Tmpl *obj)
Definition TBuffer.h:397
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, std::span< const 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
std::vector< DerivatorElement > Differentiate(const ROOT::Math::IBaseFunctionMultiDim *function, const double *x, std::span< const ROOT::Fit::ParameterSettings > parameters, std::span< const DerivatorElement > previous_gradient)
void SetInitialGradient(const ROOT::Math::IBaseFunctionMultiDim *function, std::span< const ROOT::Fit::ParameterSettings > parameters, std::vector< DerivatorElement > &gradient)
This function was not implemented as in Minuit2.
void SetNCycles(unsigned int value)
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 PartialDerivative(const ROOT::Math::IBaseFunctionMultiDim *function, const double *x, std::span< const ROOT::Fit::ParameterSettings > parameters, unsigned int i_component, DerivatorElement previous)
ROOT::Minuit2::SqrtLowParameterTransformation fLowerLimTrafo
DerivatorElement FastPartialDerivative(const ROOT::Math::IBaseFunctionMultiDim *function, std::span< const ROOT::Fit::ParameterSettings > parameters, unsigned int i_component, const DerivatorElement &previous)
void SetupDifferentiate(const ROOT::Math::IBaseFunctionMultiDim *function, const double *cx, std::span< const ROOT::Fit::ParameterSettings > parameters)
This function sets internal state based on input parameters.
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
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...