]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/multiprecision/plots/cpp_bin_float_tan_errors.cpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / libs / multiprecision / plots / cpp_bin_float_tan_errors.cpp
diff --git a/ceph/src/boost/libs/multiprecision/plots/cpp_bin_float_tan_errors.cpp b/ceph/src/boost/libs/multiprecision/plots/cpp_bin_float_tan_errors.cpp
new file mode 100644 (file)
index 0000000..f9bd486
--- /dev/null
@@ -0,0 +1,52 @@
+
+//  (C) Copyright Nick Thompson 2020.
+//  (C) Copyright John Maddock 2020.
+//  Use, modification and distribution are subject to the
+//  Boost Software License, Version 1.0. (See accompanying file
+//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#include <iostream>
+#include <boost/math/tools/ulps_plot.hpp>
+#include <boost/core/demangle.hpp>
+#include <boost/multiprecision/mpfr.hpp>
+#include <boost/multiprecision/cpp_bin_float.hpp>
+
+using boost::math::tools::ulps_plot;
+
+int main() {
+   using PreciseReal = boost::multiprecision::mpfr_float_100;
+   using CoarseReal = boost::multiprecision::cpp_bin_float_50;
+
+   typedef boost::math::policies::policy<
+      boost::math::policies::promote_float<false>,
+      boost::math::policies::promote_double<false> >
+      no_promote_policy;
+
+   auto ai_coarse = [](CoarseReal const& x)->CoarseReal {
+      return tan(x);
+   };
+   auto ai_precise = [](PreciseReal const& x)->PreciseReal {
+      return tan(x);
+   };
+
+   std::string filename = "cpp_bin_float_tan.svg";
+   int samples = 100000;
+   // How many pixels wide do you want your .svg?
+   int width = 700;
+   // Near a root, we have unbounded relative error. So for functions with roots, we define an ULP clip:
+   PreciseReal clip = 20;
+   // Should we perturb the abscissas?
+   bool perturb_abscissas = false;
+   auto plot = ulps_plot<decltype(ai_precise), PreciseReal, CoarseReal>(ai_precise, CoarseReal(-20), CoarseReal(20), samples, perturb_abscissas);
+   // Note the argument chaining:
+   plot.clip(clip).width(width);
+   plot.background_color("white").font_color("black");
+   // Sometimes it's useful to set a title, but in many cases it's more useful to just use a caption.
+   std::string title = "tan ULP plot with cpp_bin_float_50";
+   plot.title(title);
+   plot.vertical_lines(6);
+   plot.add_fn(ai_coarse);
+   // You can write the plot to a stream:
+   //std::cout << plot;
+   // Or to a file:
+   plot.write(filename);
+}