Integrate drop-in function-wrapper
-
template<typename UnaryRealFunction_>
inline integrator::return_type integratecpp::integrate(UnaryRealFunction_ &&fn, const double lower, const double upper, const integrator::config_type config = {}) A drop-in replacement of
integratecpp::integrator
for numerical integration. Approximates an integral numerically for a functor, lower, and upper bound, usingRdqags
if both bounds are are finite andRdqagi
of at least one of the bounds is infinite.- Template Parameters:
UnaryRealFunction_ – A
Callable
type invocable withconst double
and returningdouble
.- Parameters:
fn – a
UnaryRealFunction_
functor compatible with aconst double
signature.lower – a
double
for the lower bound.upper – a
double
for the upper bound.config – an optional
const
reference to aintegratecpp::integrator::config_type
configuration parameter.
- Throws:
throws – integratecpp::invalid_input_error if configuration parameters’ preconditions are not fulfilled.
throws – integratecpp::max_subdivision_error if the maximal number of subdivisions is reached without fulfilling required error conditions.
throws – integratecpp::roundoff_error if a roundoff error is detected which prevents the requested accuracy from being achieved.
throws – integratecpp::bad_integrand_error if extremely bad integrand behaviour is detected during integration.
throws – integratecpp::extrapolation_roundoff_error if a roundoff error is detected in the extrapolation table.
throws – integratecpp::divergence_error if the integral is deemed divergence (or slowly convergent).
throws – integratecpp::integration_runtime_error if the
Callable
returns infinite values.rethrows – caught exceptions that occur during the evaluation of the
Callable
.
- Returns:
a
integratecpp::integrator::return_type
with the integration results.