romberg_integrator< Function > Class Template Reference

#include <romberg.h>

Inheritance diagram for romberg_integrator< Function >:

iterative_method

List of all members.

Public Member Functions

 romberg_integrator (Function &f, unsigned int iterations=100, double relative_error=1.0e-15)
 ~romberg_integrator ()
double integrate (double a, double b)


Detailed Description

template<class Function>
class romberg_integrator< Function >

An implementation of Romberg Integration.

For example, to evaluate definite integrals for sine, first a Romberg integrator is created providing a target function functor:

typdef double Function(double);

num::romberg_integrator<Function> integrator(std::sin);

Then, evaluating definite integrals is accomplished using the integrate method:

// integrate sine from 0 to Pi.

double two = integrator.integrate(0.0, num::PI);

integrate sine from Pi/2 to 2 Pi.
double one = integrator.integrate(num::PI / 2.0, num::PI);

References:

  1. Eric W. Weisstein. "Romberg Integration." From MathWorld--A Wolfram Web Resource. http://mathworld.wolfram.com/RombergIntegration.html

Constructor & Destructor Documentation

template<class Function>
romberg_integrator< Function >::romberg_integrator ( Function &  f,
unsigned int  iterations = 100,
double  relative_error = 1.0e-15 
) [inline]

Create an integrator for the given function.

Parameters:
f the function functor.
iterations the maximum number of iterations.
relative_error the maximum allowable relative error.

template<class Function>
romberg_integrator< Function >::~romberg_integrator (  )  [inline]

Destructor.


Member Function Documentation

template<class Function>
double romberg_integrator< Function >::integrate ( double  a,
double  b 
) [inline]

Evaluate the definite integral from a to b.

Parameters:
a the lower limit of integration.
b the upper limit of integration.
Returns:
the definite integral from a to b.


The documentation for this class was generated from the following file:
Generated on Wed Nov 21 22:22:16 2007 for numerics4c++ by  doxygen 1.5.3