]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/math/tools/ellint_pi3_data.cpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / libs / math / tools / ellint_pi3_data.cpp
CommitLineData
7c673cae
FG
1// Copyright John Maddock 2006.
2
3// Use, modification and distribution are subject to the
4// Boost Software License, Version 1.0.
5// (See accompanying file LICENSE_1_0.txt
6// or copy at http://www.boost.org/LICENSE_1_0.txt)
7
8
20effc67 9#include "mp_t.hpp"
7c673cae
FG
10#include <boost/math/tools/test_data.hpp>
11#include <boost/test/included/prg_exec_monitor.hpp>
12#include <boost/math/special_functions/ellint_3.hpp>
13#include <fstream>
14#include <boost/math/tools/test_data.hpp>
15#include <boost/random.hpp>
7c673cae
FG
16
17float extern_val;
18// confuse the compilers optimiser, and force a truncation to float precision:
19float truncate_to_float(float const * pf)
20{
21 extern_val = *pf;
22 return *pf;
23}
24
25boost::math::tuple<mp_t, mp_t> generate_data(mp_t n, mp_t phi)
26{
27 static boost::mt19937 r;
28 boost::uniform_real<float> ui(0, 1);
29 float k = ui(r);
30 mp_t kr(truncate_to_float(&k));
31 mp_t result = boost::math::ellint_3(kr, n, phi);
32 return boost::math::make_tuple(kr, result);
33}
34
35int cpp_main(int argc, char*argv [])
36{
37 using namespace boost::math::tools;
38
39 parameter_info<mp_t> arg1, arg2;
40 test_data<mp_t> data;
41
42 bool cont;
43 std::string line;
44
45 if(argc < 1)
46 return 1;
47
48 do{
49 if(0 == get_user_parameter_info(arg1, "n"))
50 return 1;
51 if(0 == get_user_parameter_info(arg2, "phi"))
52 return 1;
53
54 data.insert(&generate_data, arg1, arg2);
55
56 std::cout << "Any more data [y/n]?";
57 std::getline(std::cin, line);
58 boost::algorithm::trim(line);
59 cont = (line == "y");
60 }while(cont);
61
62 std::cout << "Enter name of test data file [default=ellint_pi3_data.ipp]";
63 std::getline(std::cin, line);
64 boost::algorithm::trim(line);
65 if(line == "")
66 line = "ellint_pi3_data.ipp";
67 std::ofstream ofs(line.c_str());
68 line.erase(line.find('.'));
69 ofs << std::scientific << std::setprecision(40);
70 write_code(ofs, data, line.c_str());
71
72 return 0;
73}
74
75