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 #include <boost/math/constants/constants.hpp>
9 #include <boost/lexical_cast.hpp>
12 #include <boost/math/tools/test_data.hpp>
13 #include <boost/random.hpp>
16 using namespace boost::math::tools
;
17 using namespace boost::math
;
20 struct hypergeometric_1f2_gen
22 mp_t
operator()(mp_t a1
, mp_t b1
, mp_t b2
, mp_t z
)
32 abs_result
+= fabs(term
);
33 if (fabs(result
) * boost::math::tools::epsilon
<mp_t
>() > fabs(term
))
45 if (abs_result
* boost::math::tools::epsilon
<mp_t
>() / fabs(result
) > 1e-40)
46 throw std::domain_error("Unable to calculate result");
48 std::cout
<< a1
<< " " << b1
<< " " << b2
<< " " << z
<< " " << result
<< std::endl
;
53 int main(int, char* [])
55 parameter_info
<mp_t
> arg1
, arg2
, arg3
, arg4
;
58 std::cout
<< "Welcome.\n"
59 "This program will generate spot tests for 2F0:\n";
67 std::cout
<< "Enter the range to calculate over for a1, b1 and b2 (single value, range will be -x to x): ";
71 std::cout
<< "Enter the range to calculate over for z (single value, range will be -x to x): ";
75 std::cout
<< "Enter how many test points to calculate: ";
76 std::cin
>> num_spots
;
79 random_ns::mt19937 rnd
;
80 random_ns::uniform_real_distribution
<float> ur_a(-range
, range
);
81 random_ns::uniform_real_distribution
<float> ur_z(-z_range
, z_range
);
90 arg1
= make_single_param(a1
);
91 arg2
= make_single_param(b1
);
92 arg3
= make_single_param(b2
);
93 arg4
= make_single_param(z
);
94 data
.insert(hypergeometric_1f2_gen(), arg1
, arg2
, arg3
, arg4
);
95 } while (num_spots
--);
97 std::cout
<< "Any more data?";
104 std::cout
<< "Enter name of test data file [default=hypergeometric_1f2.ipp]";
105 std::getline(std::cin
, line
);
106 boost::algorithm::trim(line
);
108 line
= "hypergeometric_1f2.ipp";
109 std::ofstream
ofs(line
.c_str());
110 ofs
<< std::scientific
<< std::setprecision(40);
111 write_code(ofs
, data
, line
.c_str());