• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
14 using namespace boost::math::tools;
15 using namespace boost::math;
16 using namespace std;
17 
heuman_lambda(mp_t phi,mp_t k)18 mp_t heuman_lambda(mp_t phi, mp_t k)
19 {
20    mp_t kp = sqrt(1 - k *k);
21    if((k * k < tools::epsilon<float>()) && (fabs(phi) >= constants::half_pi<mp_t>()))
22       throw std::domain_error("");
23    return ellint_1(kp, phi) / ellint_1(kp) + ellint_1(k) * jacobi_zeta(kp, phi) / constants::half_pi<mp_t>();
24 }
25 
cpp_main(int argc,char * argv[])26 int cpp_main(int argc, char*argv [])
27 {
28    using namespace boost::math::tools;
29 
30    parameter_info<mp_t> arg1, arg2;
31    test_data<mp_t> data;
32 
33    bool cont;
34    std::string line;
35 
36    if(argc < 1)
37       return 1;
38 
39    do{
40       if(0 == get_user_parameter_info(arg1, "phi"))
41          return 1;
42       if(0 == get_user_parameter_info(arg2, "k"))
43          return 1;
44 
45       mp_t(*fp)(mp_t, mp_t) = &heuman_lambda;
46       data.insert(fp, arg1, arg2);
47 
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    std::cout << "Enter name of test data file [default=heuman_lambda_data.ipp]";
55    std::getline(std::cin, line);
56    boost::algorithm::trim(line);
57    if(line == "")
58       line = "heuman_lambda_data.ipp";
59    std::ofstream ofs(line.c_str());
60    line.erase(line.find('.'));
61    ofs << std::scientific << std::setprecision(40);
62    write_code(ofs, data, line.c_str());
63 
64    return 0;
65 }
66 
67 
68