]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/test/test_owens_t.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / math / test / test_owens_t.cpp
1 // test_owens_t.cpp
2
3 // Copyright Paul A. Bristow 2012.
4 // Copyright Benjamin Sobotta 2012.
5
6 // Use, modification and distribution are subject to the
7 // Boost Software License, Version 1.0.
8 // (See accompanying file LICENSE_1_0.txt
9 // or copy at http://www.boost.org/LICENSE_1_0.txt)
10
11 // Tested using some 30 decimal digit accuracy values from:
12 // Fast and accurate calculation of Owen's T-function
13 // Mike Patefield, and David Tandy
14 // Journal of Statistical Software, 5 (5), 1-25 (2000).
15 // http://www.jstatsoft.org/v05/a05/paper Table 3, page 15
16 // Values of T(h,a) accurate to thirty figures were calculated using 128 bit arithmetic by
17 // evaluating (9) with m = 48, the summation over k being continued until additional terms did
18 // not alter the result. The resultant values Tacc(h,a) say, were validated by evaluating (8) with
19 // m = 48 (i.e. 96 point Gaussian quadrature).
20
21 #define BOOST_MATH_OVERFLOW_ERROR_POLICY ignore_error
22
23 #ifdef _MSC_VER
24 # pragma warning (disable : 4127) // conditional expression is constant
25 # pragma warning (disable : 4305) // 'initializing' : truncation from 'double' to 'const float'
26 // ?? TODO get rid of these warnings?
27 #endif
28
29 #include <boost/math/concepts/real_concept.hpp> // for real_concept.
30 using ::boost::math::concepts::real_concept;
31
32 #include <boost/math/special_functions/owens_t.hpp> // for owens_t function.
33 using boost::math::owens_t;
34 #include <boost/math/distributions/normal.hpp>
35
36 #define BOOST_TEST_MAIN
37 #include <boost/test/unit_test.hpp>
38 #include <boost/test/tools/floating_point_comparison.hpp>
39 #include <boost/array.hpp>
40
41 #include "libs/math/test/handle_test_result.hpp"
42 #include "libs/math/test/table_type.hpp"
43 #include "libs/math/test/functor.hpp"
44 #include "boost/math/tools/test_value.hpp"
45 #include "test_owens_t.hpp"
46
47 //
48 // Defining TEST_CPP_DEC_FLOAT enables testing of multiprecision support.
49 // This requires the multiprecision library from sandbox/big_number.
50 // Note that these tests *do not pass*, but they do give an idea of the
51 // error rates that can be expected....
52 //
53 #ifdef TEST_CPP_DEC_FLOAT
54 #include <boost/multiprecision/cpp_dec_float.hpp>
55
56 #undef SC_
57 #define SC_(x) BOOST_MATH_TEST_VALUE(x)
58 #endif
59
60 #include "owens_t_T7.hpp"
61
62 #include <iostream>
63 using std::cout;
64 using std::endl;
65 #include <limits>
66 using std::numeric_limits;
67
68 void expected_results()
69 {
70 //
71 // Define the max and mean errors expected for
72 // various compilers and platforms.
73 //
74 const char* largest_type;
75 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
76 if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
77 {
78 largest_type = "(long\\s+)?double|real_concept";
79 }
80 else
81 {
82 largest_type = "long double|real_concept";
83 }
84 #else
85 largest_type = "(long\\s+)?double";
86 #endif
87
88 //
89 // Catch all cases come last:
90 //
91 if(std::numeric_limits<long double>::digits > 60)
92 {
93 add_expected_result(
94 ".*", // compiler
95 ".*", // stdlib
96 ".*", // platform
97 largest_type, // test type(s)
98 ".*", // test data group
99 "owens_t", 500, 100); // test function
100 }
101 else
102 {
103 add_expected_result(
104 ".*", // compiler
105 ".*", // stdlib
106 ".*", // platform
107 largest_type, // test type(s)
108 ".*", // test data group
109 "owens_t", 60, 5); // test function
110 }
111 //
112 // Finish off by printing out the compiler/stdlib/platform names,
113 // we do this to make it easier to mark up expected error rates.
114 //
115 std::cout << "Tests run with " << BOOST_COMPILER << ", "
116 << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
117 }
118
119 BOOST_AUTO_TEST_CASE( test_main )
120 {
121 BOOST_MATH_CONTROL_FP;
122
123 expected_results();
124
125 // Basic sanity-check spot values.
126
127 // (Parameter value, arbitrarily zero, only communicates the floating point type).
128 test_spots(0.0F); // Test float.
129 test_spots(0.0); // Test double.
130 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
131 test_spots(0.0L); // Test long double.
132 #if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x582)) && !defined(BOOST_MATH_NO_REAL_CONCEPT_TESTS)
133 test_spots(boost::math::concepts::real_concept(0.)); // Test real concept.
134 #endif
135 #endif
136
137 check_against_T7(0.0F); // Test float.
138 check_against_T7(0.0); // Test double.
139 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
140 check_against_T7(0.0L); // Test long double.
141 #if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x582)) && !defined(BOOST_MATH_NO_REAL_CONCEPT_TESTS)
142 check_against_T7(boost::math::concepts::real_concept(0.)); // Test real concept.
143 #endif
144 #endif
145
146 test_owens_t(0.0F, "float"); // Test float.
147 test_owens_t(0.0, "double"); // Test double.
148 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
149 test_owens_t(0.0L, "long double"); // Test long double.
150 #if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x582)) && !defined(BOOST_MATH_NO_REAL_CONCEPT_TESTS)
151 test_owens_t(boost::math::concepts::real_concept(0.), "real_concept"); // Test real concept.
152 #endif
153 #endif
154 #if defined(TEST_CPP_DEC_FLOAT) && !defined(BOOST_MATH_STANDALONE)
155 typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<35> > cpp_dec_float_35;
156 test_owens_t(cpp_dec_float_35(0), "cpp_dec_float_35"); // Test real concept.
157 test_owens_t(boost::multiprecision::cpp_dec_float_50(0), "cpp_dec_float_50"); // Test real concept.
158 test_owens_t(boost::multiprecision::cpp_dec_float_100(0), "cpp_dec_float_100"); // Test real concept.
159 #endif
160
161 } // BOOST_AUTO_TEST_CASE( test_main )
162
163 /*
164
165 Output:
166
167 Description: Autorun "J:\Cpp\MathToolkit\test\Math_test\Debug\test_owens_t.exe"
168 Running 1 test case...
169 Tests run with Microsoft Visual C++ version 10.0, Dinkumware standard library version 520, Win32
170 Tolerance = 3.57628e-006.
171 Tolerance = 6.66134e-015.
172 Tolerance = 6.66134e-015.
173 Tolerance = 6.66134e-015.
174 Tolerance = 1.78814e-005.
175 Tolerance = 3.33067e-014.
176 Tolerance = 3.33067e-014.
177 Tolerance = 3.33067e-014.
178 Testing Owens T (medium small values) with type float
179 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
180 boost::math::owens_t<float> Max = 0 RMS Mean=0
181
182
183 Testing Owens T (large and diverse values) with type float
184 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
185 boost::math::owens_t<float> Max = 0 RMS Mean=0
186
187
188 Testing Owens T (medium small values) with type double
189 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
190 boost::math::owens_t<double> Max = 4.375 RMS Mean=0.9728
191 worst case at row: 81
192 { 4.4206809997558594, 0.1269868016242981, 1.0900281236140834e-006 }
193
194
195 Testing Owens T (large and diverse values) with type double
196 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
197 boost::math::owens_t<double> Max = 3.781 RMS Mean=0.6206
198 worst case at row: 430
199 { 3.4516773223876953, 0.0010718167759478092, 4.413983645332431e-007 }
200
201
202 Testing Owens T (medium small values) with type long double
203 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
204 boost::math::owens_t<long double> Max = 4.375 RMS Mean=0.9728
205 worst case at row: 81
206 { 4.4206809997558594, 0.1269868016242981, 1.0900281236140834e-006 }
207
208
209 Testing Owens T (large and diverse values) with type long double
210 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
211 boost::math::owens_t<long double> Max = 3.781 RMS Mean=0.6206
212 worst case at row: 430
213 { 3.4516773223876953, 0.0010718167759478092, 4.413983645332431e-007 }
214
215
216 Testing Owens T (medium small values) with type real_concept
217 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
218 boost::math::owens_t<real_concept> Max = 4.375 RMS Mean=1.032
219 worst case at row: 81
220 { 4.4206809997558594, 0.1269868016242981, 1.0900281236140834e-006 }
221
222
223 Testing Owens T (large and diverse values) with type real_concept
224 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
225 boost::math::owens_t<real_concept> Max = 21.04 RMS Mean=1.102
226 worst case at row: 439
227 { 3.4516773223876953, 0.98384737968444824, 0.00013923002576038691 }
228
229
230
231 *** No errors detected
232
233
234 */
235
236
237