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
7 #define BOOST_MATH_USE_MPFR
9 #include <boost/math/special_functions/hypergeometric_1F1.hpp>
10 #include <boost/math/special_functions/hypergeometric_pFq.hpp>
11 #include <boost/math/constants/constants.hpp>
12 #include <boost/lexical_cast.hpp>
15 #include <boost/math/tools/test_data.hpp>
16 #include <boost/random.hpp>
18 #include <boost/multiprecision/mpfr.hpp>
20 using namespace boost::math::tools
;
21 using namespace boost::math
;
23 using namespace boost::multiprecision
;
26 struct hypergeometric_1f1_gen
28 mp_t
operator()(mp_t a1
, mp_t a2
, mp_t z
)
32 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
);
33 std::cout
<< a1
<< " " << a2
<< " " << z
<< " " << result
<< std::endl
;
37 throw std::domain_error("");
39 if (fabs(result
) > (std::numeric_limits
<double>::max
)())
41 std::cout
<< "Rejecting over large value\n";
42 throw std::domain_error("");
49 int main(int, char* [])
51 parameter_info
<mp_t
> arg1
, arg2
, arg3
;
54 std::cout
<< "Welcome.\n"
55 "This program will generate spot tests for 1F1 (Yeh!!):\n";
61 random_ns::mt19937 rnd
;
62 random_ns::uniform_real_distribution
<float> ur_a(0, 1);
97 for (unsigned i
= 0; i
< v
.size(); ++i
)
99 for (unsigned j
= 0; j
< v
.size(); ++j
)
101 for (unsigned k
= 0; k
< v
.size(); ++k
)
103 std::cout
<< i
<< " " << j
<< " " << k
<< std::endl
;
104 std::cout
<< v
[i
] << " " << (v
[j
] * 3) / 2 << " " << (v
[j
] * 5) / 4 << std::endl
;
105 arg1
= make_single_param(v
[i
]);
106 arg2
= make_single_param(mp_t((v
[j
] * 3) / 2));
107 arg3
= make_single_param(mp_t((v
[k
] * 5) / 4));
108 data
.insert(hypergeometric_1f1_gen(), arg1
, arg2
, arg3
);
114 std::cout
<< "Enter name of test data file [default=hypergeometric_1f1.ipp]";
115 std::getline(std::cin
, line
);
116 boost::algorithm::trim(line
);
118 line
= "hypergeometric_1f1.ipp";
119 std::ofstream
ofs(line
.c_str());
120 ofs
<< std::scientific
<< std::setprecision(40);
121 write_code(ofs
, data
, line
.c_str());