Imported Upstream version 1.57.0
[platform/upstream/boost.git] / libs / math / test / test_hermite.cpp
1 //  Copyright John Maddock 2006, 2007
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_hermite.hpp"
10
11 //
12 // DESCRIPTION:
13 // ~~~~~~~~~~~~
14 //
15 // This file tests the Hermite polynomials.  
16 // There are two sets of tests, spot
17 // tests which compare our results with selected values computed
18 // using the online special function calculator at 
19 // functions.wolfram.com, while the bulk of the accuracy tests
20 // use values generated with NTL::RR at 1000-bit precision
21 // and our generic versions of these functions.
22 //
23 // Note that when this file is first run on a new platform many of
24 // these tests will fail: the default accuracy is 1 epsilon which
25 // is too tight for most platforms.  In this situation you will 
26 // need to cast a human eye over the error rates reported and make
27 // a judgement as to whether they are acceptable.  Either way please
28 // report the results to the Boost mailing list.  Acceptable rates of
29 // error are marked up below as a series of regular expressions that
30 // identify the compiler/stdlib/platform/data-type/test-data/test-function
31 // along with the maximum expected peek and RMS mean errors for that
32 // test.
33 //
34
35 void expected_results()
36 {
37    //
38    // Define the max and mean errors expected for
39    // various compilers and platforms.
40    //
41    const char* largest_type;
42 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
43    if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
44    {
45       largest_type = "(long\\s+)?double";
46    }
47    else
48    {
49       largest_type = "long double";
50    }
51 #else
52    largest_type = "(long\\s+)?double";
53 #endif
54
55    //
56    // Catch all cases come last:
57    //
58    add_expected_result(
59       ".*",                          // compiler
60       ".*",                          // stdlib
61       ".*",                          // platform
62       largest_type,                  // test type(s)
63       ".*",      // test data group
64       "boost::math::hermite", 10, 5);  // test function
65    add_expected_result(
66       ".*",                          // compiler
67       ".*",                          // stdlib
68       ".*",                          // platform
69       "real_concept",                  // test type(s)
70       ".*",      // test data group
71       "boost::math::hermite", 10, 5);  // test function
72    //
73    // Finish off by printing out the compiler/stdlib/platform names,
74    // we do this to make it easier to mark up expected error rates.
75    //
76    std::cout << "Tests run with " << BOOST_COMPILER << ", " 
77       << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
78 }
79
80 BOOST_AUTO_TEST_CASE( test_main )
81 {
82    BOOST_MATH_CONTROL_FP;
83
84    boost::math::hermite(51, 915.0);
85
86 #ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS
87    test_spots(0.0F, "float");
88 #endif
89    test_spots(0.0, "double");
90 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
91    test_spots(0.0L, "long double");
92    test_spots(boost::math::concepts::real_concept(0.1), "real_concept");
93 #endif
94
95    expected_results();
96
97 #ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS
98    test_hermite(0.1F, "float");
99 #endif
100    test_hermite(0.1, "double");
101 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
102    test_hermite(0.1L, "long double");
103 #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
104    test_hermite(boost::math::concepts::real_concept(0.1), "real_concept");
105 #endif
106 #else
107    std::cout << "<note>The long double tests have been disabled on this platform "
108       "either because the long double overloads of the usual math functions are "
109       "not available at all, or because they are too inaccurate for these tests "
110       "to pass.</note>" << std::cout;
111 #endif
112    
113 }
114
115
116