heuman_lambda_data.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // Copyright John Maddock 2006.
  2. // Use, modification and distribution are subject to the
  3. // Boost Software License, Version 1.0.
  4. // (See accompanying file LICENSE_1_0.txt
  5. // or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. #include <boost/math/tools/test_data.hpp>
  7. #include <boost/test/included/prg_exec_monitor.hpp>
  8. #include <boost/math/special_functions/ellint_1.hpp>
  9. #include <boost/math/special_functions/jacobi_zeta.hpp>
  10. #include <fstream>
  11. #include <boost/math/tools/test_data.hpp>
  12. #include "mp_t.hpp"
  13. using namespace boost::math::tools;
  14. using namespace boost::math;
  15. using namespace std;
  16. mp_t heuman_lambda(mp_t phi, mp_t k)
  17. {
  18. mp_t kp = sqrt(1 - k *k);
  19. if((k * k < tools::epsilon<float>()) && (fabs(phi) >= constants::half_pi<mp_t>()))
  20. throw std::domain_error("");
  21. return ellint_1(kp, phi) / ellint_1(kp) + ellint_1(k) * jacobi_zeta(kp, phi) / constants::half_pi<mp_t>();
  22. }
  23. int cpp_main(int argc, char*argv [])
  24. {
  25. using namespace boost::math::tools;
  26. parameter_info<mp_t> arg1, arg2;
  27. test_data<mp_t> data;
  28. bool cont;
  29. std::string line;
  30. if(argc < 1)
  31. return 1;
  32. do{
  33. if(0 == get_user_parameter_info(arg1, "phi"))
  34. return 1;
  35. if(0 == get_user_parameter_info(arg2, "k"))
  36. return 1;
  37. mp_t(*fp)(mp_t, mp_t) = &heuman_lambda;
  38. data.insert(fp, arg1, arg2);
  39. std::cout << "Any more data [y/n]?";
  40. std::getline(std::cin, line);
  41. boost::algorithm::trim(line);
  42. cont = (line == "y");
  43. }while(cont);
  44. std::cout << "Enter name of test data file [default=heuman_lambda_data.ipp]";
  45. std::getline(std::cin, line);
  46. boost::algorithm::trim(line);
  47. if(line == "")
  48. line = "heuman_lambda_data.ipp";
  49. std::ofstream ofs(line.c_str());
  50. line.erase(line.find('.'));
  51. ofs << std::scientific << std::setprecision(40);
  52. write_code(ofs, data, line.c_str());
  53. return 0;
  54. }