From dfb3bf1d632a23a3c577439625fe88e6d2a647bd Mon Sep 17 00:00:00 2001 From: Nick Date: Sun, 26 Apr 2020 09:37:03 -0400 Subject: [PATCH] Daubechies scaling plots should use ulps_plots from boost. --- example/daubechies_wavelets/bench.cpp | 2 +- ...plots.cpp => daubechies_scaling_plots.cpp} | 25 ++++++++++--------- 2 files changed, 14 insertions(+), 13 deletions(-) rename example/daubechies_wavelets/{daubechies_plots.cpp => daubechies_scaling_plots.cpp} (90%) diff --git a/example/daubechies_wavelets/bench.cpp b/example/daubechies_wavelets/bench.cpp index db2846130..e3928006c 100644 --- a/example/daubechies_wavelets/bench.cpp +++ b/example/daubechies_wavelets/bench.cpp @@ -379,7 +379,7 @@ void SepticHermite(benchmark::State & state) boost::random::uniform_real_distribution dis(Real(0), Real(1)); Real x0 = dis(rd); x[0] = x0; - for (size_t i = 1; i < n; ++i) + for (decltype(n) i = 1; i < n; ++i) { x[i] = x[i-1] + dis(rd); } diff --git a/example/daubechies_wavelets/daubechies_plots.cpp b/example/daubechies_wavelets/daubechies_scaling_plots.cpp similarity index 90% rename from example/daubechies_wavelets/daubechies_plots.cpp rename to example/daubechies_wavelets/daubechies_scaling_plots.cpp index 3c4e81936..d4ef5fde2 100644 --- a/example/daubechies_wavelets/daubechies_plots.cpp +++ b/example/daubechies_wavelets/daubechies_scaling_plots.cpp @@ -11,12 +11,12 @@ #include #include -#include +#include #include using boost::multiprecision::float128; -constexpr const int GRAPH_WIDTH = 700; +constexpr const int GRAPH_WIDTH = 300; template void plot_phi(int grid_refinements = -1) @@ -71,7 +71,7 @@ void plot_convergence() title = ""; std::string filename = "daubechies_" + std::to_string(p) + "_scaling_convergence.svg"; - quicksvg::graph_fn daub(a, b, title, filename, 1024, GRAPH_WIDTH); + quicksvg::graph_fn daub(a, b, title, filename, 1024, 900); daub.set_stroke_width(1); daub.set_gridlines(8, 2*p-1); @@ -135,16 +135,17 @@ void do_ulp(int coarse_refinements, PhiPrecise phi_precise) title = ""; std::string filename = "daubechies_" + std::to_string(p) + "_" + boost::core::demangle(typeid(CoarseReal).name()) + "_" + std::to_string(coarse_refinements) + "_refinements.svg"; - int samples = 1000000; - int clip = 20; + int samples = 20000; + int clip = 10; int horizontal_lines = 8; int vertical_lines = 2*p - 1; auto [a, b] = phi_coarse.support(); - auto plot = boost::math::tools::ulp_plot(phi_precise, a, b, samples); - plot.set_clip(clip); - plot.set_width(GRAPH_WIDTH); + auto plot = boost::math::tools::ulps_plot(phi_precise, a, b, samples); + plot.clip(clip).width(GRAPH_WIDTH).horizontal_lines(horizontal_lines).vertical_lines(vertical_lines).ulp_envelope(false); + + plot.background_color("white").font_color("black"); plot.add_fn(phi_coarse); - plot.write(filename, true, title, horizontal_lines, vertical_lines); + plot.write(filename); } @@ -156,9 +157,9 @@ int main() boost::hana::for_each(std::make_index_sequence<18>(), [&](auto i){ plot_convergence(); }); using PreciseReal = float128; - using CoarseReal = float; - int precise_refinements = 22; - constexpr const int p = 14; + using CoarseReal = double; + int precise_refinements = 23; + constexpr const int p = 8; std::cout << "Computing precise scaling function in " << boost::core::demangle(typeid(PreciseReal).name()) << " precision.\n"; auto phi_precise = boost::math::daubechies_scaling(precise_refinements); std::cout << "Beginning comparison with functions computed in " << boost::core::demangle(typeid(CoarseReal).name()) << " precision.\n";