Logo ROOT  
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 
22 {
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);
31  if (fTransformation.Parameter(ext).HasLimits()) {
32  // double dd = (fTransformation.Parameter(ext).Upper() -
33  // fTransformation.Parameter(ext).Lower())*0.5*cos(par.Vec()(i));
34  // const ParameterTransformation * pt = fTransformation.transformation(ext);
35  // double dd = pt->dInt2ext(par.Vec()(i), fTransformation.Parameter(ext).Lower(),
36  // fTransformation.Parameter(ext).Upper() );
37  double dd = fTransformation.DInt2Ext(i, par.Vec()(i));
38  v(i) = dd * grad[ext];
39  } else {
40  v(i) = grad[ext];
41  }
42  }
43 
44  MnPrint print("AnalyticalGradientCalculator");
45  print.Debug("User given gradient in Minuit2", v);
46 
47  return FunctionGradient(v);
48 }
49 
51 {
52  // needed from base class
53  return (*this)(par);
54 }
55 
57 {
58  // check to be sure FCN implements analytical gradient
59  return fGradCalc.CheckGradient();
60 }
61 
62 } // namespace Minuit2
63 
64 } // namespace ROOT
ROOT::Minuit2::AnalyticalGradientCalculator::fGradCalc
const FCNGradientBase & fGradCalc
Definition: AnalyticalGradientCalculator.h:39
ROOT::Minuit2::LAVector
Definition: LAVector.h:32
ROOT::Minuit2::MnPrint::Debug
void Debug(const Ts &... args)
Definition: MnPrint.h:138
ROOT::Minuit2::AnalyticalGradientCalculator::CheckGradient
virtual bool CheckGradient() const
Definition: AnalyticalGradientCalculator.cxx:56
ROOT::Minuit2::MnUserTransformation::Parameters
const std::vector< MinuitParameter > & Parameters() const
Definition: MnUserTransformation.h:108
MnUserTransformation.h
ROOT::Minuit2::MinimumParameters::Vec
const MnAlgebraicVector & Vec() const
Definition: MinimumParameters.h:38
MnMatrix.h
ROOT::Minuit2::FunctionGradient
Definition: FunctionGradient.h:21
v
@ v
Definition: rootcling_impl.cxx:3643
ROOT::Minuit2::FCNGradientBase::CheckGradient
virtual bool CheckGradient() const
Definition: FCNGradientBase.h:41
ROOT::Minuit2::AnalyticalGradientCalculator::operator()
virtual FunctionGradient operator()(const MinimumParameters &) const
Definition: AnalyticalGradientCalculator.cxx:21
ROOT::Minuit2::MinimumParameters
Definition: MinimumParameters.h:21
FunctionGradient.h
FCNGradientBase.h
ROOT::Minuit2::AnalyticalGradientCalculator::fTransformation
const MnUserTransformation & fTransformation
Definition: AnalyticalGradientCalculator.h:40
ROOT::Minuit2::FCNGradientBase::Gradient
virtual std::vector< double > Gradient(const std::vector< double > &) const =0
ROOT::Minuit2::MnUserTransformation::Parameter
const MinuitParameter & Parameter(unsigned int) const
Definition: MnUserTransformation.cxx:263
ROOT::Minuit2::MinuitParameter::HasLimits
bool HasLimits() const
Definition: MinuitParameter.h:154
AnalyticalGradientCalculator.h
ROOT::Minuit2::LAVector::size
unsigned int size() const
Definition: LAVector.h:227
ROOT::Minuit2::MnUserTransformation::DInt2Ext
double DInt2Ext(unsigned int, double) const
Definition: MnUserTransformation.cxx:190
MinimumParameters.h
MnPrint.h
ROOT::Minuit2::MnUserTransformation::ExtOfInt
unsigned int ExtOfInt(unsigned int internal) const
Definition: MnUserTransformation.h:102
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