]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/tools/zeta_data.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / math / tools / zeta_data.cpp
1 // 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/special_functions/zeta.hpp>
7 #include <boost/math/constants/constants.hpp>
8 #include <fstream>
9 #include <boost/math/tools/test_data.hpp>
10 #include "mp_t.hpp"
11
12 using namespace boost::math::tools;
13 using namespace std;
14
15 struct zeta_data_generator
16 {
17 mp_t operator()(mp_t z)
18 {
19 std::cout << z << " ";
20 mp_t result = boost::math::zeta(z);
21 std::cout << result << std::endl;
22 return result;
23 }
24 };
25
26 struct zeta_data_generator2
27 {
28 boost::math::tuple<mp_t, mp_t> operator()(mp_t z)
29 {
30 std::cout << -z << " ";
31 mp_t result = boost::math::zeta(-z);
32 std::cout << result << std::endl;
33 return boost::math::make_tuple(-z, result);
34 }
35 };
36
37
38 int main(int argc, char*argv [])
39 {
40 parameter_info<mp_t> arg1;
41 test_data<mp_t> data;
42
43 bool cont;
44 std::string line;
45
46 std::cout << "Welcome.\n"
47 "This program will generate spot tests for the zeta function:\n";
48
49 do{
50 if(0 == get_user_parameter_info(arg1, "z"))
51 return 1;
52 arg1.type |= dummy_param;
53 data.insert(zeta_data_generator2(), arg1);
54
55 std::cout << "Any more data [y/n]?";
56 std::getline(std::cin, line);
57 boost::algorithm::trim(line);
58 cont = (line == "y");
59 }while(cont);
60
61 std::cout << "Enter name of test data file [default=zeta_data.ipp]";
62 std::getline(std::cin, line);
63 boost::algorithm::trim(line);
64 if(line == "")
65 line = "zeta_data.ipp";
66 std::ofstream ofs(line.c_str());
67 ofs << std::scientific << std::setprecision(40);
68 write_code(ofs, data, "zeta_data");
69
70 return 0;
71 }
72