]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/tools/gamma_P_inva_data.cpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / libs / math / tools / gamma_P_inva_data.cpp
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 #include "mp_t.hpp"
7 #include <boost/math/special_functions/gamma.hpp>
8 #include <boost/math/constants/constants.hpp>
9 #include <boost/lexical_cast.hpp>
10 #include <fstream>
11 #include <boost/math/tools/test_data.hpp>
12
13 using namespace boost::math::tools;
14
15 //
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
19 // be thrown off:
20 //
21 float external_f;
22 float force_truncate(const float* f)
23 {
24 external_f = *f;
25 return external_f;
26 }
27
28 float truncate_to_float(mp_t r)
29 {
30 float f = boost::math::tools::real_cast<float>(r);
31 return force_truncate(&f);
32 }
33
34 struct gamma_inverse_generator_a
35 {
36 boost::math::tuple<mp_t, mp_t> operator()(const mp_t x, const mp_t p)
37 {
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);
42 }
43 };
44
45
46 int main(int argc, char*argv [])
47 {
48 bool cont;
49 std::string line;
50
51 parameter_info<mp_t> arg1, arg2;
52 test_data<mp_t> data;
53
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";
57
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);
61
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");
66
67 return 0;
68 }
69