23#ifndef quantlib_tanh_sinh_integral_hpp
24#define quantlib_tanh_sinh_integral_hpp
30#if BOOST_VERSION >= 106900
31#define QL_BOOST_HAS_TANH_SINH
33#include <boost/math/quadrature/tanh_sinh.hpp>
41 class TanhSinhIntegral :
public Integrator {
44 Real relTolerance = std::sqrt(std::numeric_limits<Real>::epsilon()),
45 Size maxRefinements = 15,
46 Real minComplement = std::numeric_limits<Real>::min() * 4
49 relTolerance_(relTolerance),
50 tanh_sinh_(maxRefinements, minComplement) {}
56 Real value = tanh_sinh_.integrate(
61 a,
b, relTolerance_, &error);
68 const Real relTolerance_;
69 mutable boost::math::quadrature::tanh_sinh<Real> tanh_sinh_;
81 QL_FAIL(
"boost version 1.69 or higher is required in order to use TanhSinhIntegral");
86 QL_FAIL(
"boost version 1.69 or higher is required in order to use TanhSinhIntegral");
Integrator(Real absoluteAccuracy, Size maxEvaluations)
void increaseNumberOfEvaluations(Size increase) const
void setAbsoluteError(Real error) const
template class providing a null value for a given type.
TanhSinhIntegral(Real relTolerance=0, Size maxRefinements=0, Real minComplement=0)
Real integrate(const ext::function< Real(Real)> &f, Real a, Real b) const override
#define QL_FAIL(message)
throw an error (possibly with file and line information)
ext::function< Real(Real)> b
std::size_t Size
size of a container
Integrators base class definition.