laguerre_data.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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/laguerre.hpp>
  7. #include <boost/math/special_functions/gamma.hpp>
  8. #include <fstream>
  9. #include <boost/math/tools/test_data.hpp>
  10. #include "mp_t.hpp"
  11. using namespace boost::math::tools;
  12. using namespace boost::math;
  13. using namespace std;
  14. template<class T>
  15. boost::math::tuple<T, T, T> laguerre2_data(T n, T x)
  16. {
  17. n = floor(n);
  18. T r1 = laguerre(boost::math::tools::real_cast<unsigned>(n), x);
  19. return boost::math::make_tuple(n, x, r1);
  20. }
  21. template<class T>
  22. boost::math::tuple<T, T, T, T> laguerre3_data(T n, T m, T x)
  23. {
  24. n = floor(n);
  25. m = floor(m);
  26. T r1 = laguerre(real_cast<unsigned>(n), real_cast<unsigned>(m), x);
  27. return boost::math::make_tuple(n, m, x, r1);
  28. }
  29. int main(int argc, char*argv [])
  30. {
  31. using namespace boost::math::tools;
  32. parameter_info<mp_t> arg1, arg2, arg3;
  33. test_data<mp_t> data;
  34. bool cont;
  35. std::string line;
  36. if(argc < 2)
  37. return 1;
  38. if(strcmp(argv[1], "--laguerre2") == 0)
  39. {
  40. do{
  41. if(0 == get_user_parameter_info(arg1, "n"))
  42. return 1;
  43. if(0 == get_user_parameter_info(arg2, "x"))
  44. return 1;
  45. arg1.type |= dummy_param;
  46. arg2.type |= dummy_param;
  47. data.insert(&laguerre2_data<mp_t>, arg1, arg2);
  48. std::cout << "Any more data [y/n]?";
  49. std::getline(std::cin, line);
  50. boost::algorithm::trim(line);
  51. cont = (line == "y");
  52. }while(cont);
  53. }
  54. else if(strcmp(argv[1], "--laguerre3") == 0)
  55. {
  56. do{
  57. if(0 == get_user_parameter_info(arg1, "n"))
  58. return 1;
  59. if(0 == get_user_parameter_info(arg2, "m"))
  60. return 1;
  61. if(0 == get_user_parameter_info(arg3, "x"))
  62. return 1;
  63. arg1.type |= dummy_param;
  64. arg2.type |= dummy_param;
  65. arg3.type |= dummy_param;
  66. data.insert(&laguerre3_data<mp_t>, arg1, arg2, arg3);
  67. std::cout << "Any more data [y/n]?";
  68. std::getline(std::cin, line);
  69. boost::algorithm::trim(line);
  70. cont = (line == "y");
  71. }while(cont);
  72. }
  73. std::cout << "Enter name of test data file [default=laguerre.ipp]";
  74. std::getline(std::cin, line);
  75. boost::algorithm::trim(line);
  76. if(line == "")
  77. line = "laguerre.ipp";
  78. std::ofstream ofs(line.c_str());
  79. line.erase(line.find('.'));
  80. ofs << std::scientific << std::setprecision(40);
  81. write_code(ofs, data, line.c_str());
  82. return 0;
  83. }