]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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/ellint_1.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>, 19> data1 = { { | |
21 | { { SC_(0.0), SC_(0.0), SC_(0.0) } }, | |
22 | { { SC_(-10.0), SC_(0.0), SC_(-10.0) } }, | |
23 | { { SC_(-1.0), SC_(-1.0), SC_(-1.2261911708835170708130609674719067527242483502207) } }, | |
24 | { { SC_(-4.0), SC_(0.875), SC_(-5.3190556182262405182189463092940736859067548232647) } }, | |
25 | { { SC_(8.0), SC_(-0.625), SC_(9.0419973860310100524448893214394562615252527557062) } }, | |
26 | { { SC_(1e-05), SC_(0.875), SC_(0.000010000000000127604166668510945638036143355898993088) } }, | |
27 | { { SC_(1e+05), T(10) / 1024, SC_(100002.38431454899771096037307519328741455615271038) } }, | |
28 | { { SC_(1e-20), SC_(1.0), SC_(1.0000000000000000000000000000000000000000166666667e-20) } }, | |
29 | { { SC_(1e-20), SC_(1e-20), SC_(1.000000000000000e-20) } }, | |
30 | { { SC_(1e+20), T(400) / 1024, SC_(1.0418143796499216839719289963154558027005142709763e20) } }, | |
31 | { { SC_(1e+50), SC_(0.875), SC_(1.3913251718238765549409892714295358043696028445944e50) } }, | |
32 | { { SC_(2.0), SC_(0.5), SC_(2.1765877052210673672479877957388515321497888026770) } }, | |
33 | { { SC_(4.0), SC_(0.5), SC_(4.2543274975235836861894752787874633017836785640477) } }, | |
34 | { { SC_(6.0), SC_(0.5), SC_(6.4588766202317746302999080620490579800463614807916) } }, | |
35 | { { SC_(10.0), SC_(0.5), SC_(10.697409951222544858346795279378531495869386960090) } }, | |
36 | { { SC_(-2.0), SC_(0.5), SC_(-2.1765877052210673672479877957388515321497888026770) } }, | |
37 | { { SC_(-4.0), SC_(0.5), SC_(-4.2543274975235836861894752787874633017836785640477) } }, | |
38 | { { SC_(-6.0), SC_(0.5), SC_(-6.4588766202317746302999080620490579800463614807916) } }, | |
39 | { { SC_(-10.0), SC_(0.5), SC_(-10.697409951222544858346795279378531495869386960090) } }, | |
40 | } }; | |
41 | ||
42 | int main() | |
43 | { | |
44 | #include "ellint_f_data.ipp" | |
45 | ||
46 | add_data(data1); | |
47 | add_data(ellint_f_data); | |
48 | ||
49 | unsigned data_total = data.size(); | |
50 | ||
51 | screen_data([](const std::vector<double>& v){ return boost::math::ellint_1(v[1], v[0]); }, [](const std::vector<double>& v){ return v[2]; }); | |
52 | ||
53 | ||
54 | #if defined(TEST_LIBSTDCXX) && !defined(COMPILER_COMPARISON_TABLES) | |
55 | screen_data([](const std::vector<double>& v){ return std::tr1::ellint_1(v[1], v[0]); }, [](const std::vector<double>& v){ return v[2]; }); | |
56 | #endif | |
57 | #if defined(TEST_GSL) && !defined(COMPILER_COMPARISON_TABLES) | |
58 | screen_data([](const std::vector<double>& v){ return gsl_sf_ellint_F(v[0], v[1], GSL_PREC_DOUBLE); }, [](const std::vector<double>& v){ return v[2]; }); | |
59 | #endif | |
60 | ||
61 | unsigned data_used = data.size(); | |
62 | std::string function = "ellint_1[br](" + boost::lexical_cast<std::string>(data_used) + "/" + boost::lexical_cast<std::string>(data_total) + " tests selected)"; | |
63 | std::string function_short = "ellint_1"; | |
64 | ||
65 | double time; | |
66 | ||
67 | time = exec_timed_test([](const std::vector<double>& v){ return boost::math::ellint_1(v[1], v[0]); }); | |
68 | std::cout << time << std::endl; | |
69 | #if !defined(COMPILER_COMPARISON_TABLES) && (defined(TEST_GSL) || defined(TEST_RMATH) || defined(TEST_LIBSTDCXX)) | |
70 | report_execution_time(time, std::string("Library Comparison with ") + std::string(compiler_name()) + std::string(" on ") + platform_name(), function, boost_name()); | |
71 | #endif | |
72 | report_execution_time(time, std::string("Compiler Comparison on ") + std::string(platform_name()), function_short, compiler_name() + std::string("[br]") + boost_name()); | |
73 | // | |
74 | // Boost again, but with promotion to long double turned off: | |
75 | // | |
76 | #if !defined(COMPILER_COMPARISON_TABLES) | |
77 | if(sizeof(long double) != sizeof(double)) | |
78 | { | |
79 | time = exec_timed_test([](const std::vector<double>& v){ return boost::math::ellint_1(v[1], v[0], boost::math::policies::make_policy(boost::math::policies::promote_double<false>())); }); | |
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() + "[br]promote_double<false>"); | |
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() + "[br]promote_double<false>"); | |
85 | } | |
86 | #endif | |
87 | ||
88 | ||
89 | #if defined(TEST_LIBSTDCXX) && !defined(COMPILER_COMPARISON_TABLES) | |
90 | time = exec_timed_test([](const std::vector<double>& v){ return std::tr1::ellint_1(v[1], v[0]); }); | |
91 | std::cout << time << std::endl; | |
92 | report_execution_time(time, std::string("Library Comparison with ") + std::string(compiler_name()) + std::string(" on ") + platform_name(), function, "tr1/cmath"); | |
93 | #endif | |
94 | #if defined(TEST_GSL) && !defined(COMPILER_COMPARISON_TABLES) | |
95 | time = exec_timed_test([](const std::vector<double>& v){ return gsl_sf_ellint_F(v[0], v[1], GSL_PREC_DOUBLE); }); | |
96 | std::cout << time << std::endl; | |
97 | report_execution_time(time, std::string("Library Comparison with ") + std::string(compiler_name()) + std::string(" on ") + platform_name(), function, "GSL " GSL_VERSION); | |
98 | #endif | |
99 | ||
100 | return 0; | |
101 | } | |
102 |