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