• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //  Copyright 2006 John Maddock
2 // Copyright Paul A. Bristow 2007.
3 
4 //  Use, modification and distribution are subject to the
5 //  Boost Software License, Version 1.0. (See accompanying file
6 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 
8 #include <pch_light.hpp>
9 #include "test_carlson.hpp"
10 
11 //
12 // DESCRIPTION:
13 // ~~~~~~~~~~~~
14 //
15 // This file tests the Carlson Elliptic Integrals.
16 // There are two sets of tests, spot
17 // tests which compare our results with the published test values,
18 // in Numerical Computation of Real or Complex Elliptic Integrals,
19 // B. C. Carlson: http://arxiv.org/abs/math.CA/9409227
20 // However, the bulk of the accuracy tests
21 // use values generated with NTL::RR at 1000-bit precision
22 // and our generic versions of these functions.
23 //
24 // Note that when this file is first run on a new platform many of
25 // these tests will fail: the default accuracy is 1 epsilon which
26 // is too tight for most platforms.  In this situation you will
27 // need to cast a human eye over the error rates reported and make
28 // a judgement as to whether they are acceptable.  Either way please
29 // report the results to the Boost mailing list.  Acceptable rates of
30 // error are marked up below as a series of regular expressions that
31 // identify the compiler/stdlib/platform/data-type/test-data/test-function
32 // along with the maximum expected peek and RMS mean errors for that
33 // test.
34 //
35 
expected_results()36 void expected_results()
37 {
38    //
39    // Define the max and mean errors expected for
40    // various compilers and platforms.
41    //
42    const char* largest_type;
43 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
44    if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
45    {
46       largest_type = "(long\\s+)?double";
47    }
48    else
49    {
50       largest_type = "long double";
51    }
52 #else
53    largest_type = "(long\\s+)?double";
54 #endif
55    //
56    // real long doubles:
57    //
58    if(boost::math::policies::digits<long double, boost::math::policies::policy<> >() > 53)
59    {
60       add_expected_result(
61          ".*",                          // compiler
62          ".*",                          // stdlib
63          BOOST_PLATFORM,                          // platform
64          largest_type,                  // test type(s)
65          ".*RJ.*",      // test data group
66          ".*", 1000, 50);  // test function
67       add_expected_result(
68          ".*",                          // compiler
69          ".*",                          // stdlib
70          BOOST_PLATFORM,                          // platform
71          "real_concept",                  // test type(s)
72          ".*RJ.*",      // test data group
73          ".*", 1000, 50);  // test function
74    }
75    //
76    // Catch all cases come last:
77    //
78    add_expected_result(
79       ".*",                          // compiler
80       ".*",                          // stdlib
81       ".*",                          // platform
82       largest_type,                  // test type(s)
83       ".*RJ.*",      // test data group
84       ".*", 250, 50);  // test function
85    add_expected_result(
86       ".*",                          // compiler
87       ".*",                          // stdlib
88       ".*",                          // platform
89       "real_concept",                  // test type(s)
90       ".*RJ.*",      // test data group
91       ".*", 250, 50);  // test function
92    add_expected_result(
93       ".*",                          // compiler
94       ".*",                          // stdlib
95       ".*",                          // platform
96       largest_type,                  // test type(s)
97       ".*",      // test data group
98       ".*", 25, 8);  // test function
99    add_expected_result(
100       ".*",                          // compiler
101       ".*",                          // stdlib
102       ".*",                          // platform
103       "real_concept",                  // test type(s)
104       ".*",      // test data group
105       ".*", 25, 8);  // 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 
BOOST_AUTO_TEST_CASE(test_main)115 BOOST_AUTO_TEST_CASE( test_main )
116 {
117     expected_results();
118     BOOST_MATH_CONTROL_FP;
119 
120     boost::math::ellint_rj(1.778e-31, 1.407e+18, 10.05, -4.83e-10);
121 
122     test_spots(0.0F, "float");
123     test_spots(0.0, "double");
124 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
125     test_spots(0.0L, "long double");
126 #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
127     test_spots(boost::math::concepts::real_concept(0), "real_concept");
128 #endif
129 #else
130    std::cout << "<note>The long double tests have been disabled on this platform "
131       "either because the long double overloads of the usual math functions are "
132       "not available at all, or because they are too inaccurate for these tests "
133       "to pass.</note>" << std::endl;
134 #endif
135 }
136 
137 /*
138 
139 test_carlson.cpp
140 Linking...
141 Embedding manifest...
142 Autorun "i:\boost-06-05-03-1300\libs\math\test\Math_test\debug\test_carlson.exe"
143 Running 1 test case...
144 Tests run with Microsoft Visual C++ version 8.0, Dinkumware standard library version 405, Win32
145 Testing: RF: Random data
146 boost::math::ellint_rf<float> Max = 0 RMS Mean=0
147 Testing: RC: Random data
148 boost::math::ellint_rc<float> Max = 0 RMS Mean=0
149 Testing: RJ: Random data
150 boost::math::ellint_rf<float> Max = 0 RMS Mean=0
151 Testing: RD: Random data
152 boost::math::ellint_rd<float> Max = 0 RMS Mean=0
153 Testing: RF: Random data
154 boost::math::ellint_rf<double> Max = 2.949 RMS Mean=0.7498
155     worst case at row: 377
156     { 3.418e+025, 2.594e-005, 3.264e-012, 6.169e-012 }
157 Testing: RC: Random data
158 boost::math::ellint_rc<double> Max = 2.396 RMS Mean=0.6283
159     worst case at row: 10
160     { 1.97e-029, 3.224e-025, 2.753e+012 }
161 Testing: RJ: Random data
162 boost::math::ellint_rf<double> Max = 152.9 RMS Mean=11.15
163     worst case at row: 633
164     { 1.876e+016, 0.000278, 3.796e-006, -4.412e-005, -1.656e-005 }
165 Testing: RD: Random data
166 boost::math::ellint_rd<double> Max = 2.586 RMS Mean=0.8614
167     worst case at row: 45
168     { 2.111e-020, 8.757e-026, 1.923e-023, 1.004e+033 }
169 Testing: RF: Random data
170 boost::math::ellint_rf<long double> Max = 2.949 RMS Mean=0.7498
171     worst case at row: 377
172     { 3.418e+025, 2.594e-005, 3.264e-012, 6.169e-012 }
173 Testing: RC: Random data
174 boost::math::ellint_rc<long double> Max = 2.396 RMS Mean=0.6283
175     worst case at row: 10
176     { 1.97e-029, 3.224e-025, 2.753e+012 }
177 Testing: RJ: Random data
178 boost::math::ellint_rf<long double> Max = 152.9 RMS Mean=11.15
179     worst case at row: 633
180     { 1.876e+016, 0.000278, 3.796e-006, -4.412e-005, -1.656e-005 }
181 Testing: RD: Random data
182 boost::math::ellint_rd<long double> Max = 2.586 RMS Mean=0.8614
183     worst case at row: 45
184     { 2.111e-020, 8.757e-026, 1.923e-023, 1.004e+033 }
185 Testing: RF: Random data
186 boost::math::ellint_rf<real_concept> Max = 2.949 RMS Mean=0.7498
187     worst case at row: 377
188     { 3.418e+025, 2.594e-005, 3.264e-012, 6.169e-012 }
189 Testing: RC: Random data
190 boost::math::ellint_rc<real_concept> Max = 2.396 RMS Mean=0.6283
191     worst case at row: 10
192     { 1.97e-029, 3.224e-025, 2.753e+012 }
193 Testing: RJ: Random data
194 boost::math::ellint_rf<real_concept> Max = 152.9 RMS Mean=11.15
195     worst case at row: 633
196     { 1.876e+016, 0.000278, 3.796e-006, -4.412e-005, -1.656e-005 }
197 Testing: RD: Random data
198 boost::math::ellint_rd<real_concept> Max = 2.586 RMS Mean=0.8614
199     worst case at row: 45
200     { 2.111e-020, 8.757e-026, 1.923e-023, 1.004e+033 }
201 *** No errors detected
202 
203 */
204