Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
Derivator.cxx
Go to the documentation of this file.
1// @(#)root/mathmore:$Id$
2// Authors: L. Moneta, A. Zsenei 08/2005
3
4 /**********************************************************************
5 * *
6 * Copyright (c) 2004 ROOT Foundation, 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 GSLDerivator
26//
27// Created by: moneta at Sat Nov 13 14:46:00 2004
28//
29// Last update: Sat Nov 13 14:46:00 2004
30//
31
32#include "Math/IFunction.h"
33#include "Math/IParamFunction.h"
34#include "Math/Derivator.h"
35#include "GSLDerivator.h"
36
38
39// for GSL greater then 1.5
40#include "gsl/gsl_deriv.h"
41// for OLD GSL versions
42//#include "gsl/gsl_diff.h"
43
44namespace ROOT {
45namespace Math {
46
49}
50
52{
53 // allocate a GSLDerivator
56}
57
59{
60 // allocate a GSLDerivator
63
64}
65
67{
68 if (fDerivator) delete fDerivator;
69}
70
71
73{
74}
75
77{
78 if (this == &rhs) return *this; // time saving self-test
79
80 return *this;
81}
82
83
86}
87
90}
91
92
93double Derivator::Eval( double x, double h) const {
94 return fDerivator->EvalCentral(x, h);
95}
96
97double Derivator::EvalCentral( double x, double h) const {
98 return fDerivator->EvalCentral(x, h);
99}
100
101double Derivator::EvalForward( double x, double h) const {
102 return fDerivator->EvalForward(x, h);
103}
104
105double Derivator::EvalBackward( double x, double h) const {
106 return fDerivator->EvalBackward(x, h);
107}
108
109// static methods
110double Derivator::Eval(const IGenFunction & f, double x, double h ) {
111 return GSLDerivator::EvalCentral(f, x, h );
112}
113
114double Derivator::EvalCentral(const IGenFunction & f, double x, double h) {
116}
117
118double Derivator::EvalForward(const IGenFunction & f, double x, double h) {
119 return GSLDerivator::EvalForward(f, x, h);
120}
121
122double Derivator::EvalBackward(const IGenFunction & f, double x, double h) {
124}
125
126double Derivator::Eval(const IMultiGenFunction & f, const double * x, unsigned int icoord, double h ) {
127 // partial derivative for a multi-dim function
129 OneDimMultiFunctionAdapter<> adapter(f,x,icoord);
130 d.SetFunction( &GSLFunctionAdapter<OneDimMultiFunctionAdapter<> >::F,static_cast<void *>(&adapter) );
131 return d.EvalCentral(x[icoord],h);
132}
133
134double Derivator::Eval(IParamFunction & f, double x, const double * p, unsigned int ipar, double h ) {
135 // derivative w.r.t parameter for a one-dim param function
137 const double xx = x;
139 d.SetFunction( &GSLFunctionAdapter<OneDimParamFunctionAdapter<IParamFunction &> >::F,static_cast<void *>(&adapter) );
140 return d.EvalCentral(p[ipar],h);
141}
142
143double Derivator::Eval(IParamMultiFunction & f, const double * x, const double * p, unsigned int ipar, double h ) {
144 // derivative w.r.t parameter for a multi-dim param function
147 d.SetFunction( &GSLFunctionAdapter<OneDimParamFunctionAdapter<IParamMultiFunction &> >::F,static_cast<void *>(&adapter) );
148 return d.EvalCentral(p[ipar],h);
149}
150
151
152double Derivator::Result() const { return fDerivator->Result(); }
153
154double Derivator::Error() const { return fDerivator->Error(); }
155
156int Derivator::Status() const { return fDerivator->Status(); }
157
158
159
160} // namespace Math
161} // namespace ROOT
#define d(i)
Definition RSha256.hxx:102
#define f(i)
Definition RSha256.hxx:104
#define h(i)
Definition RSha256.hxx:106
winID h TVirtualViewer3D TVirtualGLPainter p
Class for computing numerical derivative of a function.
Definition Derivator.h:61
void SetFunction(const IGenFunction &f)
Set the function for calculating the derivatives.
Definition Derivator.cxx:84
GSLDerivator * fDerivator
Definition Derivator.h:232
double Result() const
return the result of the last derivative calculation
virtual ~Derivator()
destructor
Definition Derivator.cxx:66
double EvalBackward(double x, double h=1E-8) const
Computes the numerical derivative at a point x using an adaptive backward difference algorithm with a...
int Status() const
return the error status of the last derivative calculation
Derivator & operator=(const Derivator &)
Definition Derivator.cxx:76
Derivator()
Empty Construct for a Derivator class Need to set the function afterwards with Derivator::SetFunction...
Definition Derivator.cxx:47
double Error() const
return the estimate of the absolute error of the last derivative calculation
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 EvalCentral(double x, double h=1E-8) const
Computes the numerical derivative at a point x using an adaptive central difference algorithm with a ...
Definition Derivator.cxx:97
double EvalForward(double x, double h=1E-8) const
Computes the numerical derivative at a point x using an adaptive forward difference algorithm with a ...
Class for computing numerical derivative of a function based on the GSL numerical algorithm This clas...
void SetFunction(const IGenFunction &f)
Set the function for calculating the derivatives.
double Result() const
return the result of the last derivative calculation
double EvalForward(double x, double h)
Computes the numerical derivative at a point x using an adaptive forward difference algorithm with a ...
double EvalCentral(double x, double h)
Computes the numerical derivative at a point x using an adaptive central difference algorithm with a ...
double Error() const
return the estimate of the absolute error of the last derivative calculation
int Status() const
return the error status of the last integral calculation
double EvalBackward(double x, double h)
Computes the numerical derivative at a point x using an adaptive backward difference algorithm with a...
Class for adapting any C++ functor class to C function pointers used by GSL.
Documentation for the abstract class IBaseFunctionMultiDim.
Definition IFunction.h:61
Interface (abstract class) for generic functions objects of one-dimension Provides a method to evalua...
Definition IFunction.h:112
Specialized IParamFunction interface (abstract class) for one-dimensional parametric functions It is ...
OneDimMultiFunctionAdapter class to wrap a multidimensional function in one dimensional one.
OneDimParamFunctionAdapter class to wrap a multi-dim parametric function in one dimensional one.
Double_t x[n]
Definition legend1.C:17
#define F(x, y, z)
Namespace for new Math classes and functions.
double(* GSLFuncPointer)(double, void *)
Function pointer corresponding to gsl_function signature.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...