]>
Commit | Line | Data |
---|---|---|
20effc67 TL |
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 | ||
9 | int main() { | |
10 | using PreciseReal = long double; | |
11 | using CoarseReal = float; | |
12 | ||
13 | auto jacobi_theta1_coarse = [](CoarseReal q) { | |
14 | return boost::math::jacobi_theta1<CoarseReal>(5.0, q); | |
15 | }; | |
16 | auto jacobi_theta1_precise = [](PreciseReal q) { | |
17 | return boost::math::jacobi_theta1<PreciseReal>(5.0, q); | |
18 | }; | |
19 | ||
20 | auto jacobi_theta2_coarse = [](CoarseReal q) { | |
21 | return boost::math::jacobi_theta2<CoarseReal>(0.4, q); | |
22 | }; | |
23 | auto jacobi_theta2_precise = [](PreciseReal q) { | |
24 | return boost::math::jacobi_theta2<PreciseReal>(0.4, q); | |
25 | }; | |
26 | ||
27 | auto jacobi_theta3_coarse = [](CoarseReal q) { | |
28 | return boost::math::jacobi_theta3<CoarseReal>(0.4, q); | |
29 | }; | |
30 | auto jacobi_theta3_precise = [](PreciseReal q) { | |
31 | return boost::math::jacobi_theta3<PreciseReal>(0.4, q); | |
32 | }; | |
33 | ||
34 | auto jacobi_theta4_coarse = [](CoarseReal q) { | |
35 | return boost::math::jacobi_theta4<CoarseReal>(5.0, q); | |
36 | }; | |
37 | auto jacobi_theta4_precise = [](PreciseReal q) { | |
38 | return boost::math::jacobi_theta4<PreciseReal>(5.0, q); | |
39 | }; | |
40 | ||
41 | int samples = 2500; | |
42 | int width = 800; | |
43 | PreciseReal clip = 100; | |
44 | ||
45 | std::string filename1 = "jacobi_theta1q_" + boost::core::demangle(typeid(CoarseReal).name()) + ".svg"; | |
46 | auto plot1 = ulps_plot<decltype(jacobi_theta1_precise), PreciseReal, CoarseReal>(jacobi_theta1_precise, CoarseReal(0), CoarseReal(0.999999), samples); | |
47 | plot1.clip(clip).width(width); | |
48 | std::string title1 = "jacobi_theta1(5.0, q) ULP plot at " + boost::core::demangle(typeid(CoarseReal).name()) + " precision"; | |
49 | plot1.title(title1); | |
50 | plot1.vertical_lines(10); | |
51 | plot1.add_fn(jacobi_theta1_coarse); | |
52 | plot1.write(filename1); | |
53 | ||
54 | std::string filename2 = "jacobi_theta2q_" + boost::core::demangle(typeid(CoarseReal).name()) + ".svg"; | |
55 | auto plot2 = ulps_plot<decltype(jacobi_theta2_precise), PreciseReal, CoarseReal>(jacobi_theta2_precise, CoarseReal(0), CoarseReal(0.999999), samples); | |
56 | plot2.clip(clip).width(width); | |
57 | std::string title2 = "jacobi_theta2(0.4, q) ULP plot at " + boost::core::demangle(typeid(CoarseReal).name()) + " precision"; | |
58 | plot2.title(title2); | |
59 | plot2.vertical_lines(10); | |
60 | plot2.add_fn(jacobi_theta2_coarse); | |
61 | plot2.write(filename2); | |
62 | ||
63 | std::string filename3 = "jacobi_theta3q_" + boost::core::demangle(typeid(CoarseReal).name()) + ".svg"; | |
64 | auto plot3 = ulps_plot<decltype(jacobi_theta3_precise), PreciseReal, CoarseReal>(jacobi_theta3_precise, CoarseReal(0), CoarseReal(0.999999), samples); | |
65 | plot3.clip(clip).width(width); | |
66 | std::string title3 = "jacobi_theta3(0.4, q) ULP plot at " + boost::core::demangle(typeid(CoarseReal).name()) + " precision"; | |
67 | plot3.title(title3); | |
68 | plot3.vertical_lines(10); | |
69 | plot3.add_fn(jacobi_theta3_coarse); | |
70 | plot3.write(filename3); | |
71 | ||
72 | std::string filename4 = "jacobi_theta4q_" + boost::core::demangle(typeid(CoarseReal).name()) + ".svg"; | |
73 | auto plot4 = ulps_plot<decltype(jacobi_theta4_precise), PreciseReal, CoarseReal>(jacobi_theta4_precise, CoarseReal(0), CoarseReal(0.999999), samples); | |
74 | plot4.clip(clip).width(width); | |
75 | std::string title4 = "jacobi_theta4(5.0, q) ULP plot at " + boost::core::demangle(typeid(CoarseReal).name()) + " precision"; | |
76 | plot4.title(title4); | |
77 | plot4.vertical_lines(10); | |
78 | plot4.add_fn(jacobi_theta4_coarse); | |
79 | plot4.write(filename4); | |
80 | } |