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)
7 #include <boost/math/special_functions/gamma.hpp>
8 #include <boost/math/constants/constants.hpp>
9 #include <boost/lexical_cast.hpp>
11 #include <boost/math/tools/test_data.hpp>
13 using namespace boost::math::tools
;
16 // Force truncation to float precision of input values:
17 // we must ensure that the input values are exactly representable
18 // in whatever type we are testing, or the output values will all
22 float force_truncate(const float* f
)
28 float truncate_to_float(mp_t r
)
30 float f
= boost::math::tools::real_cast
<float>(r
);
31 return force_truncate(&f
);
34 struct gamma_inverse_generator_a
36 boost::math::tuple
<mp_t
, mp_t
> operator()(const mp_t x
, const mp_t p
)
38 mp_t x1
= boost::math::gamma_p_inva(x
, p
);
39 mp_t x2
= boost::math::gamma_q_inva(x
, p
);
40 std::cout
<< "Inverse for " << x
<< " " << p
<< std::endl
;
41 return boost::math::make_tuple(x1
, x2
);
46 int main(int argc
, char*argv
[])
51 parameter_info
<mp_t
> arg1
, arg2
;
54 std::cout
<< "Welcome.\n"
55 "This program will generate spot tests for the inverse incomplete gamma function:\n"
56 " gamma_p_inva(a, p) and gamma_q_inva(a, q)\n\n";
58 arg1
= make_power_param
<mp_t
>(mp_t(0), -4, 24);
59 arg2
= make_random_param
<mp_t
>(mp_t(0), mp_t(1), 15);
60 data
.insert(gamma_inverse_generator_a(), arg1
, arg2
);
62 line
= "igamma_inva_data.ipp";
63 std::ofstream
ofs(line
.c_str());
64 ofs
<< std::scientific
<< std::setprecision(40);
65 write_code(ofs
, data
, "igamma_inva_data");