Logo ROOT   6.18/05
Reference Guide
FCNGradAdapter.h
Go to the documentation of this file.
1// @(#)root/minuit2:$Id$
2// Author: L. Moneta 10/2006
3
4/**********************************************************************
5 * *
6 * Copyright (c) 2006 ROOT Foundation, CERN/PH-SFT *
7 * *
8 **********************************************************************/
9
10#ifndef ROOT_Minuit2_FCNGradAdapter
11#define ROOT_Minuit2_FCNGradAdapter
12
14
15//#define DEBUG
16#ifdef DEBUG
17#include <iostream>
18#endif
19
20namespace ROOT {
21
22 namespace Minuit2 {
23
24/**
25
26
27template wrapped class for adapting to FCNBase signature a IGradFunction
28
29@author Lorenzo Moneta
30
31@ingroup Minuit
32
33*/
34
35template< class Function>
37
38public:
39
40 FCNGradAdapter(const Function & f, double up = 1.) :
41 fFunc(f) ,
42 fUp (up) ,
43 fGrad(std::vector<double>(fFunc.NDim() ) )
44
45 {}
46
48
49
50 double operator()(const std::vector<double>& v) const {
51 return fFunc.operator()(&v[0]);
52 }
53 double operator()(const double * v) const {
54 return fFunc.operator()(v);
55 }
56
57 double Up() const {return fUp;}
58
59 std::vector<double> Gradient(const std::vector<double>& v) const {
60 fFunc.Gradient(&v[0], &fGrad[0]);
61
62#ifdef DEBUG
63 std::cout << " gradient in FCNAdapter = { " ;
64 for (unsigned int i = 0; i < fGrad.size(); ++i)
65 std::cout << fGrad[i] << "\t";
66 std::cout << "}" << std::endl;
67#endif
68 return fGrad;
69 }
70 // forward interface
71 //virtual double operator()(int npar, double* params,int iflag = 4) const;
72 bool CheckGradient() const { return false; }
73
74private:
75 const Function & fFunc;
76 double fUp;
77 mutable std::vector<double> fGrad;
78};
79
80 } // end namespace Minuit2
81
82} // end namespace ROOT
83
84
85
86#endif //ROOT_Minuit2_FCNGradAdapter
SVector< double, 2 > v
Definition: Dict.h:5
#define f(i)
Definition: RSha256.hxx:104
Double_t(* Function)(Double_t)
Definition: Functor.C:4
template wrapped class for adapting to FCNBase signature a IGradFunction
double operator()(const std::vector< double > &v) const
The meaning of the vector of parameters is of course defined by the user, who uses the values of thos...
FCNGradAdapter(const Function &f, double up=1.)
double operator()(const double *v) const
std::vector< double > Gradient(const std::vector< double > &v) const
double Up() const
Error definition of the function.
std::vector< double > fGrad
Extension of the FCNBase for providing the analytical Gradient of the function.
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21