1
2 #include <iostream>
3 #include <boost/math/tools/ulps_plot.hpp>
4 #include <boost/core/demangle.hpp>
5 #include <boost/math/special_functions/jacobi_theta.hpp>
6
7 using boost::math::tools::ulps_plot;
8
main()9 int main() {
10 using PreciseReal = long double;
11 using CoarseReal = float;
12
13 CoarseReal q = 0.5;
14
15 auto jacobi_theta1_coarse = [=](CoarseReal z) {
16 return boost::math::jacobi_theta1<CoarseReal>(z, q);
17 };
18 auto jacobi_theta1_precise = [=](PreciseReal z) {
19 return boost::math::jacobi_theta1<PreciseReal>(z, q);
20 };
21 auto jacobi_theta2_coarse = [=](CoarseReal z) {
22 return boost::math::jacobi_theta2<CoarseReal>(z, q);
23 };
24 auto jacobi_theta2_precise = [=](PreciseReal z) {
25 return boost::math::jacobi_theta2<PreciseReal>(z, q);
26 };
27 auto jacobi_theta3_coarse = [=](CoarseReal z) {
28 return boost::math::jacobi_theta3m1<CoarseReal>(z, q);
29 };
30 auto jacobi_theta3_precise = [=](PreciseReal z) {
31 return boost::math::jacobi_theta3m1<PreciseReal>(z, q);
32 };
33 auto jacobi_theta4_coarse = [=](CoarseReal z) {
34 return boost::math::jacobi_theta4m1<CoarseReal>(z, q);
35 };
36 auto jacobi_theta4_precise = [=](PreciseReal z) {
37 return boost::math::jacobi_theta4m1<PreciseReal>(z, q);
38 };
39
40 int samples = 2500;
41 int width = 800;
42 PreciseReal clip = 100;
43
44 std::string filename1 = "jacobi_theta1_" + boost::core::demangle(typeid(CoarseReal).name()) + ".svg";
45 auto plot1 = ulps_plot<decltype(jacobi_theta1_precise), PreciseReal, CoarseReal>(jacobi_theta1_precise, 0.0, boost::math::constants::two_pi<CoarseReal>(), samples);
46 plot1.clip(clip).width(width);
47 std::string title1 = "jacobi_theta1(x, 0.5) ULP plot at " + boost::core::demangle(typeid(CoarseReal).name()) + " precision";
48 plot1.title(title1);
49 plot1.vertical_lines(10);
50 plot1.add_fn(jacobi_theta1_coarse);
51 plot1.write(filename1);
52
53 std::string filename2 = "jacobi_theta2_" + boost::core::demangle(typeid(CoarseReal).name()) + ".svg";
54 auto plot2 = ulps_plot<decltype(jacobi_theta2_precise), PreciseReal, CoarseReal>(jacobi_theta2_precise, 0.0, boost::math::constants::two_pi<CoarseReal>(), samples);
55 plot2.clip(clip).width(width);
56 std::string title2 = "jacobi_theta2(x, 0.5) ULP plot at " + boost::core::demangle(typeid(CoarseReal).name()) + " precision";
57 plot2.title(title2);
58 plot2.vertical_lines(10);
59 plot2.add_fn(jacobi_theta2_coarse);
60 plot2.write(filename2);
61
62 std::string filename3 = "jacobi_theta3_" + boost::core::demangle(typeid(CoarseReal).name()) + ".svg";
63 auto plot3 = ulps_plot<decltype(jacobi_theta3_precise), PreciseReal, CoarseReal>(jacobi_theta3_precise, 0.0, boost::math::constants::two_pi<CoarseReal>(), samples);
64 plot3.clip(clip).width(width);
65 std::string title3 = "jacobi_theta3m1(x, 0.5) ULP plot at " + boost::core::demangle(typeid(CoarseReal).name()) + " precision";
66 plot3.title(title3);
67 plot3.vertical_lines(10);
68 plot3.add_fn(jacobi_theta3_coarse);
69 plot3.write(filename3);
70
71 std::string filename4 = "jacobi_theta4_" + boost::core::demangle(typeid(CoarseReal).name()) + ".svg";
72 auto plot4 = ulps_plot<decltype(jacobi_theta4_precise), PreciseReal, CoarseReal>(jacobi_theta4_precise, 0.0, boost::math::constants::two_pi<CoarseReal>(), samples);
73 plot4.clip(clip).width(width);
74 std::string title4 = "jacobi_theta4m1(x, 0.5) ULP plot at " + boost::core::demangle(typeid(CoarseReal).name()) + " precision";
75 plot4.title(title4);
76 plot4.vertical_lines(10);
77 plot4.add_fn(jacobi_theta4_coarse);
78 plot4.write(filename4);
79 }
80