]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/reporting/performance/test_jv.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / math / reporting / performance / test_jv.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<T, 3>, 21> jv_data = { {
21 //SC_(-2.4), {{ SC_(0.0), std::numeric_limits<T>::infinity() }},
22 { { T(22.5), T(0.0), SC_(0.0) } },
23 { { T(2457.0) / 1024, T(1.0) / 1024, SC_(3.80739920118603335646474073457326714709615200130620574875292e-9) } },
24 { { SC_(5.5), T(3217) / 1024, SC_(0.0281933076257506091621579544064767140470089107926550720453038) } },
25 { { SC_(-5.5), T(3217) / 1024, SC_(-2.55820064470647911823175836997490971806135336759164272675969) } },
26 { { SC_(-5.5), SC_(1e+04), SC_(2.449843111985605522111159013846599118397e-03) } },
27 { { SC_(5.5), SC_(1e+04), SC_(0.00759343502722670361395585198154817047185480147294665270646578) } },
28 { { SC_(5.5), SC_(1e+06), SC_(-0.000747424248595630177396350688505919533097973148718960064663632) } },
29 { { SC_(5.125), SC_(1e+06), SC_(-0.000776600124835704280633640911329691642748783663198207360238214) } },
30 { { SC_(5.875), SC_(1e+06), SC_(-0.000466322721115193071631008581529503095819705088484386434589780) } },
31 { { SC_(0.5), SC_(101.0), SC_(0.0358874487875643822020496677692429287863419555699447066226409) } },
32 { { SC_(-5.5), SC_(1e+04), SC_(0.00244984311198560552211115901384659911839737686676766460822577) } },
33 { { SC_(-5.5), SC_(1e+06), SC_(0.000279243200433579511095229508894156656558211060453622750659554) } },
34 { { SC_(-0.5), SC_(101.0), SC_(0.0708184798097594268482290389188138201440114881159344944791454) } },
35 { { T(-10486074) / (1024 * 1024), T(1) / 1024, SC_(1.41474013160494695750009004222225969090304185981836460288562e35) } },
36 { { T(-10486074) / (1024 * 1024), SC_(15.0), SC_(-0.0902239288885423309568944543848111461724911781719692852541489) } },
37 { { T(10486074) / (1024 * 1024), SC_(1e+02), SC_(-0.0547064914615137807616774867984047583596945624129838091326863) } },
38 { { T(10486074) / (1024 * 1024), SC_(2e+04), SC_(-0.00556783614400875611650958980796060611309029233226596737701688) } },
39 { { T(-10486074) / (1024 * 1024), SC_(1e+02), SC_(-0.0547613660316806551338637153942604550779513947674222863858713) } },
40 // Bug report https://svn.boost.org/trac/boost/ticket/4812:
41 { { SC_(1.5), T(8034) / 1024, SC_(0.0339477646369710610146236955872928005087352629422508823945264) } },
42 { { SC_(8.5), boost::math::constants::pi<T>() * 4, SC_(0.0436807946352780974532519564114026730332781693877984686758680) } },
43 { { SC_(-8.5), boost::math::constants::pi<T>() * 4, SC_(-0.257086543428224355151772807588810984369026142375675714560864) } },
44 } };
45
46 int main()
47 {
48 #include "bessel_j_data.ipp"
49 #include "bessel_j_large_data.ipp"
50
51 add_data(jv_data);
52 add_data(bessel_j_data);
53 add_data(bessel_j_large_data);
54
55 unsigned data_total = data.size();
56
57 std::cout << "Screening boost data:\n";
58 screen_data([](const std::vector<double>& v){ return boost::math::cyl_bessel_j(v[0], v[1]); }, [](const std::vector<double>& v){ return v[2]; });
59
60 #if defined(TEST_LIBSTDCXX) && !defined(COMPILER_COMPARISON_TABLES)
61 std::cout << "Screening libstdc++ data:\n";
62 screen_data([](const std::vector<double>& v){ return std::tr1::cyl_bessel_j(v[0], v[1]); }, [](const std::vector<double>& v){ return v[2]; });
63 #endif
64 #if defined(TEST_GSL) && !defined(COMPILER_COMPARISON_TABLES)
65 std::cout << "Screening libstdc++ data:\n";
66 screen_data([](const std::vector<double>& v){ return gsl_sf_bessel_Jnu(v[0], v[1]); }, [](const std::vector<double>& v){ return v[2]; });
67 #endif
68 #if defined(TEST_RMATH) && !defined(COMPILER_COMPARISON_TABLES)
69 std::cout << "Screening libstdc++ data:\n";
70 screen_data([](const std::vector<double>& v){ return bessel_j(v[1], v[0]); }, [](const std::vector<double>& v){ return v[2]; });
71 #endif
72
73 unsigned data_used = data.size();
74 std::string function = "cyl_bessel_j[br](" + boost::lexical_cast<std::string>(data_used) + "/" + boost::lexical_cast<std::string>(data_total) + " tests selected)";
75 std::string function_short = "cyl_bessel_j";
76
77 double time;
78
79 time = exec_timed_test([](const std::vector<double>& v){ return boost::math::cyl_bessel_j(v[0], v[1]); });
80 std::cout << time << std::endl;
81 #if !defined(COMPILER_COMPARISON_TABLES) && (defined(TEST_GSL) || defined(TEST_RMATH) || defined(TEST_LIBSTDCXX))
82 report_execution_time(time, std::string("Library Comparison with ") + std::string(compiler_name()) + std::string(" on ") + platform_name(), function, boost_name());
83 #endif
84 report_execution_time(time, std::string("Compiler Comparison on ") + std::string(platform_name()), function_short, compiler_name() + std::string("[br]") + boost_name());
85 //
86 // Boost again, but with promotion to long double turned off:
87 //
88 #if !defined(COMPILER_COMPARISON_TABLES)
89 if(sizeof(long double) != sizeof(double))
90 {
91 time = exec_timed_test([](const std::vector<double>& v){ return boost::math::cyl_bessel_j(v[0], v[1], boost::math::policies::make_policy(boost::math::policies::promote_double<false>())); });
92 std::cout << time << std::endl;
93 #if !defined(COMPILER_COMPARISON_TABLES) && (defined(TEST_GSL) || defined(TEST_RMATH) || defined(TEST_LIBSTDCXX))
94 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>");
95 #endif
96 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>");
97 }
98 #endif
99
100
101 #if defined(TEST_LIBSTDCXX) && !defined(COMPILER_COMPARISON_TABLES)
102 time = exec_timed_test([](const std::vector<double>& v){ return std::tr1::cyl_bessel_j(v[0], v[1]); });
103 std::cout << time << std::endl;
104 report_execution_time(time, std::string("Library Comparison with ") + std::string(compiler_name()) + std::string(" on ") + platform_name(), function, "tr1/cmath");
105 #endif
106 #if defined(TEST_GSL) && !defined(COMPILER_COMPARISON_TABLES)
107 time = exec_timed_test([](const std::vector<double>& v){ return gsl_sf_bessel_Jnu(v[0], v[1]); });
108 std::cout << time << std::endl;
109 report_execution_time(time, std::string("Library Comparison with ") + std::string(compiler_name()) + std::string(" on ") + platform_name(), function, "GSL " GSL_VERSION);
110 #endif
111 #if defined(TEST_RMATH) && !defined(COMPILER_COMPARISON_TABLES)
112 time = exec_timed_test([](const std::vector<double>& v){ return bessel_j(v[1], v[0]); });
113 std::cout << time << std::endl;
114 report_execution_time(time, std::string("Library Comparison with ") + std::string(compiler_name()) + std::string(" on ") + platform_name(), function, "Rmath " R_VERSION_STRING);
115 #endif
116
117 return 0;
118 }
119