ROOT
6.30.04
Reference Guide
All
Namespaces
Files
Pages
GSLDerivator.h
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
// Header file for class Derivator
26
//
27
// class for calculating Derivative of functions
28
//
29
// Created by: moneta at Sat Nov 13 14:46:00 2004
30
//
31
// Last update: Sat Nov 13 14:46:00 2004
32
//
33
#ifndef ROOT_Math_GSLDerivator
34
#define ROOT_Math_GSLDerivator
35
36
/**
37
@defgroup Deriv Numerical Differentiation
38
*/
39
40
#include "
Math/GSLFunctionAdapter.h
"
41
#include "
GSLFunctionWrapper.h
"
42
43
44
#include "
Math/IFunctionfwd.h
"
45
#include "
Math/IFunction.h
"
46
47
namespace
ROOT {
48
namespace
Math {
49
50
51
class
GSLFunctionWrapper;
52
53
54
/**
55
Class for computing numerical derivative of a function based on the GSL numerical algorithm
56
This class is implemented using the numerical derivatives algorithms provided by GSL
57
(see <A HREF="http://www.gnu.org/software/gsl/manual/html_node/Numerical-Differentiation.html">GSL Online Manual</A> ).
58
59
@ingroup Deriv
60
*/
61
62
class
GSLDerivator {
63
64
public
:
65
/**
66
Default Constructor of a GSLDerivator class based on GSL numerical differentiation algorithms
67
*/
68
GSLDerivator() : fStatus(0), fResult(0), fError(0) {}
69
70
/// destructor (no operations)
71
virtual
~GSLDerivator() {}
72
73
// // disable copying
74
// private:
75
76
// GSLDerivator(const GSLDerivator &);
77
// GSLDerivator & operator = (const GSLDerivator &);
78
79
// public:
80
81
82
83
/**
84
Set the function for calculating the derivatives.
85
The function must implement the ROOT::Math::IGenFunction signature
86
*/
87
void
SetFunction(
const
IGenFunction &f);
88
89
/**
90
Set the function f for evaluating the derivative using a GSL function pointer type
91
@param f : free function pointer of the GSL required type
92
@param p : pointer to the object carrying the function state
93
(for example the function object itself)
94
*/
95
void
SetFunction( GSLFuncPointer f,
void
* p = 0);
96
97
/**
98
Computes the numerical derivative at a point x using an adaptive central
99
difference algorithm with a step size h.
100
*/
101
double
EvalCentral(
double
x,
double
h);
102
103
/**
104
Computes the numerical derivative at a point x using an adaptive forward
105
difference algorithm with a step size h.
106
The function is evaluated only at points greater than x and at x itself.
107
*/
108
double
EvalForward(
double
x,
double
h);
109
110
/**
111
Computes the numerical derivative at a point x using an adaptive backward
112
difference algorithm with a step size h.
113
The function is evaluated only at points less than x and at x itself.
114
*/
115
double
EvalBackward(
double
x,
double
h);
116
117
/** @name --- Static methods --- **/
118
119
/**
120
Computes the numerical derivative of a function f at a point x using an adaptive central
121
difference algorithm with a step size h
122
*/
123
static
double
EvalCentral(
const
IGenFunction & f,
double
x,
double
h);
124
125
126
/**
127
Computes the numerical derivative of a function f at a point x using an adaptive forward
128
difference algorithm with a step size h.
129
The function is evaluated only at points greater than x and at x itself
130
*/
131
static
double
EvalForward(
const
IGenFunction & f,
double
x,
double
h);
132
133
/**
134
Computes the numerical derivative of a function f at a point x using an adaptive backward
135
difference algorithm with a step size h.
136
The function is evaluated only at points less than x and at x itself
137
*/
138
139
static
double
EvalBackward(
const
IGenFunction & f,
double
x,
double
h);
140
141
142
143
/**
144
return the error status of the last integral calculation
145
*/
146
int
Status()
const
;
147
148
/**
149
return the result of the last derivative calculation
150
*/
151
double
Result()
const
;
152
153
/**
154
return the estimate of the absolute error of the last derivative calculation
155
*/
156
double
Error()
const
;
157
158
159
private
:
160
161
int
fStatus;
162
double
fResult;
163
double
fError;
164
165
GSLFunctionWrapper fFunction;
166
167
};
168
169
170
171
172
}
// namespace Math
173
}
// namespace ROOT
174
175
176
#endif
/* ROOT_Math_GSLDerivator */
GSLFunctionAdapter.h
IFunctionfwd.h
GSLFunctionWrapper.h
IFunction.h
math
mathmore
src
GSLDerivator.h
Generated on Tue May 5 2020 14:03:03 for ROOT by
1.8.5