Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
18namespace ROOT {
19
20namespace Minuit2 {
21
22/**
23
24
25template wrapped class for adapting to FCNBase signature a IGradFunction
26
27@author Lorenzo Moneta
28
29@ingroup Minuit
30
31*/
32
33template <class Function>
35
36public:
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
61private:
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
double
#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.
void Debug(const Ts &... args)
Definition MnPrint.h:138
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...