]>
git.proxmox.com Git - ceph.git/blob - 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)
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>
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 #include <libs/math/test/table_type.hpp>
23 #define SC_(x) static_cast<double>(x)
24 #include <libs/math/test/ibeta_int_data.ipp>
26 int main(int, char* [])
28 std::cout
<< "Enter name of test data file [default=ibeta_derivative_data.ipp]";
30 std::getline(std::cin
, line
);
31 boost::algorithm::trim(line
);
33 line
= "ibeta_derivative_data.ipp";
34 std::ofstream
ofs(line
.c_str());
35 ofs
<< std::scientific
<< std::setprecision(40);
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"
43 "static const boost::array<boost::array<typename table_type<T>::type, 4>, " << ibeta_int_data
.size() << "> ibeta_derivative_small_data = { {\n";
46 for(unsigned i
= 0; i
< ibeta_int_data
.size(); ++i
)
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]);
52 std::cout
<< a
<< std::endl
;
53 std::cout
<< b
<< std::endl
;
54 std::cout
<< x
<< std::endl
;
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
;
59 ofs
<< "{{ SC_(" << a
<< "), SC_(" << b
<< "), SC_(" << x
<< "), SC_(" << d
<< ") }}\n";