Logo ROOT  
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 #include "Minuit2/MnPrint.h"
15 
16 #include <vector>
17 
18 namespace ROOT {
19 
20 namespace Minuit2 {
21 
22 /**
23 
24 
25 template wrapped class for adapting to FCNBase signature a IGradFunction
26 
27 @author Lorenzo Moneta
28 
29 @ingroup Minuit
30 
31 */
32 
33 template <class Function>
35 
36 public:
37  FCNGradAdapter(const Function &f, double up = 1.) : fFunc(f), fUp(up), fGrad(std::vector<double>(fFunc.NDim())) {}
38 
40 
41  double operator()(const std::vector<double> &v) const { return fFunc.operator()(&v[0]); }
42  double operator()(const double *v) const { return fFunc.operator()(v); }
43 
44  double Up() const { return fUp; }
45 
46  std::vector<double> Gradient(const std::vector<double> &v) const
47  {
48  fFunc.Gradient(&v[0], &fGrad[0]);
49 
50  MnPrint("FCNGradAdapter").Debug([&](std::ostream &os) {
51  os << "gradient in FCNAdapter = {";
52  for (unsigned int i = 0; i < fGrad.size(); ++i)
53  os << fGrad[i] << (i == fGrad.size() - 1 ? '}' : '\t');
54  });
55  return fGrad;
56  }
57  // forward interface
58  // virtual double operator()(int npar, double* params,int iflag = 4) const;
59  bool CheckGradient() const { return false; }
60 
61 private:
62  const Function &fFunc;
63  double fUp;
64  mutable std::vector<double> fGrad;
65 };
66 
67 } // end namespace Minuit2
68 
69 } // end namespace ROOT
70 
71 #endif // ROOT_Minuit2_FCNGradAdapter
ROOT::Minuit2::FCNGradAdapter::FCNGradAdapter
FCNGradAdapter(const Function &f, double up=1.)
Definition: FCNGradAdapter.h:37
f
#define f(i)
Definition: RSha256.hxx:104
ROOT::Minuit2::MnPrint::Debug
void Debug(const Ts &... args)
Definition: MnPrint.h:138
ROOT::Minuit2::FCNGradAdapter::fUp
double fUp
Definition: FCNGradAdapter.h:63
ROOT::Minuit2::FCNGradAdapter::fFunc
const Function & fFunc
Definition: FCNGradAdapter.h:62
Function
Double_t(* Function)(Double_t)
Definition: Functor.C:4
v
@ v
Definition: rootcling_impl.cxx:3643
ROOT::Minuit2::FCNGradAdapter
template wrapped class for adapting to FCNBase signature a IGradFunction
Definition: FCNGradAdapter.h:34
ROOT::Minuit2::FCNGradAdapter::operator()
double operator()(const double *v) const
Definition: FCNGradAdapter.h:42
ROOT::Minuit2::FCNGradAdapter::Gradient
std::vector< double > Gradient(const std::vector< double > &v) const
Definition: FCNGradAdapter.h:46
ROOT::Minuit2::FCNGradAdapter::Up
double Up() const
Error definition of the function.
Definition: FCNGradAdapter.h:44
FCNGradientBase.h
ROOT::Minuit2::FCNGradAdapter::~FCNGradAdapter
~FCNGradAdapter()
Definition: FCNGradAdapter.h:39
double
double
Definition: Converters.cxx:921
ROOT::Minuit2::FCNGradAdapter::fGrad
std::vector< double > fGrad
Definition: FCNGradAdapter.h:64
ROOT::Minuit2::FCNGradientBase
Extension of the FCNBase for providing the analytical Gradient of the function.
Definition: FCNGradientBase.h:34
ROOT::Minuit2::FCNGradAdapter::operator()
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...
Definition: FCNGradAdapter.h:41
ROOT::Minuit2::FCNGradAdapter::CheckGradient
bool CheckGradient() const
Definition: FCNGradAdapter.h:59
MnPrint.h
ROOT
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition: EExecutionPolicy.hxx:4
ROOT::Minuit2::MnPrint
Definition: MnPrint.h:73