ellint_f_data.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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/test/included/prg_exec_monitor.hpp>
  7. #include <boost/math/special_functions/ellint_1.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. float extern_val;
  15. // confuse the compilers optimiser, and force a truncation to float precision:
  16. float truncate_to_float(float const * pf)
  17. {
  18. extern_val = *pf;
  19. return *pf;
  20. }
  21. template<class T>
  22. T ellint_f_data(T phi, T k)
  23. {
  24. return ellint_1(k, phi);
  25. }
  26. int cpp_main(int argc, char*argv [])
  27. {
  28. using namespace boost::math::tools;
  29. parameter_info<mp_t> arg1, arg2;
  30. test_data<mp_t> data;
  31. bool cont;
  32. std::string line;
  33. if(argc < 1)
  34. return 1;
  35. do{
  36. if(0 == get_user_parameter_info(arg1, "phi"))
  37. return 1;
  38. if(0 == get_user_parameter_info(arg2, "k"))
  39. return 1;
  40. data.insert(&ellint_f_data<mp_t>, arg1, arg2);
  41. std::cout << "Any more data [y/n]?";
  42. std::getline(std::cin, line);
  43. boost::algorithm::trim(line);
  44. cont = (line == "y");
  45. }while(cont);
  46. std::cout << "Enter name of test data file [default=ellint_f.ipp]";
  47. std::getline(std::cin, line);
  48. boost::algorithm::trim(line);
  49. if(line == "")
  50. line = "ellint_f.ipp";
  51. std::ofstream ofs(line.c_str());
  52. line.erase(line.find('.'));
  53. ofs << std::scientific << std::setprecision(40);
  54. write_code(ofs, data, line.c_str());
  55. return 0;
  56. }