diff --git a/example/daubechies_wavelets/bench.cpp b/example/daubechies_wavelets/bench.cpp index 797121d79..878bf1c7e 100644 --- a/example/daubechies_wavelets/bench.cpp +++ b/example/daubechies_wavelets/bench.cpp @@ -27,7 +27,7 @@ void DyadicGrid(benchmark::State & state) size_t s = 0; for (auto _ : state) { - auto v = boost::math::detail::dyadic_grid(j); + auto v = boost::math::dyadic_grid(j); benchmark::DoNotOptimize(v[0]); s = v.size(); } @@ -486,4 +486,4 @@ void CardinalSepticHermiteAOS(benchmark::State & state) BENCHMARK_TEMPLATE(CardinalSepticHermiteAOS, double)->RangeMultiplier(2)->Range(1<<8, 1<<20)->Complexity(); -BENCHMARK_MAIN(); \ No newline at end of file +BENCHMARK_MAIN(); diff --git a/example/daubechies_wavelets/daubechies_scaling_memory_occupation.cpp b/example/daubechies_wavelets/daubechies_scaling_memory_occupation.cpp index d4aeb6de6..43ae80779 100644 --- a/example/daubechies_wavelets/daubechies_scaling_memory_occupation.cpp +++ b/example/daubechies_wavelets/daubechies_scaling_memory_occupation.cpp @@ -11,9 +11,8 @@ int main() std::cout << std::right; auto daub = boost::math::daubechies_scaling(); std::cout << "The Daubechies " << std::setw(2) << i + 2 << " scaling function occupies " - << std::setw(12) << daub.bytes() << " bytes in relative accuracy mode in " + << std::setw(12) << daub.bytes()/1000.0 << " kilobytes in relative accuracy mode in " << boost::core::demangle(typeid(float).name()) << " precision\n"; - //std::cout << "Size of class = " << sizeof(daub) << "\n"; }); std::cout << std::endl; @@ -25,9 +24,8 @@ int main() std::cout << std::right; auto daub = boost::math::daubechies_scaling(-2); std::cout << "The Daubechies " << std::setw(2) << i + 2 << " scaling function occupies " - << std::setw(12) << daub.bytes() << " bytes in absolute accuracy mode in " + << std::setw(12) << daub.bytes()/1000.0 << " kilobytes in absolute accuracy mode in " << boost::core::demangle(typeid(float).name()) << " precision\n"; - //std::cout << "Size of class = " << sizeof(daub) << "\n"; }); std::cout << std::endl; @@ -40,7 +38,7 @@ int main() std::cout << std::right; auto daub = boost::math::daubechies_scaling(); std::cout << "The Daubechies " << std::setw(2) << i + 2 << " scaling function occupies " - << std::setw(12) << daub.bytes() << " bytes in relative accuracy mode in " + << std::setw(12) << daub.bytes()/1000.0 << " kilobytes in relative accuracy mode in " << boost::core::demangle(typeid(double).name()) << " precision\n"; }); @@ -53,9 +51,9 @@ int main() std::cout << std::right; auto daub = boost::math::daubechies_scaling(-2); std::cout << "The Daubechies " << std::setw(2) << i + 2 << " scaling function occupies " - << std::setw(12) << daub.bytes() << " bytes in absolute accuracy mode in " + << std::setw(12) << daub.bytes()/1000.0 << " kilobytes in absolute accuracy mode in " << boost::core::demangle(typeid(double).name()) << " precision\n"; }); -} \ No newline at end of file +} diff --git a/include/boost/math/special_functions/daubechies_scaling.hpp b/include/boost/math/special_functions/daubechies_scaling.hpp index 5061449e9..a4899c7e6 100644 --- a/include/boost/math/special_functions/daubechies_scaling.hpp +++ b/include/boost/math/special_functions/daubechies_scaling.hpp @@ -22,8 +22,6 @@ namespace boost::math { -namespace detail { - template std::vector dyadic_grid(int64_t j_max) { @@ -35,7 +33,7 @@ std::vector dyadic_grid(int64_t j_max) x *= scale; } - auto phik = daubechies_scaling_integer_grid(); + auto phik = detail::daubechies_scaling_integer_grid(); // Maximum sensible j for 32 bit floats is j_max = 22: std::vector v(2*p + (2*p-1)*((1<::quiet_NaN()); @@ -52,7 +50,7 @@ std::vector dyadic_grid(int64_t j_max) { // Where this value will go: int64_t delivery_idx = k*(1 << (j_max-j)); - // This is a nice check, but we've tested this exhaustively, and it's expensive: + // This is a nice check, but we've tested this exhaustively, and it's an expensive check: //if (delivery_idx >= (int64_t) v.size()) { // std::cerr << "Delivery index out of range!\n"; // continue; @@ -81,6 +79,8 @@ std::vector dyadic_grid(int64_t j_max) return v; } +namespace detail { + template class matched_holder { public: @@ -298,7 +298,7 @@ public: std::future> t0 = std::async(std::launch::async, [&grid_refinements]() { // Computing in higher precision and downcasting is essential for 1ULP evaluation in float precision: if constexpr (std::is_same_v) { - auto v = detail::dyadic_grid(grid_refinements); + auto v = dyadic_grid(grid_refinements); std::vector w(v.size()); for (size_t i = 0; i < v.size(); ++i) { w[i] = v[i]; @@ -306,7 +306,7 @@ public: return w; } else if constexpr (std::is_same_v) { - auto v = detail::dyadic_grid(grid_refinements); + auto v = dyadic_grid(grid_refinements); std::vector w(v.size()); for (size_t i = 0; i < v.size(); ++i) { w[i] = v[i]; @@ -314,12 +314,12 @@ public: return w; } - return detail::dyadic_grid(grid_refinements); + return dyadic_grid(grid_refinements); }); // Compute the derivative of the refined grid: std::future> t1 = std::async(std::launch::async, [&grid_refinements]() { if constexpr (std::is_same_v) { - auto v = detail::dyadic_grid(grid_refinements); + auto v = dyadic_grid(grid_refinements); std::vector w(v.size()); for (size_t i = 0; i < v.size(); ++i) { w[i] = v[i]; @@ -327,7 +327,7 @@ public: return w; } else if constexpr (std::is_same_v) { - auto v = detail::dyadic_grid(grid_refinements); + auto v = dyadic_grid(grid_refinements); std::vector w(v.size()); for (size_t i = 0; i < v.size(); ++i) { w[i] = v[i]; @@ -335,7 +335,7 @@ public: return w; } - return detail::dyadic_grid(grid_refinements); + return dyadic_grid(grid_refinements); }); // if necessary, compute the second and third derivative: @@ -345,7 +345,7 @@ public: std::future> t3 = std::async(std::launch::async, [&grid_refinements]() { if constexpr (std::is_same_v) { - auto v = detail::dyadic_grid(grid_refinements); + auto v = dyadic_grid(grid_refinements); std::vector w(v.size()); for (size_t i = 0; i < v.size(); ++i) { @@ -355,7 +355,7 @@ public: } else if constexpr (std::is_same_v) { - auto v = detail::dyadic_grid(grid_refinements); + auto v = dyadic_grid(grid_refinements); std::vector w(v.size()); for (size_t i = 0; i < v.size(); ++i) { @@ -364,14 +364,14 @@ public: return w; } - return detail::dyadic_grid(grid_refinements); + return dyadic_grid(grid_refinements); }); if constexpr (p >= 10) { std::future> t4 = std::async(std::launch::async, [&grid_refinements]() { if constexpr (std::is_same_v) { - auto v = detail::dyadic_grid(grid_refinements); + auto v = dyadic_grid(grid_refinements); std::vector w(v.size()); for (size_t i = 0; i < v.size(); ++i) { @@ -380,7 +380,7 @@ public: return w; } else if constexpr (std::is_same_v) { - auto v = detail::dyadic_grid(grid_refinements); + auto v = dyadic_grid(grid_refinements); std::vector w(v.size()); for (size_t i = 0; i < v.size(); ++i) { @@ -389,7 +389,7 @@ public: return w; } - return detail::dyadic_grid(grid_refinements); }); + return dyadic_grid(grid_refinements); }); d3ydx3 = t4.get(); } d2ydx2 = t3.get();