tgamma_large_data.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // Copyright John Maddock 2013.
  2. // Use, modification and distribution are subject to the
  3. // Boost Software License, Version 1.0.
  4. // (See accompanying file LICENSE_1_0.txt
  5. // or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //[special_data_example
  7. #include <boost/multiprecision/mpfr.hpp>
  8. #include <boost/math/tools/test_data.hpp>
  9. #include <boost/test/included/prg_exec_monitor.hpp>
  10. #include <boost/math/tools/tuple.hpp>
  11. #include <fstream>
  12. using namespace boost::math::tools;
  13. using namespace boost::math;
  14. using namespace std;
  15. using namespace boost::multiprecision;
  16. typedef number<mpfr_float_backend<1000> > mp_type;
  17. boost::math::tuple<mp_type, mp_type, mp_type> generate(mp_type a)
  18. {
  19. mp_type tg, lg;
  20. mpfr_gamma(tg.backend().data(), a.backend().data(), GMP_RNDN);
  21. mpfr_lngamma(lg.backend().data(), a.backend().data(), GMP_RNDN);
  22. return boost::math::make_tuple(a, tg, lg);
  23. }
  24. int cpp_main(int argc, char*argv [])
  25. {
  26. parameter_info<mp_type> arg1, arg2;
  27. test_data<mp_type> data;
  28. bool cont;
  29. std::string line;
  30. if(argc < 1)
  31. return 1;
  32. do{
  33. //
  34. // User interface which prompts for
  35. // range of input parameters:
  36. //
  37. if(0 == get_user_parameter_info(arg1, "a"))
  38. return 1;
  39. arg1.type |= dummy_param;
  40. data.insert(&generate, arg1);
  41. std::cout << "Any more data [y/n]?";
  42. std::getline(std::cin, line);
  43. boost::algorithm::trim(line);
  44. cont = (line == "y");
  45. }while(cont);
  46. //
  47. // Just need to write the results to a file:
  48. //
  49. std::cout << "Enter name of test data file [default=gamma.ipp]";
  50. std::getline(std::cin, line);
  51. boost::algorithm::trim(line);
  52. if(line == "")
  53. line = "gamma.ipp";
  54. std::ofstream ofs(line.c_str());
  55. line.erase(line.find('.'));
  56. ofs << std::scientific << std::setprecision(500);
  57. write_code(ofs, data, line.c_str());
  58. return 0;
  59. }
  60. //]