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)
5
6 #define BOOST_MATH_MAX_SERIES_ITERATION_POLICY 10000000
7
8 #include <boost/math/special_functions/hypergeometric_1f1.hpp>
9 #include <boost/math/special_functions/hypergeometric_pfq.hpp>
10 #include <boost/math/constants/constants.hpp>
11 #include <boost/lexical_cast.hpp>
12 #include <fstream>
13 #include <map>
14 #include <boost/math/tools/test_data.hpp>
15 #include <boost/random.hpp>
16 #define BOOST_MATH_USE_MPFR
17 #include "mp_t.hpp"
18
19 #include <boost/multiprecision/mpfr.hpp>
20
21 using namespace boost::math::tools;
22 using namespace boost::math;
23 using namespace std;
24 using namespace boost::multiprecision;
25
26
27 struct hypergeometric_1f1_gen
28 {
operator ()hypergeometric_1f1_gen29 mp_t operator()(mp_t a1, mp_t a2, mp_t z)
30 {
31 mp_t result;
32 try {
33 result = (mp_t)boost::math::hypergeometric_pFq_precision({ mpfr_float(a1) }, { mpfr_float(mpfr_float(a2)) }, mpfr_float(z), 50, 25.0) / boost::multiprecision::tgamma(a2);
34 std::cout << a1 << " " << a2 << " " << z << " " << result << std::endl;
35 }
36 catch (...)
37 {
38 throw std::domain_error("");
39 }
40 if (fabs(result) > (std::numeric_limits<double>::max)())
41 {
42 std::cout << "Rejecting over large value\n";
43 throw std::domain_error("");
44 }
45 return result;
46 }
47 };
48
49
main(int,char * [])50 int main(int, char* [])
51 {
52 parameter_info<mp_t> arg1, arg2, arg3;
53 test_data<mp_t> data;
54
55 std::cout << "Welcome.\n"
56 "This program will generate spot tests for 1F1 (Yeh!!):\n";
57
58 std::string line;
59 //bool cont;
60
61 std::vector<mp_t> v;
62 random_ns::mt19937 rnd;
63 random_ns::uniform_real_distribution<float> ur_a(0, 1);
64
65 mp_t p = ur_a(rnd);
66 p *= 1e6;
67 v.push_back(p);
68 v.push_back(-p);
69 p = ur_a(rnd);
70 p *= 1e5;
71 v.push_back(p);
72 v.push_back(-p);
73 p = ur_a(rnd);
74 p *= 1e4;
75 v.push_back(p);
76 v.push_back(-p);
77 p = ur_a(rnd);
78 p *= 1e3;
79 v.push_back(p);
80 v.push_back(-p);
81 p = ur_a(rnd);
82 p *= 1e2;
83 v.push_back(p);
84 v.push_back(-p);
85 p = ur_a(rnd);
86 p *= 1e-5;
87 v.push_back(p);
88 v.push_back(-p);
89 p = ur_a(rnd);
90 p *= 1e-12;
91 v.push_back(p);
92 v.push_back(-p);
93 p = ur_a(rnd);
94 p *= 1e-30;
95 v.push_back(p);
96 v.push_back(-p);
97
98 for (unsigned i = 0; i < v.size(); ++i)
99 {
100 for (unsigned j = 0; j < v.size(); ++j)
101 {
102 for (unsigned k = 0; k < v.size(); ++k)
103 {
104 std::cout << i << " " << j << " " << k << std::endl;
105 std::cout << v[i] << " " << (v[j] * 3) / 2 << " " << (v[j] * 5) / 4 << std::endl;
106 arg1 = make_single_param(v[i]);
107 arg2 = make_single_param(mp_t((v[j] * 3) / 2));
108 arg3 = make_single_param(mp_t((v[k] * 5) / 4));
109 data.insert(hypergeometric_1f1_gen(), arg1, arg2, arg3);
110 }
111 }
112 }
113
114
115 std::cout << "Enter name of test data file [default=hypergeometric_1f1.ipp]";
116 std::getline(std::cin, line);
117 boost::algorithm::trim(line);
118 if(line == "")
119 line = "hypergeometric_1f1.ipp";
120 std::ofstream ofs(line.c_str());
121 ofs << std::scientific << std::setprecision(40);
122 write_code(ofs, data, line.c_str());
123
124 return 0;
125 }
126
127
128