21 #if defined(DEBUG) || defined(WARNINGMSG) 47 return (*
this)(par, gra);
55 int npar = params.size();
58 for (
int i = 0; i < npar; ++i) {
62 double fval =
Fcn()(par);
66 return (*
this)(minpars);
83 double fcnmin = par.
Fval();
89 double dfmin = 8.*eps2*(
fabs(fcnmin)+
Fcn().
Up());
90 double vrysml = 8.*eps*eps;
96 unsigned int n = (par.
Vec()).size();
97 unsigned int ncycle =
Ncycle();
108 std::cout <<
"Calculating Gradient at x = " << par.
Vec() << std::endl;
109 int pr = std::cout.precision(13);
110 std::cout <<
"fcn(x) = " << fcnmin << std::endl;
111 std::cout.precision(pr);
121 for(
unsigned int i = startElementIndex; i < endElementIndex; i++) {
131 for(
int i = 0; i < int(n); i++) {
136 int ith = omp_get_thread_num();
146 double epspri = eps2 +
fabs(grd(i)*eps2);
148 for(
unsigned int j = 0; j < ncycle; j++) {
149 double optstp =
sqrt(dfmin/(
fabs(g2(i))+epspri));
150 double step = std::max(optstp,
fabs(0.1*gstep(i)));
152 if(
Trafo().Parameter(
Trafo().ExtOfInt(i)).HasLimits()) {
153 if(step > 0.5) step = 0.5;
155 double stpmax = 10.*
fabs(gstep(i));
156 if(step > stpmax) step = stpmax;
158 double stpmin = std::max(vrysml, 8.*
fabs(eps2*
x(i)));
159 if(step < stpmin) step = stpmin;
176 double fs1 =
Fcn()(
x);
178 double fs2 =
Fcn()(
x);
181 double grdb4 = grd(i);
182 grd(i) = 0.5*(fs1 - fs2)/step;
183 g2(i) = (fs1 + fs2 - 2.*fcnmin)/step/step;
186 pr = std::cout.precision(13);
187 std::cout <<
"cycle " << j <<
" x " <<
x(i) <<
" step " << step <<
" f1 " << fs1 <<
" f2 " << fs2
188 <<
" grd " << grd(i) <<
" g2 " << g2(i) << std::endl;
189 std::cout.precision(pr);
205 std::cout <<
"Gradient for thread " << ith <<
" " << i <<
" " << std::setprecision(15) << grd(i) <<
" " << g2(i) << std::endl;
215 pr = std::cout.precision(13);
217 std::cout <<
"Parameter " <<
Trafo().
Name(iext) <<
" Gradient = " << grd(i) <<
" g2 = " << g2(i) <<
" step " << gstep(i) << std::endl;
218 std::cout.precision(pr);
229 std::cout <<
"Calculated Gradient at x = " << par.
Vec() << std::endl;
230 std::cout <<
"fcn(x) = " << fcnmin << std::endl;
231 std::cout <<
"Computed gradient in N2PGC " << grd << std::endl;
Namespace for new ROOT classes and functions.
const MnAlgebraicVector & Vec() const
double GradientTolerance() const
double Eps() const
eps returns the smallest possible number so that 1.+eps > 1.
unsigned int Ncycle() const
bool SyncVector(ROOT::Minuit2::MnAlgebraicVector &mnvector)
unsigned int GradientNCycles() const
const MnStrategy & fStrategy
unsigned int EndElementIndex() const
determines the relative floating point arithmetic precision.
const MnMachinePrecision & Precision() const
double GradientStepTolerance() const
unsigned int StartElementIndex() const
const MnAlgebraicVector & G2() const
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
const MnAlgebraicVector & Gstep() const
const MnStrategy & Strategy() const
const MnUserTransformation & fTransformation
Class to calculate an initial estimate of the gradient.
double GradTolerance() const
const MnFcn & Fcn() const
const MnUserTransformation & Trafo() const
const MnAlgebraicVector & Grad() const
double Eps2() const
eps2 returns 2*sqrt(eps)
double StepTolerance() const
virtual FunctionGradient operator()(const MinimumParameters &) const