Logo Search packages:      
Sourcecode: quantlib version File versions

QuantLib::TrapezoidIntegral Class Reference

#include <trapezoidintegral.hpp>

Inheritance diagram for QuantLib::TrapezoidIntegral:


List of all members.

Detailed Description

Integral of a one-dimensional function.

Given a target accuracy $ \epsilon $, the integral of a function $ f $ between $ a $ and $ b $ is calculated by means of the trapezoid formula

\[ \int_{a}^{b} f \mathrm{d}x = \frac{1}{2} f(x_{0}) + f(x_{1}) + f(x_{2}) + \dots + f(x_{N-1}) + \frac{1}{2} f(x_{N}) \]

where $ x_0 = a $, $ x_N = b $, and $ x_i = a+i \Delta x $ with $ \Delta x = (b-a)/N $. The number $ N $ of intervals is repeatedly increased until the target accuracy is reached.

the correctness of the result is tested by checking it against known good values.

Definition at line 49 of file trapezoidintegral.hpp.

Public Types

enum  Method { Default, MidPoint }

Public Member Functions

Real & accuracy ()
Real accuracy () const
Size & maxIterations ()
Size maxIterations () const
Method & method ()
Method method () const
template<class F>
Real operator() (const F &f, Real a, Real b) const
 TrapezoidIntegral (Real accuracy, Method method=Default, Size maxIterations=Null< Size >())

Protected Member Functions

template<class F>
Real defaultIteration (const F &f, Real a, Real b, Real I, Size N) const
template<class F>
Real midPointIteration (const F &f, Real a, Real b, Real I, Size N) const

Protected Attributes

Real accuracy_
Size maxIterations_
Method method_

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

Generated by  Doxygen 1.6.0   Back to index