#include <romberg.h>
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) |
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:
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.
f | the function functor. | |
iterations | the maximum number of iterations. | |
relative_error | the maximum allowable relative error. |
romberg_integrator< Function >::~romberg_integrator | ( | ) | [inline] |
Destructor.
double romberg_integrator< Function >::integrate | ( | double | a, | |
double | b | |||
) | [inline] |
Evaluate the definite integral from a
to b
.
a | the lower limit of integration. | |
b | the upper limit of integration. |
a
to b
.