brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · 7aabcb4 Raw
73 lines · plain
1// Copyright Nick Thompson, 20172// Copyright Matt Borland, 20243// Use, modification and distribution are subject to the4// Boost Software License, Version 1.0.5// (See accompanying file LICENSE_1_0.txt6// 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_HPP17#define BOOST_MATH_QUADRATURE_SINH_SINH_HPP18 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_NVRTC26 27#include <cmath>28#include <limits>29#include <memory>30 31namespace boost{ namespace math{ namespace quadrature {32 33template<class Real, class Policy = boost::math::policies::policy<> >34class sinh_sinh35{36public: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 46private:47    std::shared_ptr<detail::sinh_sinh_detail<Real, Policy>> m_imp;48};49 50}}}51 52#endif // BOOST_MATH_HAS_NVRTC53 54#ifdef BOOST_MATH_ENABLE_CUDA55 56namespace boost {57namespace math {58namespace quadrature {59 60template <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 quadrature67} // namespace math68} // namespace boost69 70#endif // BOOST_MATH_ENABLE_CUDA71 72#endif // BOOST_MATH_QUADRATURE_SINH_SINH_HPP73