hermite_data.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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/tools/test_data.hpp>
  6. #include <boost/math/special_functions/hermite.hpp>
  7. #include <fstream>
  8. #include "mp_t.hpp"
  9. using namespace boost::math::tools;
  10. using namespace boost::math;
  11. using namespace std;
  12. template<class T>
  13. boost::math::tuple<T, T, T> hermite_data(T n, T x)
  14. {
  15. n = floor(n);
  16. T r1 = hermite(boost::math::tools::real_cast<unsigned>(n), x);
  17. return boost::math::make_tuple(n, x, r1);
  18. }
  19. int main(int argc, char*argv [])
  20. {
  21. using namespace boost::math::tools;
  22. parameter_info<mp_t> arg1, arg2, arg3;
  23. test_data<mp_t> data;
  24. std::cout << boost::math::hermite(10, static_cast<mp_t>(1e300)) << std::endl;
  25. bool cont;
  26. std::string line;
  27. if(argc < 1)
  28. return 1;
  29. do{
  30. if(0 == get_user_parameter_info(arg1, "n"))
  31. return 1;
  32. if(0 == get_user_parameter_info(arg2, "x"))
  33. return 1;
  34. arg1.type |= dummy_param;
  35. arg2.type |= dummy_param;
  36. data.insert(&hermite_data<mp_t>, 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=hermite.ipp]";
  43. std::getline(std::cin, line);
  44. boost::algorithm::trim(line);
  45. if(line == "")
  46. line = "hermite.ipp";
  47. std::ofstream ofs(line.c_str());
  48. line.erase(line.find('.'));
  49. ofs << std::scientific << std::setprecision(40);
  50. write_code(ofs, data, line.c_str());
  51. return 0;
  52. }