Logo ROOT  
Reference Guide
TFormula.h
Go to the documentation of this file.
1// @(#)root/hist:$Id$
2// Author: Maciej Zimnoch 30/09/2013
3
4/*************************************************************************
5 * Copyright (C) 1995-2013, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11#ifndef ROOT_TFormula
12#define ROOT_TFormula
13
14
15#include "TNamed.h"
16#include "TBits.h"
17#include "TInterpreter.h"
18#include <cassert>
19#include <vector>
20#include <list>
21#include <map>
22#include <string>
23#include <atomic>
24#include <Math/Types.h>
25
26class TMethodCall;
27
28
30{
31public:
37 const char * GetName() const { return fName.Data(); }
38 const char * GetBody() const { return fBody.Data(); }
39 Int_t GetNargs() const { return fNargs;}
40 Bool_t IsFuncCall() const { return fFuncCall;}
42 TFormulaFunction(const TString &name, const TString &body, int numArgs)
43 : fName(name),fBody(body),fNargs(numArgs),fFound(false),fFuncCall(true) {}
45 : fName(name),fBody(""),fNargs(0),fFound(false),fFuncCall(false){}
46 Bool_t operator<(const TFormulaFunction &rhv) const
47 {
48 // order by length - first the longer ones to avoid replacing wrong functions
49 if ( fName.Length() < rhv.fName.Length() )
50 return true;
51 else if ( fName.Length() > rhv.fName.Length() )
52 return false;
53 // case of equal length
54 return fName < rhv.fName && fBody < rhv.fBody;
55 }
56 Bool_t operator==(const TFormulaFunction &rhv) const
57 {
58 return fName == rhv.fName && fBody == rhv.fBody && fNargs == rhv.fNargs;
59 }
60};
61
63{
64public:
69 const char * GetName() const { return fName.Data(); }
70 Double_t GetInitialValue() const { return fValue; }
71 Int_t GetArrayPos() const { return fArrayPos; }
72 TFormulaVariable():fName(""),fValue(-1),fArrayPos(-1),fFound(false){}
74 : fName(name), fValue(value), fArrayPos(pos),fFound(false) {}
75 Bool_t operator<(const TFormulaVariable &rhv) const
76 {
77 return fName < rhv.fName;
78 }
79};
80
81struct TFormulaParamOrder {
82 bool operator() (const TString& a, const TString& b) const;
83};
84
85
86class TFormula : public TNamed
87{
88private:
89
90// All data members are transient apart from the string defining the formula and the parameter values
91 TString fClingInput; ///<! Input function passed to Cling
92 std::vector<Double_t> fClingVariables; ///<! Cached variables
93 std::vector<Double_t> fClingParameters; ///< Parameter values
94 Bool_t fReadyToExecute; ///<! Transient to force initialization
95 std::atomic<Bool_t> fClingInitialized; ///<! Transient to force re-initialization
96 Bool_t fAllParametersSetted; ///< Flag to control if all parameters are setted
97 Bool_t fLazyInitialization = kFALSE; ///<! Transient flag to control lazy initialization (needed for reading from files)
98 std::unique_ptr<TMethodCall> fMethod; ///<! Pointer to methodcall
99 TString fClingName; ///<! Unique name passed to Cling to define the function ( double clingName(double*x, double*p) )
100 std::string fSavedInputFormula; ///<! Unique name used to defined the function and used in the global map (need to be saved in case of lazy initialization)
101
103 std::string fGradGenerationInput; ///<! Input query to clad to generate a gradient
104 std::string fHessGenerationInput; ///<! Input query to clad to generate a hessian
105 CallFuncSignature fFuncPtr = nullptr; ///<! Function pointer, owned by the JIT.
106 CallFuncSignature fGradFuncPtr = nullptr; ///<! Function pointer, owned by the JIT.
107 CallFuncSignature fHessFuncPtr = nullptr; ///<! Function pointer, owned by the JIT.
108 void * fLambdaPtr = nullptr; ///<! Pointer to the lambda function
109 static bool fIsCladRuntimeIncluded;
110
113 void FillDefaults();
114 void HandlePolN(TString &formula);
116 void HandleParamRanges(TString &formula);
117 void HandleFunctionArguments(TString &formula);
118 void HandleExponentiation(TString &formula);
119 void HandleLinear(TString &formula);
120 Bool_t InitLambdaExpression(const char * formula);
122 void ReplaceAllNames(TString &formula, std::map<TString, TString> &substitutions);
123 void FillParametrizedFunctions(std::map<std::pair<TString, Int_t>, std::pair<TString, TString>> &functions);
126 std::string GetGradientFuncName() const {
127 assert(fClingName.Length() && "TFormula is not initialized yet!");
128 return std::string(fClingName.Data()) + "_grad_1";
129 }
130 std::string GetHessianFuncName() const {
131 assert(fClingName.Length() && "TFormula is not initialized yet!");
132 return std::string(fClingName.Data()) + "_hessian_1";
133 }
134 bool HasGradientGenerationFailed() const {
135 return !fGradFuncPtr && !fGradGenerationInput.empty();
136 }
137 bool HasHessianGenerationFailed() const {
138 return !fHessFuncPtr && !fHessGenerationInput.empty();
139 }
140
141protected:
142
143 std::list<TFormulaFunction> fFuncs; ///<!
144 std::map<TString,TFormulaVariable> fVars; ///<! List of variable names
145 std::map<TString,Int_t,TFormulaParamOrder> fParams; ///<|| List of parameter names
146 std::map<TString,Double_t> fConsts; ///<!
147 std::map<TString,TString> fFunctionsShortcuts; ///<!
148 TString fFormula; ///< String representing the formula expression
149 Int_t fNdim; ///< Dimension - needed for lambda expressions
150 Int_t fNpar; ///<! Number of parameter (transient since we save the vector)
151 Int_t fNumber; ///<!
152 std::vector<TObject*> fLinearParts; ///< Vector of linear functions
153 Bool_t fVectorized = false; ///< Whether we should use vectorized or regular variables
154 // (we default to false since a lot of functions still cannot be expressed in vectorized form)
155
156 static Bool_t IsOperator(const char c);
157 static Bool_t IsBracket(const char c);
158 static Bool_t IsFunctionNameChar(const char c);
159 static Bool_t IsScientificNotation(const TString & formula, int ipos);
160 static Bool_t IsHexadecimal(const TString & formula, int ipos);
161 static Bool_t IsAParameterName(const TString & formula, int ipos);
162 void ExtractFunctors(TString &formula);
163 void PreProcessFormula(TString &formula);
164 void ProcessFormula(TString &formula);
165 Bool_t PrepareFormula(TString &formula);
166 void ReplaceParamName(TString &formula, const TString & oldname, const TString & name);
167 void DoAddParameter(const TString &name, Double_t value, bool processFormula);
168 void DoSetParameters(const Double_t * p, Int_t size);
170
171 Double_t DoEval(const Double_t * x, const Double_t * p = nullptr) const;
172#ifdef R__HAS_VECCORE
173 ROOT::Double_v DoEvalVec(const ROOT::Double_v *x, const Double_t *p = nullptr) const;
174#endif
175
176public:
177
178 enum EStatusBits {
179 kNotGlobal = BIT(10), ///< Don't store in gROOT->GetListOfFunction (it should be protected)
180 kNormalized = BIT(14), ///< Set to true if the TFormula (ex gausn) is normalized
181 kLinear = BIT(16), ///< Set to true if the TFormula is for linear fitting
182 kLambda = BIT(17) ///< Set to true if TFormula has been build with a lambda
183 };
184 using CladStorage = std::vector<Double_t>;
185
186 TFormula();
187 ~TFormula() override;
188 TFormula& operator=(const TFormula &rhs);
189 TFormula(const char *name, const char * formula = "", bool addToGlobList = true, bool vectorize = false);
190 TFormula(const char *name, const char * formula, int ndim, int npar, bool addToGlobList = true);
191 TFormula(const TFormula &formula);
192 // TFormula(const char *name, Int_t nparams, Int_t ndims);
193
194 void AddParameter(const TString &name, Double_t value = 0) { DoAddParameter(name,value,true); }
195 void AddVariable(const TString &name, Double_t value = 0);
196 void AddVariables(const TString *vars, const Int_t size);
197 Int_t Compile(const char *expression="");
198 void Copy(TObject &f1) const override;
199 void Clear(Option_t * option="") override;
200 Double_t Eval(Double_t x) const;
204 Double_t EvalPar(const Double_t *x, const Double_t *params=0) const;
205
206 /// Generate gradient computation routine with respect to the parameters.
207 /// \returns true if a gradient was generated and GradientPar can be called.
208 bool GenerateGradientPar();
209
210 /// Generate hessian computation routine with respect to the parameters.
211 /// \returns true if a hessian was generated and HessianPar can be called.
212 bool GenerateHessianPar();
213
214 /// Compute the gradient employing automatic differentiation.
215 ///
216 /// \param[in] x - The given variables, if nullptr the already stored
217 /// variables are used.
218 /// \param[out] result - The result of the computation wrt each direction.
220
221 void GradientPar(const Double_t *x, Double_t *result);
222
223 /// Compute the gradient employing automatic differentiation.
224 ///
225 /// \param[in] x - The given variables, if nullptr the already stored
226 /// variables are used.
227 /// \param[out] result - The 2D hessian matrix flattened to form a vector
228 /// in row-major order.
230
231 void HessianPar(const Double_t *x, Double_t *result);
232
233 // query if TFormula provides gradient computation using AD (CLAD)
234 bool HasGeneratedGradient() const {
235 return fGradFuncPtr != nullptr;
236 }
237
238 // query if TFormula provides hessian computation using AD (CLAD)
239 bool HasGeneratedHessian() const {
240 return fHessFuncPtr != nullptr;
241 }
242
243 // template <class T>
244 // T Eval(T x, T y = 0, T z = 0, T t = 0) const;
245 template <class T>
246 T EvalPar(const T *x, const Double_t *params = 0) const {
247 return EvalParVec(x, params);
248 }
249#ifdef R__HAS_VECCORE
250 ROOT::Double_v EvalParVec(const ROOT::Double_v *x, const Double_t *params = 0) const;
251#endif
255 const TObject *GetLinearPart(Int_t i) const;
256 Int_t GetNdim() const {return fNdim;}
257 Int_t GetNpar() const {return fNpar;}
258 Int_t GetNumber() const { return fNumber; }
259 const char * GetParName(Int_t ipar) const;
260 Int_t GetParNumber(const char * name) const;
261 Double_t GetParameter(const char * name) const;
262 Double_t GetParameter(Int_t param) const;
263 Double_t* GetParameters() const;
264 void GetParameters(Double_t *params) const;
265 Double_t GetVariable(const char *name) const;
266 Int_t GetVarNumber(const char *name) const;
267 TString GetVarName(Int_t ivar) const;
268 Bool_t IsValid() const { return fReadyToExecute && fClingInitialized; }
269 Bool_t IsVectorized() const { return fVectorized; }
270 Bool_t IsLinear() const { return TestBit(kLinear); }
271 void Print(Option_t *option = "") const override;
272 void SetName(const char* name) override;
273 void SetParameter(const char* name, Double_t value);
274 void SetParameter(Int_t param, Double_t value);
275 void SetParameters(const Double_t *params);
276 //void SetParameters(const pair<TString,Double_t> *params, const Int_t size);
277 void SetParameters(Double_t p0,Double_t p1,Double_t p2=0,Double_t p3=0,Double_t p4=0,
278 Double_t p5=0,Double_t p6=0,Double_t p7=0,Double_t p8=0,
279 Double_t p9=0,Double_t p10=0); // *MENU*
280 void SetParName(Int_t ipar, const char *name);
281 void SetParNames(const char *name0="p0",const char *name1="p1",const char
282 *name2="p2",const char *name3="p3",const char
283 *name4="p4", const char *name5="p5",const char *name6="p6",const char *name7="p7",const char
284 *name8="p8",const char *name9="p9",const char *name10="p10"); // *MENU*
285 void SetVariable(const TString &name, Double_t value);
286 void SetVariables(const std::pair<TString,Double_t> *vars, const Int_t size);
287 void SetVectorized(Bool_t vectorized);
288
290};
291#endif
#define c(i)
Definition: RSha256.hxx:101
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
bool Bool_t
Definition: RtypesCore.h:63
int Int_t
Definition: RtypesCore.h:45
const Bool_t kFALSE
Definition: RtypesCore.h:101
double Double_t
Definition: RtypesCore.h:59
const char Option_t
Definition: RtypesCore.h:66
#define BIT(n)
Definition: Rtypes.h:85
#define ClassDefOverride(name, id)
Definition: Rtypes.h:339
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t b
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
char name[80]
Definition: TGX11.cxx:110
Helper class for TFormula.
Definition: TFormula.h:30
Bool_t fFound
Definition: TFormula.h:35
const char * GetName() const
Definition: TFormula.h:37
const char * GetBody() const
Definition: TFormula.h:38
Int_t GetNargs() const
Definition: TFormula.h:39
TString fName
Definition: TFormula.h:32
TString fBody
Definition: TFormula.h:33
Bool_t operator<(const TFormulaFunction &rhv) const
Definition: TFormula.h:46
Bool_t fFuncCall
Definition: TFormula.h:36
Bool_t IsFuncCall() const
Definition: TFormula.h:40
Bool_t operator==(const TFormulaFunction &rhv) const
Definition: TFormula.h:56
Another helper class for TFormula.
Definition: TFormula.h:63
TString fName
Definition: TFormula.h:65
Bool_t operator<(const TFormulaVariable &rhv) const
Definition: TFormula.h:75
const char * GetName() const
Definition: TFormula.h:69
Int_t GetArrayPos() const
Definition: TFormula.h:71
Int_t fArrayPos
Definition: TFormula.h:67
Double_t GetInitialValue() const
Definition: TFormula.h:70
Bool_t fFound
Definition: TFormula.h:68
Double_t fValue
Definition: TFormula.h:66
The Formula class.
Definition: TFormula.h:87
CallFuncSignature fHessFuncPtr
! Function pointer, owned by the JIT.
Definition: TFormula.h:107
Double_t GetParameter(const char *name) const
Returns parameter value given by string.
Definition: TFormula.cxx:2830
Bool_t PrepareFormula(TString &formula)
prepare the formula to be executed normally is called with fFormula
Definition: TFormula.cxx:1790
std::atomic< Bool_t > fClingInitialized
! Transient to force re-initialization
Definition: TFormula.h:95
void GradientPar(const Double_t *x, TFormula::CladStorage &result)
Compute the gradient employing automatic differentiation.
Definition: TFormula.cxx:3277
void FillDefaults()
Fill structures with default variables, constants and function shortcuts.
Definition: TFormula.cxx:904
TString GetHessianFormula() const
Definition: TFormula.cxx:3691
void Clear(Option_t *option="") override
Clear the formula setting expression to empty and reset the variables and parameters containers.
Definition: TFormula.cxx:769
const TObject * GetLinearPart(Int_t i) const
Return linear part.
Definition: TFormula.cxx:2550
Bool_t IsLinear() const
Definition: TFormula.h:270
void InputFormulaIntoCling()
Inputs formula, transfered to C++ code into Cling.
Definition: TFormula.cxx:878
bool HasGeneratedHessian() const
Definition: TFormula.h:239
void DoAddParameter(const TString &name, Double_t value, bool processFormula)
Adds parameter to known parameters.
Definition: TFormula.cxx:2740
bool HasGeneratedGradient() const
Definition: TFormula.h:234
void HandleLinear(TString &formula)
Handle linear functions defined with the operator ++.
Definition: TFormula.cxx:1732
TString fClingName
! Unique name passed to Cling to define the function ( double clingName(double*x, double*p) )
Definition: TFormula.h:99
TString GetVarName(Int_t ivar) const
Returns variable name given its position in the array.
Definition: TFormula.cxx:2709
void SetVariable(const TString &name, Double_t value)
Sets variable value.
Definition: TFormula.cxx:2725
void HessianPar(const Double_t *x, TFormula::CladStorage &result)
Compute the gradient employing automatic differentiation.
Definition: TFormula.cxx:3339
Int_t GetParNumber(const char *name) const
Return parameter index given a name (return -1 for not existing parameters) non need to print an erro...
Definition: TFormula.cxx:2818
void DoSetParameters(const Double_t *p, Int_t size)
Definition: TFormula.cxx:2946
bool GenerateHessianPar()
Generate hessian computation routine with respect to the parameters.
Definition: TFormula.cxx:3309
TString GetGradientFormula() const
Definition: TFormula.cxx:3683
Double_t Eval(Double_t x) const
Sets first variable (e.g. x) and evaluate formula.
Definition: TFormula.cxx:3436
void HandleParametrizedFunctions(TString &formula)
Handling parametrized functions Function can be normalized, and have different variable then x.
Definition: TFormula.cxx:1105
~TFormula() override
Definition: TFormula.cxx:465
TInterpreter::CallFuncIFacePtr_t::Generic_t CallFuncSignature
Definition: TFormula.h:102
Double_t * GetParameters() const
Definition: TFormula.cxx:2870
void SetParName(Int_t ipar, const char *name)
Definition: TFormula.cxx:3037
void SetName(const char *name) override
Set the name of the formula.
Definition: TFormula.cxx:2637
std::string GetHessianFuncName() const
Definition: TFormula.h:130
std::string fGradGenerationInput
! Input query to clad to generate a gradient
Definition: TFormula.h:103
Double_t EvalPar(const Double_t *x, const Double_t *params=0) const
Definition: TFormula.cxx:3125
static Bool_t IsAParameterName(const TString &formula, int ipos)
Definition: TFormula.cxx:354
bool HasGradientGenerationFailed() const
Definition: TFormula.h:134
void ReplaceParamName(TString &formula, const TString &oldname, const TString &name)
Replace in Formula expression the parameter name.
Definition: TFormula.cxx:3067
void SetPredefinedParamNames()
Set parameter names only in case of pre-defined functions.
Definition: TFormula.cxx:2468
void Copy(TObject &f1) const override
Copy this to obj.
Definition: TFormula.cxx:686
std::map< TString, Double_t > fConsts
!
Definition: TFormula.h:146
std::map< TString, TString > fFunctionsShortcuts
!
Definition: TFormula.h:147
void HandleParamRanges(TString &formula)
Handling parameter ranges, in the form of [1..5].
Definition: TFormula.cxx:1322
std::vector< TObject * > fLinearParts
Vector of linear functions.
Definition: TFormula.h:152
static Bool_t IsBracket(const char c)
Definition: TFormula.cxx:295
Bool_t fVectorized
Whether we should use vectorized or regular variables.
Definition: TFormula.h:153
TString fClingInput
! Input function passed to Cling
Definition: TFormula.h:91
Bool_t PrepareEvalMethod()
Sets TMethodCall to function inside Cling environment.
Definition: TFormula.cxx:863
Int_t fNumber
!
Definition: TFormula.h:151
std::string GetGradientFuncName() const
Definition: TFormula.h:126
static bool fIsCladRuntimeIncluded
Definition: TFormula.h:109
std::vector< Double_t > CladStorage
Definition: TFormula.h:184
Double_t GetVariable(const char *name) const
Returns variable value.
Definition: TFormula.cxx:2683
std::list< TFormulaFunction > fFuncs
!
Definition: TFormula.h:143
Bool_t fAllParametersSetted
Flag to control if all parameters are setted.
Definition: TFormula.h:96
void ProcessFormula(TString &formula)
Iterates through functors in fFuncs and performs the appropriate action.
Definition: TFormula.cxx:2074
static Bool_t IsOperator(const char c)
Definition: TFormula.cxx:287
bool HasHessianGenerationFailed() const
Definition: TFormula.h:137
void SetVectorized(Bool_t vectorized)
Definition: TFormula.cxx:3093
void FillVecFunctionsShurtCuts()
Fill the shortcuts for vectorized functions We will replace for example sin with vecCore::Mat::Sin.
Definition: TFormula.cxx:972
const char * GetParName(Int_t ipar) const
Return parameter name given by integer.
Definition: TFormula.cxx:2856
std::map< TString, TFormulaVariable > fVars
! List of variable names
Definition: TFormula.h:144
CallFuncSignature fFuncPtr
! Function pointer, owned by the JIT.
Definition: TFormula.h:105
void HandlePolN(TString &formula)
Handling polN If before 'pol' exist any name, this name will be treated as variable used in polynomia...
Definition: TFormula.cxx:1004
static Bool_t IsHexadecimal(const TString &formula, int ipos)
Definition: TFormula.cxx:331
void ExtractFunctors(TString &formula)
Extracts functors from formula, and put them in fFuncs.
Definition: TFormula.cxx:1829
Int_t GetNumber() const
Definition: TFormula.h:258
Bool_t InitLambdaExpression(const char *formula)
Definition: TFormula.cxx:607
void SetParameters(const Double_t *params)
Set a vector of parameters value.
Definition: TFormula.cxx:2967
void AddParameter(const TString &name, Double_t value=0)
Definition: TFormula.h:194
std::string fSavedInputFormula
! Unique name used to defined the function and used in the global map (need to be saved in case of la...
Definition: TFormula.h:100
Bool_t IsValid() const
Definition: TFormula.h:268
void ReplaceAllNames(TString &formula, std::map< TString, TString > &substitutions)
Definition: TFormula.cxx:406
static Bool_t IsDefaultVariableName(const TString &name)
Definition: TFormula.cxx:313
Int_t GetNpar() const
Definition: TFormula.h:257
void FillParametrizedFunctions(std::map< std::pair< TString, Int_t >, std::pair< TString, TString > > &functions)
Fill map with parametrized functions.
Definition: TFormula.cxx:2414
void SetParNames(const char *name0="p0", const char *name1="p1", const char *name2="p2", const char *name3="p3", const char *name4="p4", const char *name5="p5", const char *name6="p6", const char *name7="p7", const char *name8="p8", const char *name9="p9", const char *name10="p10")
Definition: TFormula.cxx:3008
void AddVariables(const TString *vars, const Int_t size)
Adds multiple variables.
Definition: TFormula.cxx:2599
Int_t GetVarNumber(const char *name) const
Returns variable number (positon in array) given its name.
Definition: TFormula.cxx:2696
std::vector< Double_t > fClingVariables
! Cached variables
Definition: TFormula.h:92
std::unique_ptr< TMethodCall > fMethod
! Pointer to methodcall
Definition: TFormula.h:98
TString fFormula
String representing the formula expression.
Definition: TFormula.h:148
static Bool_t IsScientificNotation(const TString &formula, int ipos)
Definition: TFormula.cxx:319
CallFuncSignature fGradFuncPtr
! Function pointer, owned by the JIT.
Definition: TFormula.h:106
std::vector< Double_t > fClingParameters
Parameter values.
Definition: TFormula.h:93
void SetParameter(const char *name, Double_t value)
Sets parameter value.
Definition: TFormula.cxx:2890
void Print(Option_t *option="") const override
Print the formula and its attributes.
Definition: TFormula.cxx:3700
void PreProcessFormula(TString &formula)
Preprocessing of formula Replace all ** by ^, and removes spaces.
Definition: TFormula.cxx:1768
TString GetExpFormula(Option_t *option="") const
Return the expression formula.
Definition: TFormula.cxx:3613
Int_t fNdim
Dimension - needed for lambda expressions.
Definition: TFormula.h:149
void SetVariables(const std::pair< TString, Double_t > *vars, const Int_t size)
Sets multiple variables.
Definition: TFormula.cxx:2666
void ReInitializeEvalMethod()
Re-initialize eval method.
Definition: TFormula.cxx:3556
@ kNotGlobal
Don't store in gROOT->GetListOfFunction (it should be protected)
Definition: TFormula.h:179
@ kLambda
Set to true if TFormula has been build with a lambda.
Definition: TFormula.h:182
@ kLinear
Set to true if the TFormula is for linear fitting.
Definition: TFormula.h:181
@ kNormalized
Set to true if the TFormula (ex gausn) is normalized.
Definition: TFormula.h:180
void * fLambdaPtr
! Pointer to the lambda function
Definition: TFormula.h:108
TFormula & operator=(const TFormula &rhs)
= operator.
Definition: TFormula.cxx:597
Int_t Compile(const char *expression="")
Compile the given expression with Cling backward compatibility method to be used in combination with ...
Definition: TFormula.cxx:652
Int_t fNpar
! Number of parameter (transient since we save the vector)
Definition: TFormula.h:150
void HandleFunctionArguments(TString &formula)
Handling user functions (and parametrized functions) to take variables and optionally parameters as a...
Definition: TFormula.cxx:1353
std::map< TString, Int_t, TFormulaParamOrder > fParams
|| List of parameter names
Definition: TFormula.h:145
Bool_t IsVectorized() const
Definition: TFormula.h:269
void AddVariable(const TString &name, Double_t value=0)
Adds variable to known variables, and reprocess formula.
Definition: TFormula.cxx:2566
Bool_t fLazyInitialization
! Transient flag to control lazy initialization (needed for reading from files)
Definition: TFormula.h:97
Int_t GetNdim() const
Definition: TFormula.h:256
void HandleExponentiation(TString &formula)
Handling exponentiation Can handle multiple carets, eg.
Definition: TFormula.cxx:1637
static Bool_t IsFunctionNameChar(const char c)
Definition: TFormula.cxx:307
std::string fHessGenerationInput
! Input query to clad to generate a hessian
Definition: TFormula.h:104
Double_t DoEval(const Double_t *x, const Double_t *p=nullptr) const
Evaluate formula.
Definition: TFormula.cxx:3448
Bool_t fReadyToExecute
! Transient to force initialization
Definition: TFormula.h:94
bool GenerateGradientPar()
Generate gradient computation routine with respect to the parameters.
Definition: TFormula.cxx:3250
Method or function calling interface.
Definition: TMethodCall.h:37
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
Mother of all ROOT objects.
Definition: TObject.h:37
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition: TObject.h:187
Basic string class.
Definition: TString.h:136
Ssiz_t Length() const
Definition: TString.h:410
const char * Data() const
Definition: TString.h:369
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
TF1 * f1
Definition: legend1.C:11
double T(double x)
Definition: ChebyshevPol.h:34
Functor defining the parameter order.
Definition: TFormula.h:81
bool operator()(const TString &a, const TString &b) const
Definition: TFormula.cxx:376
void(* Generic_t)(void *, int, void **, void *)
Definition: TInterpreter.h:94
auto * a
Definition: textangle.C:12