RSTT
3.2.0
Regional Seismic Travel Time
|
Class supports numerical integration of an arbitrary function using a fourth order Simpsons rule for closed intervals. Open intervals at one end-point are handled by using Simpsons rule in a segmented sense to approach the unbounded limit in successive iterations each time dividing the difference to the unbounded limit by 10.0. More...
#include <IntegrateFunction.h>
Public Member Functions | |
IntegrateFunction (F &f, double tol) | |
Standard Constructor. More... | |
IntegrateFunction (const IntegrateFunction< F > &ifctn) | |
Copy Constructor. More... | |
virtual | ~IntegrateFunction () |
Destructor. More... | |
IntegrateFunction< F > & | operator= (const IntegrateFunction< F > &ifctn) |
Assignment Operator. More... | |
double | integrateClosed (double a, double b) |
Adaptive closed form numerical integration of the input function over the closed interval a to b. The function is assumed to be defined over the entire interval [a, b]. The function uses the 3 point Simpsons rule to evaluate all sub-intervals. More... | |
double | integrateAOpenS (double a, double b) |
Adaptive closed form numerical integration of the input function over the open interval a to b, where the integrand function is undefined at a. The function uses the 3 point Simpsons rule to evaluate all sub-intervals. and slowly encroaches on the limit a until convergence is attained. More... | |
F & | getF () |
Returns a reference to the integrated function. More... | |
const F & | getF () const |
Returns a const reference to the integrated function. More... | |
void | setTolerance (double tol) |
Sets the integration tolerance value. More... | |
double | getTolerance () const |
Returns the integration tolerance value. More... | |
Class supports numerical integration of an arbitrary function using a fourth order Simpsons rule for closed intervals. Open intervals at one end-point are handled by using Simpsons rule in a segmented sense to approach the unbounded limit in successive iterations each time dividing the difference to the unbounded limit by 10.0.
This object must be instantiated with the function to be integrated. A tolerance may be provided at instantiation or reset to another value at a later time. Both the function to be integrated and the tolerance can be accessed with predefined "get" functions.
The integration functions are integrateClosed(...) and integrateAOpen(...) defined below. The function integrateClosed(...) is a recursively adaptive function that resolves the interval into one or more sub-intervals until the convergence tolerance is met. Unlike their non-adaptive counterparts these functions resolve each region of the function to whatever resolution is required to meet the accuracy requirement. The open interval version uses the closed interval definition for all internal sub-intervals. The closed interval simpson rule is defined by
(h/3)(f0 + 4*f1 + f2)
where h is the interval width, f0 is the function to be integrated defined at the left most range, f2 is defined at the right most range, and f1 is defined at the mid-point of the range.
The simpsons adaptive integration evalutes the integral across a sub- interval range using the rule 3 times, once across the sub-interval, once across the 1st half of the sub-interval and once across the second half of the sub-interval. The split halves are summed to form one result while the entire interval evaluation forms the other. The former has an accuracy that is about 4 times greater than the entire interval evaluation. Convergence is attained when the difference between the two is less than the input tolerance. Five function evaluation are required for each call to the closed form Simpson rule.
The function integrateAOpen(...) solves an improper integral containing an unbounded integrand at the initial limit a (of a,b). This function uses the closed form Simpsons solution to solve the integral from a+e to b where e is some non-zero small number. Then it solves the integral a+e/10 to a+e in a series of consecutive iterations where e is reduced by 10 at each iteration. The results of each solution are summed with the first solution to obtain the final result. The iterations are continued until convergence occurs or an unbounded result terminates the solution with an accuracy less than that which was requested.
Definition at line 112 of file IntegrateFunction.h.
util::IntegrateFunction< F >::IntegrateFunction | ( | F & | f, |
double | tol | ||
) |
Standard Constructor.
Since IntegrateFunction requires a reference assignment for the function F& ifF, the default constructor is not supported.
util::IntegrateFunction< F >::IntegrateFunction | ( | const IntegrateFunction< F > & | ifctn | ) |
Copy Constructor.
|
virtual |
Destructor.
|
inline |
Returns a reference to the integrated function.
Definition at line 216 of file IntegrateFunction.h.
|
inline |
Returns a const reference to the integrated function.
Definition at line 223 of file IntegrateFunction.h.
|
inline |
Returns the integration tolerance value.
Definition at line 237 of file IntegrateFunction.h.
|
inline |
Adaptive closed form numerical integration of the input function over the open interval a to b, where the integrand function is undefined at a. The function uses the 3 point Simpsons rule to evaluate all sub-intervals. and slowly encroaches on the limit a until convergence is attained.
Definition at line 263 of file IntegrateFunction.h.
|
inline |
Adaptive closed form numerical integration of the input function over the closed interval a to b. The function is assumed to be defined over the entire interval [a, b]. The function uses the 3 point Simpsons rule to evaluate all sub-intervals.
Definition at line 247 of file IntegrateFunction.h.
IntegrateFunction<F>& util::IntegrateFunction< F >::operator= | ( | const IntegrateFunction< F > & | ifctn | ) |
Assignment Operator.
|
inline |
Sets the integration tolerance value.
Definition at line 230 of file IntegrateFunction.h.