expint_data.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // (C) 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/expint.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. struct expint_data_generator
  12. {
  13. mp_t operator()(mp_t a, mp_t b)
  14. {
  15. unsigned n = boost::math::tools::real_cast<unsigned>(a);
  16. std::cout << n << " " << b << " ";
  17. mp_t result = boost::math::expint(n, b);
  18. std::cout << result << std::endl;
  19. return result;
  20. }
  21. };
  22. int main()
  23. {
  24. boost::math::expint(1, 0.06227754056453704833984375);
  25. std::cout << boost::math::expint(1, mp_t(0.5)) << std::endl;
  26. parameter_info<mp_t> arg1, arg2;
  27. test_data<mp_t> data;
  28. std::cout << "Welcome.\n"
  29. "This program will generate spot tests for the expint function:\n"
  30. " expint(a, b)\n\n";
  31. bool cont;
  32. std::string line;
  33. do{
  34. get_user_parameter_info(arg1, "a");
  35. get_user_parameter_info(arg2, "b");
  36. data.insert(expint_data_generator(), arg1, arg2);
  37. std::cout << "Any more data [y/n]?";
  38. std::getline(std::cin, line);
  39. boost::algorithm::trim(line);
  40. cont = (line == "y");
  41. }while(cont);
  42. std::cout << "Enter name of test data file [default=expint_data.ipp]";
  43. std::getline(std::cin, line);
  44. boost::algorithm::trim(line);
  45. if(line == "")
  46. line = "expint_data.ipp";
  47. std::ofstream ofs(line.c_str());
  48. ofs << std::scientific << std::setprecision(40);
  49. write_code(ofs, data, "expint_data");
  50. return 0;
  51. }