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 #define BOOST_MATH_MAX_SERIES_ITERATION_POLICY 10000000
8 #define BOOST_MATH_USE_MPFR
10 #include <boost/math/special_functions/hypergeometric_1F1.hpp>
11 #include <boost/math/special_functions/hypergeometric_pFq.hpp>
12 #include <boost/math/constants/constants.hpp>
13 #include <boost/lexical_cast.hpp>
16 #include <boost/math/tools/test_data.hpp>
17 #include <boost/random.hpp>
19 #include <boost/multiprecision/mpfr.hpp>
21 using namespace boost::math::tools
;
22 using namespace boost::math
;
24 using namespace boost::multiprecision
;
27 struct hypergeometric_1f1_gen
29 mp_t
operator()(mp_t a1
, mp_t a2
, mp_t z
)
33 result
= (mp_t
)log(abs(boost::math::hypergeometric_pFq_precision({ mpfr_float(a1
) }, { mpfr_float(a2
) }, mpfr_float(z
), 70, 25.0)));
34 std::cout
<< a1
<< " " << a2
<< " " << z
<< " " << result
<< std::endl
;
38 throw std::domain_error("");
40 if (fabs(result
) > (std::numeric_limits
<double>::max
)())
42 std::cout
<< "Rejecting over large value\n";
43 throw std::domain_error("");
45 if (fabs(result
) < 1/1024.0)
47 std::cout
<< "Rejecting over small value\n";
48 throw std::domain_error("");
55 int main(int, char* [])
57 parameter_info
<mp_t
> arg1
, arg2
, arg3
;
60 std::cout
<< "Welcome.\n"
61 "This program will generate spot tests for 1F1 (Yeh!!):\n";
67 random_ns::mt19937 rnd
;
68 random_ns::uniform_real_distribution
<float> ur_a(0, 1);
103 for (unsigned i
= 0; i
< v
.size(); ++i
)
105 for (unsigned j
= 0; j
< v
.size(); ++j
)
107 for (unsigned k
= 0; k
< v
.size(); ++k
)
109 std::cout
<< i
<< " " << j
<< " " << k
<< std::endl
;
110 std::cout
<< v
[i
] << " " << (v
[j
] * 3) / 2 << " " << (v
[k
] * 5) / 4 << std::endl
;
111 arg1
= make_single_param(v
[i
]);
112 arg2
= make_single_param(mp_t((v
[j
] * 3) / 2));
113 arg3
= make_single_param(mp_t((v
[k
] * 5) / 4));
114 data
.insert(hypergeometric_1f1_gen(), arg1
, arg2
, arg3
);
120 std::cout
<< "Enter name of test data file [default=hypergeometric_1f1.ipp]";
121 std::getline(std::cin
, line
);
122 boost::algorithm::trim(line
);
124 line
= "hypergeometric_1f1.ipp";
125 std::ofstream
ofs(line
.c_str());
126 ofs
<< std::scientific
<< std::setprecision(40);
127 write_code(ofs
, data
, line
.c_str());