1 // (C) Copyright John Maddock 2006.
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 <fstream>
7 #include <boost/math/tools/test_data.hpp>
8 #include <boost/math/special_functions/log1p.hpp>
9 #include <boost/math/special_functions/expm1.hpp>
10 #include "mp_t.hpp"
11
12 using namespace boost::math::tools;
13 using namespace std;
14
15 struct data_generator
16 {
operator ()data_generator17 boost::math::tuple<mp_t, mp_t> operator()(mp_t z)
18 {
19 return boost::math::make_tuple(boost::math::log1p(z), boost::math::expm1(z));
20 }
21 };
22
main(int argc,char * argv[])23 int main(int argc, char* argv[])
24 {
25 parameter_info<mp_t> arg1;
26 test_data<mp_t> data;
27
28 std::cout << "Welcome.\n"
29 "This program will generate spot tests for the log1p and expm1 functions:\n\n";
30
31 bool cont;
32 std::string line;
33
34 do{
35 if(0 == get_user_parameter_info(arg1, "z"))
36 return 1;
37 data.insert(data_generator(), arg1);
38
39 std::cout << "Any more data [y/n]?";
40 std::getline(std::cin, line);
41 boost::algorithm::trim(line);
42 cont = (line == "y");
43 }while(cont);
44
45 std::cout << "Enter name of test data file [default=log1p_expm1_data.ipp]";
46 std::getline(std::cin, line);
47 boost::algorithm::trim(line);
48 if(line == "")
49 line = "log1p_expm1_data.ipp";
50 std::ofstream ofs(line.c_str());
51 ofs << std::scientific << std::setprecision(40);
52 write_code(ofs, data, "log1p_expm1_data");
53
54 return 0;
55 }
56
57
58
59
60