// (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 #include #include #include #include #include "ntl_rr_lanczos.hpp" using namespace boost::math::tools; using namespace std; std::tr1::tuple 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 arg1, arg2; test_data 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; }