Logo ROOT   6.13/01
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 
20 namespace ROOT {
21 
22  namespace Minuit2 {
23 
24 /**
25 
26 
27 template wrapped class for adapting to FCNBase signature a IGradFunction
28 
29 @author Lorenzo Moneta
30 
31 @ingroup Minuit
32 
33 */
34 
35 template< class Function>
37 
38 public:
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 
74 private:
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
Namespace for new ROOT classes and functions.
Definition: TFoamSampler.h:19
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...
double operator()(const double *v) const
STL namespace.
template wrapped class for adapting to FCNBase signature a IGradFunction
Extension of the FCNBase for providing the analytical Gradient of the function.
std::vector< double > Gradient(const std::vector< double > &v) const
SVector< double, 2 > v
Definition: Dict.h:5
FCNGradAdapter(const Function &f, double up=1.)
std::vector< double > fGrad
double Up() const
Error definition of the function.