]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/test/test_owens_t.cpp
3 // Copyright Paul A. Bristow 2012.
4 // Copyright Benjamin Sobotta 2012.
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)
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).
21 #define BOOST_MATH_OVERFLOW_ERROR_POLICY ignore_error
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?
29 #include <boost/math/concepts/real_concept.hpp> // for real_concept.
30 using ::boost::math::concepts::real_concept
;
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>
36 #define BOOST_TEST_MAIN
37 #include <boost/test/unit_test.hpp>
38 #include <boost/test/floating_point_comparison.hpp>
39 #include <boost/array.hpp>
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 "test_owens_t.hpp"
47 // Defining TEST_CPP_DEC_FLOAT enables testing of multiprecision support.
48 // This requires the multiprecision library from sandbox/big_number.
49 // Note that these tests *do not pass*, but they do give an idea of the
50 // error rates that can be expected....
52 #ifdef TEST_CPP_DEC_FLOAT
53 #include <boost/multiprecision/cpp_dec_float.hpp>
56 inline R
convert_to(const char* s
)
59 return boost::lexical_cast
<R
>(s
);
61 catch(const boost::bad_lexical_cast
&)
67 #define SC_(x) convert_to<T>(BOOST_STRINGIZE(x))
70 #include "owens_t_T7.hpp"
76 using std::numeric_limits
;
78 void expected_results()
81 // Define the max and mean errors expected for
82 // various compilers and platforms.
84 const char* largest_type
;
85 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
86 if(boost::math::policies::digits
<double, boost::math::policies::policy
<> >() == boost::math::policies::digits
<long double, boost::math::policies::policy
<> >())
88 largest_type
= "(long\\s+)?double|real_concept";
92 largest_type
= "long double|real_concept";
95 largest_type
= "(long\\s+)?double";
99 // Catch all cases come last:
101 if(std::numeric_limits
<long double>::digits
> 60)
107 largest_type
, // test type(s)
108 ".*", // test data group
109 "owens_t", 500, 100); // test function
117 largest_type
, // test type(s)
118 ".*", // test data group
119 "owens_t", 60, 5); // test function
122 // Finish off by printing out the compiler/stdlib/platform names,
123 // we do this to make it easier to mark up expected error rates.
125 std::cout
<< "Tests run with " << BOOST_COMPILER
<< ", "
126 << BOOST_STDLIB
<< ", " << BOOST_PLATFORM
<< std::endl
;
129 BOOST_AUTO_TEST_CASE( test_main
)
131 BOOST_MATH_CONTROL_FP
;
135 // Basic sanity-check spot values.
137 // (Parameter value, arbitrarily zero, only communicates the floating point type).
138 test_spots(0.0F
); // Test float.
139 test_spots(0.0); // Test double.
140 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
141 test_spots(0.0L); // Test long double.
142 #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
143 test_spots(boost::math::concepts::real_concept(0.)); // Test real concept.
147 check_against_T7(0.0F
); // Test float.
148 check_against_T7(0.0); // Test double.
149 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
150 check_against_T7(0.0L); // Test long double.
151 #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
152 check_against_T7(boost::math::concepts::real_concept(0.)); // Test real concept.
156 test_owens_t(0.0F
, "float"); // Test float.
157 test_owens_t(0.0, "double"); // Test double.
158 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
159 test_owens_t(0.0L, "long double"); // Test long double.
160 #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
161 test_owens_t(boost::math::concepts::real_concept(0.), "real_concept"); // Test real concept.
164 #ifdef TEST_CPP_DEC_FLOAT
165 typedef boost::multiprecision::mp_number
<boost::multiprecision::cpp_dec_float
<35> > cpp_dec_float_35
;
166 test_owens_t(cpp_dec_float_35(0), "cpp_dec_float_35"); // Test real concept.
167 test_owens_t(boost::multiprecision::cpp_dec_float_50(0), "cpp_dec_float_50"); // Test real concept.
168 test_owens_t(boost::multiprecision::cpp_dec_float_100(0), "cpp_dec_float_100"); // Test real concept.
171 } // BOOST_AUTO_TEST_CASE( test_main )
177 Description: Autorun "J:\Cpp\MathToolkit\test\Math_test\Debug\test_owens_t.exe"
178 Running 1 test case...
179 Tests run with Microsoft Visual C++ version 10.0, Dinkumware standard library version 520, Win32
180 Tolerance = 3.57628e-006.
181 Tolerance = 6.66134e-015.
182 Tolerance = 6.66134e-015.
183 Tolerance = 6.66134e-015.
184 Tolerance = 1.78814e-005.
185 Tolerance = 3.33067e-014.
186 Tolerance = 3.33067e-014.
187 Tolerance = 3.33067e-014.
188 Testing Owens T (medium small values) with type float
189 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
190 boost::math::owens_t<float> Max = 0 RMS Mean=0
193 Testing Owens T (large and diverse values) with type float
194 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
195 boost::math::owens_t<float> Max = 0 RMS Mean=0
198 Testing Owens T (medium small values) with type double
199 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
200 boost::math::owens_t<double> Max = 4.375 RMS Mean=0.9728
201 worst case at row: 81
202 { 4.4206809997558594, 0.1269868016242981, 1.0900281236140834e-006 }
205 Testing Owens T (large and diverse values) with type double
206 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
207 boost::math::owens_t<double> Max = 3.781 RMS Mean=0.6206
208 worst case at row: 430
209 { 3.4516773223876953, 0.0010718167759478092, 4.413983645332431e-007 }
212 Testing Owens T (medium small values) with type long double
213 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
214 boost::math::owens_t<long double> Max = 4.375 RMS Mean=0.9728
215 worst case at row: 81
216 { 4.4206809997558594, 0.1269868016242981, 1.0900281236140834e-006 }
219 Testing Owens T (large and diverse values) with type long double
220 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
221 boost::math::owens_t<long double> Max = 3.781 RMS Mean=0.6206
222 worst case at row: 430
223 { 3.4516773223876953, 0.0010718167759478092, 4.413983645332431e-007 }
226 Testing Owens T (medium small values) with type real_concept
227 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
228 boost::math::owens_t<real_concept> Max = 4.375 RMS Mean=1.032
229 worst case at row: 81
230 { 4.4206809997558594, 0.1269868016242981, 1.0900281236140834e-006 }
233 Testing Owens T (large and diverse values) with type real_concept
234 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
235 boost::math::owens_t<real_concept> Max = 21.04 RMS Mean=1.102
236 worst case at row: 439
237 { 3.4516773223876953, 0.98384737968444824, 0.00013923002576038691 }
241 *** No errors detected