]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/tools/ibeta_derivative_data.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / math / tools / ibeta_derivative_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 <boost/math/special_functions/gamma.hpp>
7 #include <boost/math/special_functions/beta.hpp>
8 #include <boost/math/constants/constants.hpp>
9 #include <boost/lexical_cast.hpp>
10 #include <fstream>
11 #include <map>
12 #include <boost/math/tools/test_data.hpp>
13 #include <boost/random.hpp>
14 #include "mp_t.hpp"
15
16 using namespace boost::math::tools;
17 using namespace boost::math;
18 using namespace std;
19
20 #include <libs/math/test/table_type.hpp>
21
22 #define T double
23 #define SC_(x) static_cast<double>(x)
24 #include <libs/math/test/ibeta_int_data.ipp>
25
26 int main(int, char* [])
27 {
28 std::cout << "Enter name of test data file [default=ibeta_derivative_data.ipp]";
29 std::string line;
30 std::getline(std::cin, line);
31 boost::algorithm::trim(line);
32 if(line == "")
33 line = "ibeta_derivative_data.ipp";
34 std::ofstream ofs(line.c_str());
35 ofs << std::scientific << std::setprecision(40);
36
37 ofs <<
38 "// (C) Copyright John Maddock 2006.\n"
39 "// Use, modification and distribution are subject to the\n"
40 "// Boost Software License, Version 1.0. (See accompanying file\n"
41 "// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n"
42 "\n\n"
43 "static const boost::array<boost::array<typename table_type<T>::type, 4>, " << ibeta_int_data.size() << "> ibeta_derivative_small_data = { {\n";
44
45
46 for(unsigned i = 0; i < ibeta_int_data.size(); ++i)
47 {
48 mp_t a(ibeta_int_data[i][0]);
49 mp_t b(ibeta_int_data[i][1]);
50 mp_t x(ibeta_int_data[i][2]);
51
52 std::cout << a << std::endl;
53 std::cout << b << std::endl;
54 std::cout << x << std::endl;
55
56 mp_t bet = exp(boost::math::lgamma(a) + boost::math::lgamma(b) - boost::math::lgamma(a + b));
57 mp_t d = pow(1 - x, b - 1) * pow(x, a - 1) / bet;
58
59 ofs << "{{ SC_(" << a << "), SC_(" << b << "), SC_(" << x << "), SC_(" << d << ") }}\n";
60 }
61
62 ofs << "}};\n\n";
63
64
65 return 0;
66 }
67
68