Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:39:58

0001 /*
0002  * Copyright Nick Thompson, 2020
0003  * Use, modification and distribution are subject to the
0004  * Boost Software License, Version 1.0. (See accompanying file
0005  * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006  */
0007 #ifndef BOOST_MATH_QUADRATURE_WAVELET_TRANSFORMS_HPP
0008 #define BOOST_MATH_QUADRATURE_WAVELET_TRANSFORMS_HPP
0009 #include <boost/math/special_functions/daubechies_wavelet.hpp>
0010 #include <boost/math/quadrature/trapezoidal.hpp>
0011 
0012 namespace boost::math::quadrature {
0013 
0014 template<class F, typename Real, int p>
0015 class daubechies_wavelet_transform
0016 {
0017 public:
0018     daubechies_wavelet_transform(F f, int grid_refinements = -1, Real tol = 100*std::numeric_limits<Real>::epsilon(),
0019     int max_refinements = 12) : f_{f}, psi_(grid_refinements), tol_{tol}, max_refinements_{max_refinements}
0020     {}
0021 
0022     daubechies_wavelet_transform(F f, boost::math::daubechies_wavelet<Real, p> wavelet, Real tol = 100*std::numeric_limits<Real>::epsilon(),
0023     int max_refinements = 12) : f_{f}, psi_{wavelet}, tol_{tol}, max_refinements_{max_refinements}
0024     {}
0025 
0026     auto operator()(Real s, Real t) const ->decltype(std::declval<F>()(std::declval<Real>()))
0027     {
0028         using std::sqrt;
0029         using std::abs;
0030         using boost::math::quadrature::trapezoidal;
0031         auto g = [&] (Real u) {
0032             return f_(s*u+t)*psi_(u);
0033         };
0034         auto [a,b] = psi_.support();
0035         return sqrt(abs(s))*trapezoidal(g, a, b, tol_, max_refinements_);
0036     }
0037 
0038 private:
0039     F f_;
0040     boost::math::daubechies_wavelet<Real, p> psi_;
0041     Real tol_;
0042     int max_refinements_;
0043 };
0044 
0045 
0046 }
0047 #endif