Logo ROOT   6.14/05
Reference Guide
AnalyticalGradientCalculator.cxx
Go to the documentation of this file.
1 // @(#)root/minuit2:$Id$
2 // Authors: M. Winkler, F. James, L. Moneta, A. Zsenei 2003-2005
3 
4 /**********************************************************************
5  * *
6  * Copyright (c) 2005 LCG ROOT Math team, CERN/PH-SFT *
7  * *
8  **********************************************************************/
9 
15 #include "Minuit2/MnMatrix.h"
16 #include "Minuit2/MnPrint.h"
17 
18 namespace ROOT {
19  namespace Minuit2 {
20 
21 
23  // evaluate analytical gradient. take care of parameter transformations
24 
25  std::vector<double> grad = fGradCalc.Gradient(fTransformation(par.Vec()));
26  assert(grad.size() == fTransformation.Parameters().size());
27 
28  MnAlgebraicVector v(par.Vec().size());
29  for(unsigned int i = 0; i < par.Vec().size(); i++) {
30  unsigned int ext = fTransformation.ExtOfInt(i);
32  //double dd = (fTransformation.Parameter(ext).Upper() - fTransformation.Parameter(ext).Lower())*0.5*cos(par.Vec()(i));
33  // const ParameterTransformation * pt = fTransformation.transformation(ext);
34  // double dd = pt->dInt2ext(par.Vec()(i), fTransformation.Parameter(ext).Lower(), fTransformation.Parameter(ext).Upper() );
35  double dd = fTransformation.DInt2Ext(i, par.Vec()(i));
36  v(i) = dd*grad[ext];
37  } else {
38  v(i) = grad[ext];
39  }
40  }
41 #ifdef DEBUG
42  std::cout << "User given gradient in Minuit2" << v << std::endl;
43 #endif
44 
45  return FunctionGradient(v);
46 }
47 
49  // needed from base class
50  return (*this)(par);
51 }
52 
54  // check to be sure FCN implements analytical gradient
55  return fGradCalc.CheckGradient();
56 }
57 
58  } // namespace Minuit2
59 
60 } // namespace ROOT
virtual bool CheckGradient() const
virtual std::vector< double > Gradient(const std::vector< double > &) const =0
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
const MnAlgebraicVector & Vec() const
double DInt2Ext(unsigned int, double) const
unsigned int ExtOfInt(unsigned int internal) const
SVector< double, 2 > v
Definition: Dict.h:5
unsigned int size() const
Definition: LAVector.h:198
const std::vector< MinuitParameter > & Parameters() const
virtual FunctionGradient operator()(const MinimumParameters &) const
const MinuitParameter & Parameter(unsigned int) const