Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
MultiNumGradFunction.cxx
Go to the documentation of this file.
1// @(#)root/mathmore:$Id$
2// Author: L. Moneta Wed Dec 20 14:36:31 2006
3
4/**********************************************************************
5 * *
6 * Copyright (c) 2006 LCG ROOT Math Team, CERN/PH-SFT *
7 * *
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU General Public License *
10 * as published by the Free Software Foundation; either version 2 *
11 * of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU General Public License *
19 * along with this library (see file COPYING); if not, write *
20 * to the Free Software Foundation, Inc., 59 Temple Place, Suite *
21 * 330, Boston, MA 02111-1307 USA, or contact the author. *
22 * *
23 **********************************************************************/
24
25// implementation file for class MultiNumGradFunction
26
28#include <limits>
29#include <cmath>
30#include <algorithm> // needed for std::max on Solaris
31
32#include "Math/Derivator.h"
33
34
35namespace ROOT {
36
37 namespace Math {
38
39
40double MultiNumGradFunction::fgEps = 0.001;
41
42double MultiNumGradFunction::DoDerivative (const double * x, unsigned int icoord ) const {
43 // calculate derivative using mathcore derivator class
44 // step size can be changes using SetDerivPrecision()
45
46 static double kPrecision = std::sqrt ( std::numeric_limits<double>::epsilon() );
47 double x0 = std::abs(x[icoord]);
48 //double step = (x0 > 0) ? kPrecision * x0 : kPrecision;
49 // this seems to work better than above
50 double step = (x0>0) ? std::max( fgEps* x0, 8.0*kPrecision*(x0 + kPrecision) ) : kPrecision;
51 return ROOT::Math::Derivator::Eval(*fFunc, x, icoord, step);
52}
53
55
57
58
59 } // end namespace Math
60
61} // end namespace ROOT
double Eval(double x, double h=1E-8) const
Computes the numerical derivative of a function f at a point x.
Definition Derivator.cxx:93
double DoDerivative(const double *x, unsigned int icoord) const
static void SetDerivPrecision(double eps)
precision value used for calculating the derivative step-size h = eps * |x|.
static double GetDerivPrecision()
get precision value used for calculating the derivative step-size
Double_t x[n]
Definition legend1.C:17
Namespace for new Math classes and functions.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...