2
0
mirror of https://github.com/boostorg/math.git synced 2026-01-19 04:22:09 +00:00

Daubechies scaling plots should use ulps_plots from boost.

This commit is contained in:
Nick
2020-04-26 09:37:03 -04:00
committed by GitHub
parent 47e61a447c
commit dfb3bf1d63
2 changed files with 14 additions and 13 deletions

View File

@@ -379,7 +379,7 @@ void SepticHermite(benchmark::State & state)
boost::random::uniform_real_distribution<Real> 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);
}

View File

@@ -11,12 +11,12 @@
#include <boost/multiprecision/float128.hpp>
#include <boost/math/special_functions/daubechies_scaling.hpp>
#include <boost/math/tools/ulp_plot.hpp>
#include <boost/math/tools/ulps_plot.hpp>
#include <quicksvg/graph_fn.hpp>
using boost::multiprecision::float128;
constexpr const int GRAPH_WIDTH = 700;
constexpr const int GRAPH_WIDTH = 300;
template<typename Real, int p>
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<decltype(phi_precise), PreciseReal, CoarseReal>(phi_precise, a, b, samples);
plot.set_clip(clip);
plot.set_width(GRAPH_WIDTH);
auto plot = boost::math::tools::ulps_plot<decltype(phi_precise), PreciseReal, CoarseReal>(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<double, i+2>(); });
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<PreciseReal, p>(precise_refinements);
std::cout << "Beginning comparison with functions computed in " << boost::core::demangle(typeid(CoarseReal).name()) << " precision.\n";