ooura_fourier_integrals.hpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Copyright Nick Thompson, 2019
  2. // Use, modification and distribution are subject to the
  3. // Boost Software License, Version 1.0.
  4. // (See accompanying file LICENSE_1_0.txt
  5. // or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. /*
  7. * References:
  8. * Ooura, Takuya, and Masatake Mori. "A robust double exponential formula for Fourier-type integrals." Journal of computational and applied mathematics 112.1-2 (1999): 229-241.
  9. * http://www.kurims.kyoto-u.ac.jp/~ooura/intde.html
  10. */
  11. #ifndef BOOST_MATH_QUADRATURE_OOURA_FOURIER_INTEGRALS_HPP
  12. #define BOOST_MATH_QUADRATURE_OOURA_FOURIER_INTEGRALS_HPP
  13. #include <memory>
  14. #include <boost/math/quadrature/detail/ooura_fourier_integrals_detail.hpp>
  15. namespace boost { namespace math { namespace quadrature {
  16. template<class Real>
  17. class ooura_fourier_sin {
  18. public:
  19. ooura_fourier_sin(const Real relative_error_tolerance = tools::root_epsilon<Real>(), size_t levels = sizeof(Real)) : impl_(std::make_shared<detail::ooura_fourier_sin_detail<Real>>(relative_error_tolerance, levels))
  20. {}
  21. template<class F>
  22. std::pair<Real, Real> integrate(F const & f, Real omega) {
  23. return impl_->integrate(f, omega);
  24. }
  25. // These are just for debugging/unit tests:
  26. std::vector<std::vector<Real>> const & big_nodes() const {
  27. return impl_->big_nodes();
  28. }
  29. std::vector<std::vector<Real>> const & weights_for_big_nodes() const {
  30. return impl_->weights_for_big_nodes();
  31. }
  32. std::vector<std::vector<Real>> const & little_nodes() const {
  33. return impl_->little_nodes();
  34. }
  35. std::vector<std::vector<Real>> const & weights_for_little_nodes() const {
  36. return impl_->weights_for_little_nodes();
  37. }
  38. private:
  39. std::shared_ptr<detail::ooura_fourier_sin_detail<Real>> impl_;
  40. };
  41. template<class Real>
  42. class ooura_fourier_cos {
  43. public:
  44. ooura_fourier_cos(const Real relative_error_tolerance = tools::root_epsilon<Real>(), size_t levels = sizeof(Real)) : impl_(std::make_shared<detail::ooura_fourier_cos_detail<Real>>(relative_error_tolerance, levels))
  45. {}
  46. template<class F>
  47. std::pair<Real, Real> integrate(F const & f, Real omega) {
  48. return impl_->integrate(f, omega);
  49. }
  50. private:
  51. std::shared_ptr<detail::ooura_fourier_cos_detail<Real>> impl_;
  52. };
  53. }}}
  54. #endif