]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Copyright John Maddock 2012 |
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 | ||
8 | #define BOOST_MATH_OVERFLOW_ERROR_POLICY ignore_error | |
9 | #define BOOST_TEST_MAIN | |
10 | #include <boost/test/unit_test.hpp> | |
92f5a8d4 | 11 | #include <boost/test/tools/floating_point_comparison.hpp> |
7c673cae FG |
12 | #include <boost/math/special_functions/math_fwd.hpp> |
13 | #include <boost/math/concepts/real_concept.hpp> | |
14 | #include <boost/array.hpp> | |
15 | #include <iostream> | |
16 | #include <iomanip> | |
17 | ||
18 | #ifdef _MSC_VER | |
19 | # pragma warning(disable : 4756 4127) // overflow in constant arithmetic | |
20 | // Constants are too big for float case, but this doesn't matter for test. | |
21 | #endif | |
22 | ||
23 | // | |
24 | // DESCRIPTION: | |
25 | // ~~~~~~~~~~~~ | |
26 | // | |
27 | // This file tests the Airy functions. | |
28 | // These are basically just a few spot tests, since the underlying implementation | |
29 | // is the same as for the Bessel functions. | |
30 | // | |
31 | template <class T> | |
32 | void test_airy(T, const char* name) | |
33 | { | |
34 | std::cout << "Testing type " << name << std::endl; | |
35 | ||
36 | static const boost::array<boost::array<T, 5>, 8> data = | |
37 | {{ | |
38 | // Values are x, Ai, Bi, Ai', Bi'. | |
39 | // Calculated from functions.wolfram.com. | |
40 | {{ 0, static_cast<T>(0.355028053887817239260063186004183176397979174199177240583327L), static_cast<T>(0.614926627446000735150922369093613553594728188648596505040879L), static_cast<T>(-0.258819403792806798405183560189203963479091138354934582210002L), static_cast<T>(0.448288357353826357914823710398828390866226799212262061082809L) }}, | |
41 | {{ 2, static_cast<T>(0.0349241304232743791353220807918076097610602138975832071886699L), static_cast<T>(3.29809499997821471028060442522345242200397596340362078768292L), static_cast<T>(-0.0530903844336536317039991858787034912485609900458779926304030L), static_cast<T>(4.10068204993288988938203407917793529439024461377513711983771L) }}, | |
42 | {{ 3.5, static_cast<T>(0.00258409878698963496327714478330027845019631096464789073425468L), static_cast<T>(33.0555067546114794142573129819217946861266278143724855010951L), static_cast<T>(-0.00500441396795258283203024967883836790716278377542974739809987L), static_cast<T>(59.1643195813609870345742121795224602529063343063320217229383L) }}, | |
43 | {{ 30.5, static_cast<T>(2.04253461666926015963302258449952681287194929082634196439857e-50L), static_cast<T>(1.41092256201712698413071856671990267572381736486242769613348e48L), static_cast<T>(-1.12969466271996376602221721397236452019046628449363103927812e-49L), static_cast<T>(7.78046629440950280615411694840600772185863288897663300007879e48L) }}, | |
44 | {{ -2, static_cast<T>(0.227407428201685575991924436037873799460772225417096716495790L), static_cast<T>(-0.412302587956398488083234054611461042034534834472404728823877L), static_cast<T>(0.618259020741691041406264291332475282915777945124146942159898L), static_cast<T>(0.278795166921169522685097569410983241403000593451631000239732L) }}, | |
45 | {{ -3.5, static_cast<T>(-0.375533823140431911934396951580170239543268576378264063902563L), static_cast<T>(0.168939837481058611843442769540943269911562243926304070915824L), static_cast<T>(-0.343443433454048146287937374098698857094194220958713294264017L), static_cast<T>(-0.693116284907288801752443612670580462699702668014978495343697L) }}, | |
46 | {{ -30.25, static_cast<T>(-0.236900428491559731119806902381433570300271552218956227857722L), static_cast<T>(0.0418614989839147441219283537268101850442118139150748075124111L), static_cast<T>(-0.232197332372689274917364138870840123428255785603863926579897L), static_cast<T>(-1.30261375952554697768880873095691151213006925411329957440342L) }}, | |
47 | {{ -300.5, static_cast<T>(-0.117584304761702008955433457721670950077867326839023449546057L), static_cast<T>(0.0673518035440918806545676478730240310819758211028871823560384), static_cast<T>(-1.16763702262473888724431076711846459336993902544926162874376L), static_cast<T>(-2.03826035550300900666977975504950803669545593208969273694133L) }}, | |
48 | }}; | |
49 | ||
50 | T tol = boost::math::tools::epsilon<T>() * 800; | |
51 | for(unsigned i = 0; i < data.size(); ++i) | |
52 | { | |
53 | BOOST_CHECK_CLOSE_FRACTION(data[i][1], boost::math::airy_ai(data[i][0]), tol); | |
54 | if(boost::math::isfinite(data[i][2])) | |
55 | BOOST_CHECK_CLOSE_FRACTION(data[i][2], boost::math::airy_bi(data[i][0]), tol); | |
56 | BOOST_CHECK_CLOSE_FRACTION(data[i][3], boost::math::airy_ai_prime(data[i][0]), tol); | |
57 | if(boost::math::isfinite(data[i][4])) | |
58 | BOOST_CHECK_CLOSE_FRACTION(data[i][4], boost::math::airy_bi_prime(data[i][0]), tol); | |
59 | } | |
60 | } | |
61 | ||
62 | ||
63 | BOOST_AUTO_TEST_CASE( test_main ) | |
64 | { | |
65 | #ifdef TEST_GSL | |
66 | gsl_set_error_handler_off(); | |
67 | #endif | |
68 | BOOST_MATH_CONTROL_FP; | |
69 | ||
70 | #ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS | |
71 | test_airy(0.1F, "float"); | |
72 | #endif | |
73 | test_airy(0.1, "double"); | |
74 | #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS | |
75 | test_airy(0.1L, "long double"); | |
76 | test_airy(boost::math::concepts::real_concept(0), "real_concept"); | |
77 | #else | |
78 | std::cout << "<note>The long double tests have been disabled on this platform " | |
79 | "either because the long double overloads of the usual math functions are " | |
80 | "not available at all, or because they are too inaccurate for these tests " | |
81 | "to pass.</note>" << std::endl; | |
82 | #endif | |
83 | } | |
84 | ||
85 | ||
86 | ||
87 |