]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/test/test_jacobi.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / math / test / test_jacobi.cpp
1 // Copyright John Maddock 2012
2
3 // Use, modification and distribution are subject to the
4 // Boost Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6
7 #include <pch_light.hpp>
8 #include <test_jacobi.hpp>
9
10 //
11 // DESCRIPTION:
12 // ~~~~~~~~~~~~
13 //
14 // This file tests the Jacobi Elliptic Functions.
15 // There are two sets of tests, spot
16 // tests which compare our results with selected values computed
17 // using the online special function calculator at
18 // functions.wolfram.com, while the bulk of the accuracy tests
19 // use values generated with NTL::RR at 1000-bit precision
20 // and our generic versions of these functions.
21 //
22 // Note that when this file is first run on a new platform many of
23 // these tests will fail: the default accuracy is 1 epsilon which
24 // is too tight for most platforms. In this situation you will
25 // need to cast a human eye over the error rates reported and make
26 // a judgement as to whether they are acceptable. Either way please
27 // report the results to the Boost mailing list. Acceptable rates of
28 // error are marked up below as a series of regular expressions that
29 // identify the compiler/stdlib/platform/data-type/test-data/test-function
30 // along with the maximum expected peek and RMS mean errors for that
31 // test.
32 //
33
34 void expected_results()
35 {
36 //
37 // Define the max and mean errors expected for
38 // various compilers and platforms.
39 //
40 const char* largest_type;
41 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
42 if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
43 {
44 largest_type = "(long\\s+)?double|real_concept";
45 }
46 else
47 {
48 largest_type = "long double|real_concept";
49 }
50 #else
51 largest_type = "(long\\s+)?double";
52 #endif
53
54 add_expected_result(
55 ".*", // compiler
56 ".*", // stdlib
57 ".*", // platform
58 largest_type, // test type(s)
59 ".*Mathworld.*", // test data group
60 ".*", 500, 250); // test function
61 add_expected_result(
62 ".*", // compiler
63 ".*", // stdlib
64 ".*", // platform
65 largest_type, // test type(s)
66 ".*Large Phi.*", // test data group
67 ".*", 50000, 5000); // test function
68 add_expected_result(
69 ".*", // compiler
70 ".*", // stdlib
71 ".*", // platform
72 largest_type, // test type(s)
73 ".*near 1.*", // test data group
74 ".*", 7000, 500); // test function
75
76 if(std::numeric_limits<long double>::digits == 64)
77 {
78 //
79 // Some errors spill over into double precision:
80 //
81 add_expected_result(
82 ".*", // compiler
83 ".*", // stdlib
84 ".*", // platform
85 "double", // test type(s)
86 ".*Large Phi.*", // test data group
87 ".*", 500, 50); // test function
88 add_expected_result(
89 ".*", // compiler
90 ".*", // stdlib
91 ".*", // platform
92 "double", // test type(s)
93 ".*near 1.*", // test data group
94 ".*", 10, 5); // test function
95 }
96 //
97 // Catch all cases come last:
98 //
99 add_expected_result(
100 ".*", // compiler
101 ".*", // stdlib
102 ".*", // platform
103 largest_type, // test type(s)
104 ".*", // test data group
105 ".*", 50, 20); // test function
106 //
107 // Finish off by printing out the compiler/stdlib/platform names,
108 // we do this to make it easier to mark up expected error rates.
109 //
110 std::cout << "Tests run with " << BOOST_COMPILER << ", "
111 << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
112 }
113
114
115 BOOST_AUTO_TEST_CASE( test_main )
116 {
117 expected_results();
118 BOOST_MATH_CONTROL_FP;
119
120 test_spots(0.0F, "float");
121 test_spots(0.0, "double");
122 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
123 test_spots(0.0L, "long double");
124 #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
125 test_spots(boost::math::concepts::real_concept(0), "real_concept");
126 #endif
127 #else
128 std::cout << "<note>The long double tests have been disabled on this platform "
129 "either because the long double overloads of the usual math functions are "
130 "not available at all, or because they are too inaccurate for these tests "
131 "to pass.</note>" << std::endl;
132 #endif
133
134
135 }