Imported Upstream version 1.49.0
[platform/upstream/boost.git] / libs / math / tools / ellint_k_data.cpp
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
6 #include <boost/math/bindings/rr.hpp>
7 #include <boost/math/tools/test_data.hpp>
8 #include <boost/test/included/test_exec_monitor.hpp>
9 #include <boost/math/special_functions/ellint_1.hpp>
10 #include <fstream>
11 #include <boost/math/tools/test_data.hpp>
12 #include <boost/tr1/random.hpp>
13
14 using namespace boost::math::tools;
15 using namespace boost::math;
16 using namespace std;
17
18 template<class T>
19 T ellint_k_data(T k)
20 {
21    return ellint_1(k);
22 }
23
24 int test_main(int argc, char*argv [])
25 {
26    using namespace boost::math::tools;
27
28    boost::math::ntl::RR::SetOutputPrecision(50);
29    boost::math::ntl::RR::SetPrecision(1000);
30
31    parameter_info<boost::math::ntl::RR> arg1;
32    test_data<boost::math::ntl::RR> data;
33
34    bool cont;
35    std::string line;
36
37    if(argc < 1)
38       return 1;
39
40    do{
41       if(0 == get_user_parameter_info(arg1, "phi"))
42          return 1;
43
44       data.insert(&ellint_k_data<boost::math::ntl::RR>, arg1);
45
46       std::cout << "Any more data [y/n]?";
47       std::getline(std::cin, line);
48       boost::algorithm::trim(line);
49       cont = (line == "y");
50    }while(cont);
51
52    std::cout << "Enter name of test data file [default=ellint_k_data.ipp]";
53    std::getline(std::cin, line);
54    boost::algorithm::trim(line);
55    if(line == "")
56       line = "ellint_k_data.ipp";
57    std::ofstream ofs(line.c_str());
58    line.erase(line.find('.'));
59    ofs << std::scientific;
60    write_code(ofs, data, line.c_str());
61
62    return 0;
63 }
64