2
0
mirror of https://github.com/boostorg/math.git synced 2026-01-23 17:52:09 +00:00
Files
math/tools/tgamma_ratio_data.cpp
John Maddock c3611d0c6b Added factorials and gamma function ratios.
Updated incomplete beta with BGRAT routine from Didonato and Morris.
Added even and odd polynomials.
Lots of small tweeks.


[SVN r2972]
2006-06-08 16:08:05 +00:00

92 lines
2.5 KiB
C++

// (C) Copyright John Maddock 2006.
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/math/tools/ntl.hpp>
#include <boost/math/special_functions/gamma.hpp>
#include <boost/math/tools/test.hpp>
#include <fstream>
#include <boost/math/tools/test_data.hpp>
#include "ntl_rr_lanczos.hpp"
using namespace boost::math::tools;
using namespace std;
std::tr1::tuple<NTL::RR, NTL::RR>
tgamma_ratio(const NTL::RR& a, const NTL::RR& delta)
{
NTL::RR tg = boost::math::tgamma(a);
return std::tr1::make_tuple(tg / boost::math::tgamma(a + delta), tg / boost::math::tgamma(a - delta));
}
NTL::RR tgamma_ratio2(const NTL::RR& a, const NTL::RR& b)
{
return boost::math::tgamma(a) / boost::math::tgamma(b);
}
int main(int argc, char* argv[])
{
NTL::RR::SetPrecision(1000);
NTL::RR::SetOutputPrecision(40);
parameter_info<NTL::RR> arg1, arg2;
test_data<NTL::RR> data;
bool cont;
std::string line;
if((argc >= 2) && (strcmp(argv[1], "--ratio") == 0))
{
std::cout << "Welcome.\n"
"This program will generate spot tests for the function tgamma_ratio(a, b)\n\n";
do{
if(0 == get_user_parameter_info(arg1, "a"))
return 1;
if(0 == get_user_parameter_info(arg2, "b"))
return 1;
data.insert(&tgamma_ratio2, arg1, arg2);
std::cout << "Any more data [y/n]?";
std::getline(std::cin, line);
boost::algorithm::trim(line);
cont = (line == "y");
}while(cont);
}
else
{
std::cout << "Welcome.\n"
"This program will generate spot tests for the function tgamma_delta_ratio(a, delta)\n\n";
do{
if(0 == get_user_parameter_info(arg1, "a"))
return 1;
if(0 == get_user_parameter_info(arg2, "delta"))
return 1;
data.insert(&tgamma_ratio, arg1, arg2);
std::cout << "Any more data [y/n]?";
std::getline(std::cin, line);
boost::algorithm::trim(line);
cont = (line == "y");
}while(cont);
}
std::cout << "Enter name of test data file [default=tgamma_ratio_data.ipp]";
std::getline(std::cin, line);
boost::algorithm::trim(line);
if(line == "")
line = "tgamma_ratio_data.ipp";
std::ofstream ofs(line.c_str());
ofs << std::scientific;
write_code(ofs, data, "tgamma_ratio_data");
return 0;
}