1 // (C) Copyright John Maddock 2007.
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 #include <pch_light.hpp>
7 #include "test_expint.hpp"
8
9 //
10 // DESCRIPTION:
11 // ~~~~~~~~~~~~
12 //
13 // This file tests the expint functions. There are two sets of tests:
14 // 1) Sanity checks: comparison to test values created with the
15 // online calculator at functions.wolfram.com
16 // 2) Accuracy tests use values generated with NTL::RR at
17 // 1000-bit precision and our generic versions of these functions.
18 //
19 // Note that when this file is first run on a new platform many of
20 // these tests will fail: the default accuracy is 1 epsilon which
21 // is too tight for most platforms. In this situation you will
22 // need to cast a human eye over the error rates reported and make
23 // a judgement as to whether they are acceptable. Either way please
24 // report the results to the Boost mailing list. Acceptable rates of
25 // error are marked up below as a series of regular expressions that
26 // identify the compiler/stdlib/platform/data-type/test-data/test-function
27 // along with the maximum expected peek and RMS mean errors for that
28 // test.
29 //
30
expected_results()31 void expected_results()
32 {
33 //
34 // Define the max and mean errors expected for
35 // various compilers and platforms.
36 //
37
38 //
39 // On MacOS X erfc has much higher error levels than
40 // expected: given that the implementation is basically
41 // just a rational function evaluation combined with
42 // exponentiation, we conclude that exp and pow are less
43 // accurate on this platform, especially when the result
44 // is outside the range of a double.
45 //
46 add_expected_result(
47 ".*", // compiler
48 ".*", // stdlib
49 "Mac OS", // platform
50 "float|double|long double", // test type(s)
51 ".*E1.*", // test data group
52 ".*", 30, 10); // test function
53 add_expected_result(
54 ".*", // compiler
55 ".*", // stdlib
56 "Mac OS", // platform
57 "float|double|long double|real_concept", // test type(s)
58 ".*Ei.*", // test data group
59 ".*", 300, 200); // test function
60 add_expected_result(
61 ".*", // compiler
62 ".*", // stdlib
63 "Mac OS", // platform
64 ".*", // test type(s)
65 ".*", // test data group
66 ".*", 40, 15); // test function
67
68 add_expected_result(
69 ".*", // compiler
70 ".*", // stdlib
71 ".*", // platform
72 "float|double|long double", // test type(s)
73 ".*E1.*", // test data group
74 ".*", 2, 1); // test function
75 add_expected_result(
76 ".*", // compiler
77 ".*", // stdlib
78 ".*", // platform
79 "float|double|long double", // test type(s)
80 ".*Ei.*", // test data group
81 ".*", 6, 3); // test function
82 if(std::numeric_limits<long double>::digits > 100)
83 {
84 add_expected_result(
85 ".*", // compiler
86 ".*", // stdlib
87 ".*", // platform
88 "real_concept", // test type(s)
89 ".*Ei.*", // test data group
90 ".*", 150, 50); // test function
91 }
92 add_expected_result(
93 ".*", // compiler
94 ".*", // stdlib
95 ".*", // platform
96 "real_concept", // test type(s)
97 ".*Ei.*", // test data group
98 ".*", 150, 50); // test function
99 add_expected_result(
100 ".*", // compiler
101 ".*", // stdlib
102 ".*", // platform
103 ".*", // test type(s)
104 ".*", // test data group
105 ".*", 25, 5); // test function
106
107 std::cout << "Tests run with " << BOOST_COMPILER << ", "
108 << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
109 }
110
BOOST_AUTO_TEST_CASE(test_main)111 BOOST_AUTO_TEST_CASE( test_main )
112 {
113 expected_results();
114 BOOST_MATH_CONTROL_FP;
115
116 boost::math::expint(114.7);
117
118 test_spots(0.0f, "float");
119 test_spots(0.0, "double");
120 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
121 test_spots(0.0L, "long double");
122 #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
123 test_spots(boost::math::concepts::real_concept(0.1), "real_concept");
124 #endif
125 #else
126 std::cout << "<note>The long double tests have been disabled on this platform "
127 "either because the long double overloads of the usual math functions are "
128 "not available at all, or because they are too inaccurate for these tests "
129 "to pass.</note>" << std::endl;
130 #endif
131
132 test_expint(0.1F, "float");
133 test_expint(0.1, "double");
134 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
135 test_expint(0.1L, "long double");
136 #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
137 test_expint(boost::math::concepts::real_concept(0.1), "real_concept");
138 #endif
139 #else
140 std::cout << "<note>The long double tests have been disabled on this platform "
141 "either because the long double overloads of the usual math functions are "
142 "not available at all, or because they are too inaccurate for these tests "
143 "to pass.</note>" << std::endl;
144 #endif
145 }
146
147
148