]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/reporting/performance/test_yn.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / math / reporting / performance / test_yn.cpp
1 // Copyright John Maddock 2015.
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)
5
6 #ifdef _MSC_VER
7 # pragma warning (disable : 4224)
8 #endif
9
10 #include <boost/math/special_functions/bessel.hpp>
11 #include <boost/array.hpp>
12 #include <boost/lexical_cast.hpp>
13 #include "../../test/table_type.hpp"
14 #include "table_helper.hpp"
15 #include "performance.hpp"
16 #include <iostream>
17
18 typedef double T;
19 #define SC_(x) static_cast<double>(x)
20 static const boost::array<boost::array<typename table_type<T>::type, 3>, 9> y0_data = { {
21 { { SC_(0.0), SC_(1.0), SC_(0.0882569642156769579829267660235151628278175230906755467110438) } },
22 { { SC_(0.0), SC_(2.0), SC_(0.510375672649745119596606592727157873268139227085846135571839) } },
23 { { SC_(0.0), SC_(4.0), SC_(-0.0169407393250649919036351344471532182404925898980149027169321) } },
24 { { SC_(0.0), SC_(8.0), SC_(0.223521489387566220527323400498620359274814930781423577578334) } },
25 { { SC_(0.0), SC_(1e-05), SC_(-7.40316028370197013259676050746759072070960287586102867247159) } },
26 { { SC_(0.0), SC_(1e-10), SC_(-14.7325162726972420426916696426209144888762342592762415255386) } },
27 { { SC_(0.0), SC_(1e-20), SC_(-29.3912282502857968601858410375186700783698345615477536431464) } },
28 { { SC_(0.0), SC_(1e+03), SC_(0.00471591797762281339977326146566525500985900489680197718528000) } },
29 { { SC_(0.0), SC_(1e+05), SC_(0.00184676615886506410434074102431546125884886798090392516843524) } }
30 } };
31 static const boost::array<boost::array<typename table_type<T>::type, 3>, 9> y1_data = { {
32 { { SC_(1.0), SC_(1.0), SC_(-0.781212821300288716547150000047964820549906390716444607843833) } },
33 { { SC_(1.0), SC_(2.0), SC_(-0.107032431540937546888370772277476636687480898235053860525795) } },
34 { { SC_(1.0), SC_(4.0), SC_(0.397925710557100005253979972450791852271189181622908340876586) } },
35 { { SC_(1.0), SC_(8.0), SC_(-0.158060461731247494255555266187483550327344049526705737651263) } },
36 { { SC_(1.0), SC_(1e-10), SC_(-6.36619772367581343150789184284462611709080831190542841855708e9) } },
37 { { SC_(1.0), SC_(1e-20), SC_(-6.36619772367581343075535053490057448139324059868649274367256e19) } },
38 { { SC_(1.0), SC_(1e+01), SC_(0.249015424206953883923283474663222803260416543069658461246944) } },
39 { { SC_(1.0), SC_(1e+03), SC_(-0.0247843312923517789148623560971412909386318548648705287583490) } },
40 { { SC_(1.0), SC_(1e+05), SC_(0.00171921035008825630099494523539897102954509504993494957572726) } }
41 } };
42 static const boost::array<boost::array<typename table_type<T>::type, 3>, 10> yn_data = { {
43 { { SC_(2.0), SC_(1e-20), SC_(-1.27323954473516268615107010698011489627570899691226996904849e40) } },
44 { { SC_(5.0), SC_(10.0), SC_(0.135403047689362303197029014762241709088405766746419538495983) } },
45 { { SC_(-5.0), SC_(1e+06), SC_(0.000331052088322609048503535570014688967096938338061796192422114) } },
46 { { SC_(10.0), SC_(10.0), SC_(-0.359814152183402722051986577343560609358382147846904467526222) } },
47 { { SC_(10.0), SC_(1e-10), SC_(-1.18280490494334933900960937719565669877576135140014365217993e108) } },
48 { { SC_(-10.0), SC_(1e+06), SC_(0.000725951969295187086245251366365393653610914686201194434805730) } },
49 { { SC_(1e+02), SC_(5.0), SC_(-5.08486391602022287993091563093082035595081274976837280338134e115) } },
50 { { SC_(1e+03), SC_(1e+05), SC_(0.00217254919137684037092834146629212647764581965821326561261181) } },
51 { { SC_(-1e+03), SC_(7e+02), SC_(-1.88753109980945889960843803284345261796244752396992106755091e77) } },
52 { { SC_(-25.0), SC_(8.0), SC_(3.45113613777297661997458045843868931827873456761831907587263e8) } }
53 } };
54
55 int main()
56 {
57 #include "bessel_y01_data.ipp"
58 #include "bessel_yn_data.ipp"
59
60 add_data(y0_data);
61 add_data(y1_data);
62 add_data(yn_data);
63 add_data(bessel_y01_data);
64 add_data(bessel_yn_data);
65
66 unsigned data_total = data.size();
67
68 screen_data([](const std::vector<double>& v){ return boost::math::cyl_neumann(static_cast<int>(v[0]), v[1]); }, [](const std::vector<double>& v){ return v[2]; });
69
70
71 #if defined(TEST_C99) && !defined(COMPILER_COMPARISON_TABLES)
72 screen_data([](const std::vector<double>& v){ return ::yn(static_cast<int>(v[0]), v[1]); }, [](const std::vector<double>& v){ return v[2]; });
73 #endif
74 #if defined(TEST_LIBSTDCXX) && !defined(COMPILER_COMPARISON_TABLES)
75 screen_data([](const std::vector<double>& v){ return std::tr1::cyl_neumann(static_cast<int>(v[0]), v[1]); }, [](const std::vector<double>& v){ return v[2]; });
76 #endif
77 #if defined(TEST_GSL) && !defined(COMPILER_COMPARISON_TABLES)
78 screen_data([](const std::vector<double>& v){ return gsl_sf_bessel_Yn(static_cast<int>(v[0]), v[1]); }, [](const std::vector<double>& v){ return v[2]; });
79 #endif
80 #if defined(TEST_RMATH) && !defined(COMPILER_COMPARISON_TABLES)
81 screen_data([](const std::vector<double>& v){ return bessel_y(v[1], static_cast<int>(v[0])); }, [](const std::vector<double>& v){ return v[2]; });
82 #endif
83
84 unsigned data_used = data.size();
85 std::string function = "cyl_neumann (integer order)[br](" + boost::lexical_cast<std::string>(data_used) + "/" + boost::lexical_cast<std::string>(data_total) + " tests selected)";
86 std::string function_short = "cyl_neumann (integer order)";
87
88 double time;
89
90 time = exec_timed_test([](const std::vector<double>& v){ return boost::math::cyl_neumann(static_cast<int>(v[0]), v[1]); });
91 std::cout << time << std::endl;
92 #if !defined(COMPILER_COMPARISON_TABLES) && (defined(TEST_GSL) || defined(TEST_RMATH) || defined(TEST_C99) || defined(TEST_LIBSTDCXX))
93 report_execution_time(time, std::string("Library Comparison with ") + std::string(compiler_name()) + std::string(" on ") + platform_name(), function, boost_name());
94 #endif
95 report_execution_time(time, std::string("Compiler Comparison on ") + std::string(platform_name()), function_short, compiler_name() + std::string("[br]") + boost_name());
96 //
97 // Boost again, but with promotion to long double turned off:
98 //
99 #if !defined(COMPILER_COMPARISON_TABLES)
100 if(sizeof(long double) != sizeof(double))
101 {
102 time = exec_timed_test([](const std::vector<double>& v){ return boost::math::cyl_neumann(static_cast<int>(v[0]), v[1], boost::math::policies::make_policy(boost::math::policies::promote_double<false>())); });
103 std::cout << time << std::endl;
104 #if !defined(COMPILER_COMPARISON_TABLES) && (defined(TEST_GSL) || defined(TEST_RMATH) || defined(TEST_C99) || defined(TEST_LIBSTDCXX))
105 report_execution_time(time, std::string("Library Comparison with ") + std::string(compiler_name()) + std::string(" on ") + platform_name(), function, boost_name() + "[br]promote_double<false>");
106 #endif
107 report_execution_time(time, std::string("Compiler Comparison on ") + std::string(platform_name()), function_short, compiler_name() + std::string("[br]") + boost_name() + "[br]promote_double<false>");
108 }
109 #endif
110
111
112 #if defined(TEST_C99) && !defined(COMPILER_COMPARISON_TABLES)
113 time = exec_timed_test([](const std::vector<double>& v){ return ::yn(static_cast<int>(v[0]), v[1]); });
114 std::cout << time << std::endl;
115 report_execution_time(time, std::string("Library Comparison with ") + std::string(compiler_name()) + std::string(" on ") + platform_name(), function, "math.h");
116 #endif
117 #if defined(TEST_LIBSTDCXX) && !defined(COMPILER_COMPARISON_TABLES)
118 time = exec_timed_test([](const std::vector<double>& v){ return std::tr1::cyl_neumann(static_cast<int>(v[0]), v[1]); });
119 std::cout << time << std::endl;
120 report_execution_time(time, std::string("Library Comparison with ") + std::string(compiler_name()) + std::string(" on ") + platform_name(), function, "tr1/cmath");
121 #endif
122 #if defined(TEST_GSL) && !defined(COMPILER_COMPARISON_TABLES)
123 time = exec_timed_test([](const std::vector<double>& v){ return gsl_sf_bessel_Yn(static_cast<int>(v[0]), v[1]); });
124 std::cout << time << std::endl;
125 report_execution_time(time, std::string("Library Comparison with ") + std::string(compiler_name()) + std::string(" on ") + platform_name(), function, "GSL " GSL_VERSION);
126 #endif
127 #if defined(TEST_RMATH) && !defined(COMPILER_COMPARISON_TABLES)
128 time = exec_timed_test([](const std::vector<double>& v){ return bessel_y(v[1], static_cast<int>(v[0])); });
129 std::cout << time << std::endl;
130 report_execution_time(time, std::string("Library Comparison with ") + std::string(compiler_name()) + std::string(" on ") + platform_name(), function, "Rmath " R_VERSION_STRING);
131 #endif
132
133 return 0;
134 }
135