hyp_2f0_data.cpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. #include <boost/math/special_functions/hypergeometric_2f0.hpp>
  6. #include <boost/math/constants/constants.hpp>
  7. #include <boost/lexical_cast.hpp>
  8. #include <fstream>
  9. #include <map>
  10. #include <boost/math/tools/test_data.hpp>
  11. #include <boost/random.hpp>
  12. #include "mp_t.hpp"
  13. using namespace boost::math::tools;
  14. using namespace boost::math;
  15. using namespace std;
  16. struct hypergeometric_2f0_gen
  17. {
  18. mp_t operator()(mp_t a1, mp_t a2, mp_t z)
  19. {
  20. std::cout << a1 << " " << a2 << " " << z << std::endl;
  21. mp_t result = boost::math::detail::hypergeometric_2f0_generic_series(a1, a2, z, boost::math::policies::policy<>());
  22. std::cout << a1 << " " << a2 << " " << z << " " << result << std::endl;
  23. return result;
  24. }
  25. };
  26. struct hypergeometric_2f0_gen_spec1
  27. {
  28. boost::math::tuple<mp_t, mp_t, mp_t, mp_t> operator()(mp_t a1, mp_t z)
  29. {
  30. mp_t result = boost::math::detail::hypergeometric_2f0_generic_series(a1, a1 + 0.5, z, boost::math::policies::policy<>());
  31. std::cout << a1 << " " << a1 + 0.5 << " " << z << " " << result << std::endl;
  32. return boost::math::make_tuple(a1, a1 + 0.5, z, result);
  33. }
  34. };
  35. int main(int, char* [])
  36. {
  37. parameter_info<mp_t> arg1, arg2, arg3;
  38. test_data<mp_t> data;
  39. std::cout << "Welcome.\n"
  40. "This program will generate spot tests for 2F0:\n";
  41. std::string line;
  42. bool cont;
  43. #if 1
  44. arg1 = make_periodic_param(mp_t(-20), mp_t(-1), 19);
  45. arg2 = make_random_param(mp_t(-5), mp_t(5), 8);
  46. arg1.type |= dummy_param;
  47. arg2.type |= dummy_param;
  48. data.insert(hypergeometric_2f0_gen_spec1(), arg1, arg2);
  49. #else
  50. do {
  51. get_user_parameter_info(arg1, "a1");
  52. get_user_parameter_info(arg2, "a2");
  53. get_user_parameter_info(arg3, "z");
  54. data.insert(hypergeometric_2f0_gen(), arg1, arg2, arg3);
  55. std::cout << "Any more data [y/n]?";
  56. std::getline(std::cin, line);
  57. boost::algorithm::trim(line);
  58. cont = (line == "y");
  59. } while (cont);
  60. #endif
  61. std::cout << "Enter name of test data file [default=hypergeometric_2f0.ipp]";
  62. std::getline(std::cin, line);
  63. boost::algorithm::trim(line);
  64. if(line == "")
  65. line = "hypergeometric_2f0.ipp";
  66. std::ofstream ofs(line.c_str());
  67. ofs << std::scientific << std::setprecision(40);
  68. write_code(ofs, data, line.c_str());
  69. return 0;
  70. }