]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/test/test_legendre.cpp
2d5c93a1bbb1f6177da650071d66708fcb460b56
1 // (C) Copyright John Maddock 2006.
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)
6 #include <pch_light.hpp>
7 #include "test_legendre.hpp"
13 // This file tests the legendre polynomials.
14 // There are two sets of tests, spot
15 // tests which compare our results with selected values computed
16 // using the online special function calculator at
17 // functions.wolfram.com, while the bulk of the accuracy tests
18 // use values generated with NTL::RR at 1000-bit precision
19 // and our generic versions of these functions.
21 // Note that when this file is first run on a new platform many of
22 // these tests will fail: the default accuracy is 1 epsilon which
23 // is too tight for most platforms. In this situation you will
24 // need to cast a human eye over the error rates reported and make
25 // a judgement as to whether they are acceptable. Either way please
26 // report the results to the Boost mailing list. Acceptable rates of
27 // error are marked up below as a series of regular expressions that
28 // identify the compiler/stdlib/platform/data-type/test-data/test-function
29 // along with the maximum expected peek and RMS mean errors for that
33 void expected_results()
36 // Define the max and mean errors expected for
37 // various compilers and platforms.
39 const char* largest_type
;
40 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
41 if(boost::math::policies::digits
<double, boost::math::policies::policy
<> >() == boost::math::policies::digits
<long double, boost::math::policies::policy
<> >())
43 largest_type
= "(long\\s+)?double";
47 largest_type
= "long double";
50 largest_type
= "(long\\s+)?double";
55 if((std::numeric_limits
<long double>::digits
<= 64)
56 && (std::numeric_limits
<long double>::digits
!= std::numeric_limits
<double>::digits
))
58 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
63 "double", // test type(s)
64 ".*", // test data group
65 ".*", 10, 5); // test function
68 if(std::numeric_limits
<long double>::digits
== 64)
74 largest_type
, // test type(s)
75 "Legendre Polynomials.*Large.*", // test data group
76 "legendre_p", 1000, 200); // test function
78 "Intel.*", // compiler
81 largest_type
, // test type(s)
82 "Legendre Polynomials.*Large.*", // test data group
83 "legendre_q", 10000, 1000); // test function
88 largest_type
, // test type(s)
89 "Legendre Polynomials.*Large.*", // test data group
90 "legendre_q", 7000, 1000); // test function
95 "real_concept", // test type(s)
96 "Legendre Polynomials.*Large.*", // test data group
97 "legendre_p", 1000, 200); // test function
102 "real_concept", // test type(s)
103 "Legendre Polynomials.*Large.*", // test data group
104 "legendre_q", 7000, 1000); // test function
107 // Catch all cases come last:
113 largest_type
, // test type(s)
114 "Legendre Polynomials.*Large.*", // test data group
115 "legendre_p", 500, 200); // test function
120 largest_type
, // test type(s)
121 "Legendre Polynomials.*Large.*", // test data group
122 "legendre_q", 5400, 500); // test function
127 largest_type
, // test type(s)
128 "Legendre Polynomials.*", // test data group
129 "legendre_p", 300, 80); // test function
134 largest_type
, // test type(s)
135 "Legendre Polynomials.*", // test data group
136 "legendre_q", 100, 50); // test function
138 "Intel.*", // compiler
141 largest_type
, // test type(s)
142 "Associated Legendre Polynomials.*", // test data group
143 ".*", 300, 20); // test function
148 largest_type
, // test type(s)
149 "Associated Legendre Polynomials.*", // test data group
150 ".*", 200, 20); // test function
156 "real_concept", // test type(s)
157 "Legendre Polynomials.*Large.*", // test data group
158 "legendre_p", 500, 200); // test function
163 "real_concept", // test type(s)
164 "Legendre Polynomials.*Large.*", // test data group
165 "legendre_q", 5400, 500); // test function
170 "real_concept", // test type(s)
171 "Legendre Polynomials.*", // test data group
172 "legendre_p", 300, 80); // test function
177 "real_concept", // test type(s)
178 "Legendre Polynomials.*", // test data group
179 "legendre_q", 100, 50); // test function
184 "real_concept", // test type(s)
185 "Associated Legendre Polynomials.*", // test data group
186 ".*", 200, 20); // test function
188 // Finish off by printing out the compiler/stdlib/platform names,
189 // we do this to make it easier to mark up expected error rates.
191 std::cout
<< "Tests run with " << BOOST_COMPILER
<< ", "
192 << BOOST_STDLIB
<< ", " << BOOST_PLATFORM
<< std::endl
;
195 BOOST_AUTO_TEST_CASE( test_main
)
197 BOOST_MATH_CONTROL_FP
;
198 test_spots(0.0F
, "float");
199 test_spots(0.0, "double");
200 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
201 test_spots(0.0L, "long double");
202 test_spots(boost::math::concepts::real_concept(0.1), "real_concept");
207 test_legendre_p(0.1F
, "float");
208 test_legendre_p(0.1, "double");
209 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
210 test_legendre_p(0.1L, "long double");
211 #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
212 test_legendre_p(boost::math::concepts::real_concept(0.1), "real_concept");
215 std::cout
<< "<note>The long double tests have been disabled on this platform "
216 "either because the long double overloads of the usual math functions are "
217 "not available at all, or because they are too inaccurate for these tests "
218 "to pass.</note>" << std::endl
;