digamma_data.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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/digamma.hpp>
  6. #include <boost/test/included/prg_exec_monitor.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. float external_f;
  13. float force_truncate(const float* f)
  14. {
  15. external_f = *f;
  16. return external_f;
  17. }
  18. float truncate_to_float(mp_t r)
  19. {
  20. float f = boost::math::tools::real_cast<float>(r);
  21. return force_truncate(&f);
  22. }
  23. int cpp_main(int argc, char*argv [])
  24. {
  25. parameter_info<mp_t> arg1;
  26. test_data<mp_t> data;
  27. bool cont;
  28. std::string line;
  29. std::cout << "Welcome.\n"
  30. "This program will generate spot tests for the digamma function:\n"
  31. " digamma(z)\n\n";
  32. do{
  33. if(0 == get_user_parameter_info(arg1, "z"))
  34. return 1;
  35. data.insert(&boost::math::digamma<mp_t>, arg1);
  36. std::cout << "Any more data [y/n]?";
  37. std::getline(std::cin, line);
  38. boost::algorithm::trim(line);
  39. cont = (line == "y");
  40. }while(cont);
  41. std::cout << "Enter name of test data file [default=digamma_data.ipp]";
  42. std::getline(std::cin, line);
  43. boost::algorithm::trim(line);
  44. if(line == "")
  45. line = "digamma_data.ipp";
  46. std::ofstream ofs(line.c_str());
  47. ofs << std::scientific << std::setprecision(40);
  48. write_code(ofs, data, "digamma_data");
  49. return 0;
  50. }