]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/multiprecision/plots/cpp_bin_float_erf_errors.cpp
2 // (C) Copyright Nick Thompson 2020.
3 // (C) Copyright John Maddock 2020.
4 // Use, modification and distribution are subject to the
5 // Boost Software License, Version 1.0. (See accompanying file
6 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 #include <boost/math/tools/ulps_plot.hpp>
9 #include <boost/core/demangle.hpp>
10 #include <boost/multiprecision/mpfr.hpp>
11 #include <boost/multiprecision/cpp_bin_float.hpp>
13 using boost::math::tools::ulps_plot
;
16 using PreciseReal
= boost::multiprecision::mpfr_float_100
;
17 using CoarseReal
= boost::multiprecision::cpp_bin_float_50
;
19 typedef boost::math::policies::policy
<
20 boost::math::policies::promote_float
<false>,
21 boost::math::policies::promote_double
<false> >
24 auto ai_coarse
= [](CoarseReal
const& x
)->CoarseReal
{
27 auto ai_precise
= [](PreciseReal
const& x
)->PreciseReal
{
31 std::string filename
= "cpp_bin_float_erf.svg";
33 // How many pixels wide do you want your .svg?
35 // Near a root, we have unbounded relative error. So for functions with roots, we define an ULP clip:
36 PreciseReal clip
= 40;
37 // Should we perturb the abscissas?
38 bool perturb_abscissas
= false;
39 auto plot
= ulps_plot
<decltype(ai_precise
), PreciseReal
, CoarseReal
>(ai_precise
, CoarseReal(-10), CoarseReal(10), samples
, perturb_abscissas
);
40 // Note the argument chaining:
41 plot
.clip(clip
).width(width
);
42 plot
.background_color("white").font_color("black");
43 // Sometimes it's useful to set a title, but in many cases it's more useful to just use a caption.
44 //std::string title = "Airy Ai ULP plot at " + boost::core::demangle(typeid(CoarseReal).name()) + " precision";
46 plot
.vertical_lines(6);
47 plot
.add_fn(ai_coarse
);
48 // You can write the plot to a stream: