| 1 |
// Copyright Nick Thompson, 2017 |
| 2 |
// Copyright Matt Borland, 2024 |
| 3 |
// Use, modification and distribution are subject to the |
| 4 |
// Boost Software License, Version 1.0. |
| 5 |
// (See accompanying file LICENSE_1_0.txt |
| 6 |
// or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 7 |
|
| 8 |
/* |
| 9 |
* This class performs sinh-sinh quadrature over the entire real line. |
| 10 |
* |
| 11 |
* References: |
| 12 |
* |
| 13 |
* 1) Tanaka, Ken'ichiro, et al. "Function classes for double exponential integration formulas." Numerische Mathematik 111.4 (2009): 631-655. |
| 14 |
*/ |
| 15 |
|
| 16 |
#ifndef BOOST_MATH_QUADRATURE_SINH_SINH_HPP |
| 17 |
#define BOOST_MATH_QUADRATURE_SINH_SINH_HPP |
| 18 |
|
| 19 |
#include <boost/math/tools/config.hpp> |
| 20 |
#include <boost/math/tools/precision.hpp> |
| 21 |
#include <boost/math/tools/cstdint.hpp> |
| 22 |
#include <boost/math/quadrature/detail/sinh_sinh_detail.hpp> |
| 23 |
#include <boost/math/policies/error_handling.hpp> |
| 24 |
|
| 25 |
#ifndef BOOST_MATH_HAS_NVRTC |
| 26 |
|
| 27 |
#include <cmath> |
| 28 |
#include <limits> |
| 29 |
#include <memory> |
| 30 |
|
| 31 |
namespace boost{ namespace math{ namespace quadrature { |
| 32 |
|
| 33 |
template<class Real, class Policy = boost::math::policies::policy<> > |
| 34 |
class sinh_sinh |
| 35 |
{ |
| 36 |
public: |
| 37 |
sinh_sinh(size_t max_refinements = 9) |
| 38 |
: m_imp(std::make_shared<detail::sinh_sinh_detail<Real, Policy> >(max_refinements)) {} |
| 39 |
|
| 40 |
template<class F> |
| 41 |
auto integrate(const F f, Real tol = boost::math::tools::root_epsilon<Real>(), Real* error = nullptr, Real* L1 = nullptr, std::size_t* levels = nullptr) const ->decltype(std::declval<F>()(std::declval<Real>())) |
| 42 |
{ |
| 43 |
return m_imp->integrate(f, tol, error, L1, levels); |
| 44 |
} |
| 45 |
|
| 46 |
private: |
| 47 |
std::shared_ptr<detail::sinh_sinh_detail<Real, Policy>> m_imp; |
| 48 |
}; |
| 49 |
|
| 50 |
}}} |
| 51 |
|
| 52 |
#endif // BOOST_MATH_HAS_NVRTC |
| 53 |
|
| 54 |
#ifdef BOOST_MATH_ENABLE_CUDA |
| 55 |
|
| 56 |
namespace boost { |
| 57 |
namespace math { |
| 58 |
namespace quadrature { |
| 59 |
|
| 60 |
template <class F, class Real, class Policy = boost::math::policies::policy<> > |
| 61 |
__device__ auto sinh_sinh_integrate(const F& f, Real tol = boost::math::tools::root_epsilon<Real>(), Real* error = nullptr, Real* L1 = nullptr, boost::math::size_t* levels = nullptr) |
| 62 |
{ |
| 63 |
return detail::sinh_sinh_integrate_impl(f, tol, error, L1, levels); |
| 64 |
} |
| 65 |
|
| 66 |
} // namespace quadrature |
| 67 |
} // namespace math |
| 68 |
} // namespace boost |
| 69 |
|
| 70 |
#endif // BOOST_MATH_ENABLE_CUDA |
| 71 |
|
| 72 |
#endif // BOOST_MATH_QUADRATURE_SINH_SINH_HPP |