RSTT: util::IntegrateFunction< F > Class Template Reference

RSTT 3.1.0 Regional Seismic Travel Time

Public Member Functions | List of all members
util::IntegrateFunction< F > Class Template Reference

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...

## Detailed Description

### template<class F>
class util::IntegrateFunction< F >

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.

## Constructor & Destructor Documentation

## ◆ IntegrateFunction() [1/2]

template<class F >

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.

## ◆ IntegrateFunction() [2/2]

template<class F >

util::IntegrateFunction< F >::IntegrateFunction | ( | const IntegrateFunction< F > & | ifctn | ) |

Copy Constructor.

## ◆ ~IntegrateFunction()

template<class F >

virtual util::IntegrateFunction< F >::~IntegrateFunction | ( |  | ) |
| virtual

Destructor.

## Member Function Documentation

## ◆ getF() [1/2]

template<class F >

F & util::IntegrateFunction< F >::getF
| inline

Returns a reference to the integrated function.

Definition at line 216 of file IntegrateFunction.h.

## ◆ getF() [2/2]

template<class F >

const F & util::IntegrateFunction< F >::getF
| inline

Returns a const reference to the integrated function.

Definition at line 223 of file IntegrateFunction.h.

## ◆ getTolerance()

template<class F >

double util::IntegrateFunction< F >::getTolerance
| inline

Returns the integration tolerance value.

Definition at line 237 of file IntegrateFunction.h.

## ◆ integrateAOpenS()

template<class F >

double util::IntegrateFunction< F >::integrateAOpenS | ( | double | a,
|  | double | b
| ) |  |
| 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.

## ◆ integrateClosed()

template<class F >

double util::IntegrateFunction< F >::integrateClosed | ( | double | a,
|  | double | b
| ) |  |
| 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.

## ◆ operator=()

template<class F >

IntegrateFunction<F>& util::IntegrateFunction< F >::operator= | ( | const IntegrateFunction< F > & | ifctn | ) |

Assignment Operator.

## ◆ setTolerance()

template<class F >

void util::IntegrateFunction< F >::setTolerance | ( | double | tol | ) |
| inline

Sets the integration tolerance value.

Definition at line 230 of file IntegrateFunction.h.

The documentation for this class was generated from the following file:

- rstt/SLBM/include/IntegrateFunction.h