]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/math/reporting/accuracy/plot_jacobi_theta_q.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / math / reporting / accuracy / plot_jacobi_theta_q.cpp
CommitLineData
1e59de90
TL
1// (C) Copyright Evan Miller 2020.
2// Use, modification and distribution are subject to the
3// Boost Software License, Version 1.0. (See accompanying file
4// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
20effc67
TL
5
6#include <iostream>
7#include <boost/math/tools/ulps_plot.hpp>
8#include <boost/core/demangle.hpp>
9#include <boost/math/special_functions/jacobi_theta.hpp>
10
11using boost::math::tools::ulps_plot;
12
13int main() {
14 using PreciseReal = long double;
15 using CoarseReal = float;
16
17 auto jacobi_theta1_coarse = [](CoarseReal q) {
18 return boost::math::jacobi_theta1<CoarseReal>(5.0, q);
19 };
20 auto jacobi_theta1_precise = [](PreciseReal q) {
21 return boost::math::jacobi_theta1<PreciseReal>(5.0, q);
22 };
23
24 auto jacobi_theta2_coarse = [](CoarseReal q) {
25 return boost::math::jacobi_theta2<CoarseReal>(0.4, q);
26 };
27 auto jacobi_theta2_precise = [](PreciseReal q) {
28 return boost::math::jacobi_theta2<PreciseReal>(0.4, q);
29 };
30
31 auto jacobi_theta3_coarse = [](CoarseReal q) {
32 return boost::math::jacobi_theta3<CoarseReal>(0.4, q);
33 };
34 auto jacobi_theta3_precise = [](PreciseReal q) {
35 return boost::math::jacobi_theta3<PreciseReal>(0.4, q);
36 };
37
38 auto jacobi_theta4_coarse = [](CoarseReal q) {
39 return boost::math::jacobi_theta4<CoarseReal>(5.0, q);
40 };
41 auto jacobi_theta4_precise = [](PreciseReal q) {
42 return boost::math::jacobi_theta4<PreciseReal>(5.0, q);
43 };
44
45 int samples = 2500;
46 int width = 800;
47 PreciseReal clip = 100;
48
49 std::string filename1 = "jacobi_theta1q_" + boost::core::demangle(typeid(CoarseReal).name()) + ".svg";
50 auto plot1 = ulps_plot<decltype(jacobi_theta1_precise), PreciseReal, CoarseReal>(jacobi_theta1_precise, CoarseReal(0), CoarseReal(0.999999), samples);
51 plot1.clip(clip).width(width);
52 std::string title1 = "jacobi_theta1(5.0, q) ULP plot at " + boost::core::demangle(typeid(CoarseReal).name()) + " precision";
53 plot1.title(title1);
54 plot1.vertical_lines(10);
55 plot1.add_fn(jacobi_theta1_coarse);
56 plot1.write(filename1);
57
58 std::string filename2 = "jacobi_theta2q_" + boost::core::demangle(typeid(CoarseReal).name()) + ".svg";
59 auto plot2 = ulps_plot<decltype(jacobi_theta2_precise), PreciseReal, CoarseReal>(jacobi_theta2_precise, CoarseReal(0), CoarseReal(0.999999), samples);
60 plot2.clip(clip).width(width);
61 std::string title2 = "jacobi_theta2(0.4, q) ULP plot at " + boost::core::demangle(typeid(CoarseReal).name()) + " precision";
62 plot2.title(title2);
63 plot2.vertical_lines(10);
64 plot2.add_fn(jacobi_theta2_coarse);
65 plot2.write(filename2);
66
67 std::string filename3 = "jacobi_theta3q_" + boost::core::demangle(typeid(CoarseReal).name()) + ".svg";
68 auto plot3 = ulps_plot<decltype(jacobi_theta3_precise), PreciseReal, CoarseReal>(jacobi_theta3_precise, CoarseReal(0), CoarseReal(0.999999), samples);
69 plot3.clip(clip).width(width);
70 std::string title3 = "jacobi_theta3(0.4, q) ULP plot at " + boost::core::demangle(typeid(CoarseReal).name()) + " precision";
71 plot3.title(title3);
72 plot3.vertical_lines(10);
73 plot3.add_fn(jacobi_theta3_coarse);
74 plot3.write(filename3);
75
76 std::string filename4 = "jacobi_theta4q_" + boost::core::demangle(typeid(CoarseReal).name()) + ".svg";
77 auto plot4 = ulps_plot<decltype(jacobi_theta4_precise), PreciseReal, CoarseReal>(jacobi_theta4_precise, CoarseReal(0), CoarseReal(0.999999), samples);
78 plot4.clip(clip).width(width);
79 std::string title4 = "jacobi_theta4(5.0, q) ULP plot at " + boost::core::demangle(typeid(CoarseReal).name()) + " precision";
80 plot4.title(title4);
81 plot4.vertical_lines(10);
82 plot4.add_fn(jacobi_theta4_coarse);
83 plot4.write(filename4);
84}