zeta_data.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // Copyright John Maddock 2007.
  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/zeta.hpp>
  6. #include <boost/math/constants/constants.hpp>
  7. #include <fstream>
  8. #include <boost/math/tools/test_data.hpp>
  9. #include "mp_t.hpp"
  10. using namespace boost::math::tools;
  11. using namespace std;
  12. struct zeta_data_generator
  13. {
  14. mp_t operator()(mp_t z)
  15. {
  16. std::cout << z << " ";
  17. mp_t result = boost::math::zeta(z);
  18. std::cout << result << std::endl;
  19. return result;
  20. }
  21. };
  22. struct zeta_data_generator2
  23. {
  24. boost::math::tuple<mp_t, mp_t> operator()(mp_t z)
  25. {
  26. std::cout << -z << " ";
  27. mp_t result = boost::math::zeta(-z);
  28. std::cout << result << std::endl;
  29. return boost::math::make_tuple(-z, result);
  30. }
  31. };
  32. int main(int argc, char*argv [])
  33. {
  34. parameter_info<mp_t> arg1;
  35. test_data<mp_t> data;
  36. bool cont;
  37. std::string line;
  38. std::cout << "Welcome.\n"
  39. "This program will generate spot tests for the zeta function:\n";
  40. do{
  41. if(0 == get_user_parameter_info(arg1, "z"))
  42. return 1;
  43. arg1.type |= dummy_param;
  44. data.insert(zeta_data_generator2(), arg1);
  45. std::cout << "Any more data [y/n]?";
  46. std::getline(std::cin, line);
  47. boost::algorithm::trim(line);
  48. cont = (line == "y");
  49. }while(cont);
  50. std::cout << "Enter name of test data file [default=zeta_data.ipp]";
  51. std::getline(std::cin, line);
  52. boost::algorithm::trim(line);
  53. if(line == "")
  54. line = "zeta_data.ipp";
  55. std::ofstream ofs(line.c_str());
  56. ofs << std::scientific << std::setprecision(40);
  57. write_code(ofs, data, "zeta_data");
  58. return 0;
  59. }