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
24#include "Minuit2/FCNBase.h"
25
26#include <ROOT/RSpan.hxx>
27
28#include <vector>
29
30namespace ROOT {
31namespace Minuit2 {
32
33// Holds all necessary derivatives and associated numbers (per parameter) used in the NumericalDerivator class.
39
41public:
44 NumericalDerivator(double step_tolerance, double grad_tolerance, unsigned int ncycles, double error_level,
46
47 void SetupDifferentiate(unsigned int nDim, const FCNBase *function, const double *cx,
48 std::span<const ROOT::Fit::ParameterSettings> parameters);
49 std::vector<DerivatorElement> Differentiate(unsigned int nDim, const FCNBase *function, const double *x,
50 std::span<const ROOT::Fit::ParameterSettings> parameters,
51 std::span<const DerivatorElement> previous_gradient);
52
53 DerivatorElement PartialDerivative(unsigned int nDim, const FCNBase *function, const double *x,
54 std::span<const ROOT::Fit::ParameterSettings> parameters,
57 std::span<const ROOT::Fit::ParameterSettings> parameters,
58 unsigned int i_component, const DerivatorElement &previous);
59 DerivatorElement operator()(unsigned int nDim, const FCNBase *function, const double *x,
60 std::span<const ROOT::Fit::ParameterSettings> parameters, unsigned int i_component,
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
73 void SetInitialGradient(std::span<const ROOT::Fit::ParameterSettings> parameters,
74 std::vector<DerivatorElement> &gradient);
75
78
79private:
80 double fStepTolerance = 0.5;
81 double fGradTolerance = 0.1;
82 double fUp = 1;
83 double fVal = 0;
84
85 std::vector<double> fVx;
86 std::vector<double> fVxExternal;
87 std::vector<double> fVxFValCache;
88 double fDfmin;
89 double fVrysml;
90
91 // MODIFIED: Minuit2 determines machine precision in a slightly different way than
92 // std::numeric_limits<double>::epsilon()). We go with the Minuit2 one.
94
98
99 unsigned int fNCycles = 2;
101};
102
103std::ostream &operator<<(std::ostream &out, const DerivatorElement &value);
104
105} // namespace Minuit2
106} // namespace ROOT
107
108#endif // ROOT_Minuit2_NumericalDerivator
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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...
Interface (abstract class) defining the function to be minimized, which has to be implemented by the ...
Definition FCNBase.h:37
Sets the relative floating point (double) arithmetic precision.
void SetInitialGradient(std::span< const ROOT::Fit::ParameterSettings > parameters, std::vector< DerivatorElement > &gradient)
This function was not implemented as in Minuit2.
double Int2ext(const ROOT::Fit::ParameterSettings &parameter, double val) const
NumericalDerivator(const NumericalDerivator &other)
ROOT::Minuit2::SqrtUpParameterTransformation fUpperLimTrafo
ROOT::Minuit2::MnMachinePrecision fPrecision
void SetNCycles(unsigned int value)
NumericalDerivator(bool always_exactly_mimic_minuit2=true)
void SetupDifferentiate(unsigned int nDim, const FCNBase *function, const double *cx, std::span< const ROOT::Fit::ParameterSettings > parameters)
This function sets internal state based on input parameters.
double DInt2Ext(const ROOT::Fit::ParameterSettings &parameter, double val) const
double Ext2int(const ROOT::Fit::ParameterSettings &parameter, double val) const
DerivatorElement operator()(unsigned int nDim, const FCNBase *function, const double *x, std::span< const ROOT::Fit::ParameterSettings > parameters, unsigned int i_component, const DerivatorElement &previous)
std::vector< DerivatorElement > Differentiate(unsigned int nDim, const FCNBase *function, const double *x, std::span< const ROOT::Fit::ParameterSettings > parameters, std::span< const DerivatorElement > previous_gradient)
ROOT::Minuit2::SinParameterTransformation fDoubleLimTrafo
DerivatorElement FastPartialDerivative(const FCNBase *function, std::span< const ROOT::Fit::ParameterSettings > parameters, unsigned int i_component, const DerivatorElement &previous)
ROOT::Minuit2::SqrtLowParameterTransformation fLowerLimTrafo
DerivatorElement PartialDerivative(unsigned int nDim, const FCNBase *function, const double *x, std::span< const ROOT::Fit::ParameterSettings > parameters, unsigned int i_component, DerivatorElement previous)
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 LAVector &)
Definition MnMatrix.cxx:691