]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/tools/inv_hyp_data.cpp
1 // Copyright John Maddock 2008.
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)
6 #include <boost/math/constants/constants.hpp>
8 #include <boost/math/tools/test_data.hpp>
11 using namespace boost::math::tools
;
14 struct asinh_data_generator
16 mp_t
operator()(mp_t z
)
18 std::cout
<< z
<< " ";
19 mp_t result
= log(z
+ sqrt(z
* z
+ 1));
20 std::cout
<< result
<< std::endl
;
25 struct acosh_data_generator
27 mp_t
operator()(mp_t z
)
29 std::cout
<< z
<< " ";
30 mp_t result
= log(z
+ sqrt(z
* z
- 1));
31 std::cout
<< result
<< std::endl
;
36 struct atanh_data_generator
38 mp_t
operator()(mp_t z
)
40 std::cout
<< z
<< " ";
41 mp_t result
= log((z
+ 1) / (1 - z
)) / 2;
42 std::cout
<< result
<< std::endl
;
47 int main(int argc
, char*argv
[])
49 parameter_info
<mp_t
> arg1
;
56 std::cout
<< "Welcome.\n"
57 "This program will generate spot tests for the inverse hyperbolic sin function:\n";
60 if(0 == get_user_parameter_info(arg1
, "z"))
62 data
.insert(asinh_data_generator(), arg1
);
64 std::cout
<< "Any more data [y/n]?";
65 std::getline(std::cin
, line
);
66 boost::algorithm::trim(line
);
70 std::cout
<< "Enter name of test data file [default=asinh_data.ipp]";
71 std::getline(std::cin
, line
);
72 boost::algorithm::trim(line
);
74 line
= "asinh_data.ipp";
75 ofs
.open(line
.c_str());
76 ofs
<< std::scientific
<< std::setprecision(40);
77 write_code(ofs
, data
, "asinh_data");
80 std::cout
<< "Welcome.\n"
81 "This program will generate spot tests for the inverse hyperbolic cos function:\n";
84 if(0 == get_user_parameter_info(arg1
, "z"))
86 data
.insert(acosh_data_generator(), arg1
);
88 std::cout
<< "Any more data [y/n]?";
89 std::getline(std::cin
, line
);
90 boost::algorithm::trim(line
);
94 std::cout
<< "Enter name of test data file [default=acosh_data.ipp]";
95 std::getline(std::cin
, line
);
96 boost::algorithm::trim(line
);
98 line
= "acosh_data.ipp";
100 ofs
.open(line
.c_str());
101 ofs
<< std::scientific
<< std::setprecision(40);
102 write_code(ofs
, data
, "acosh_data");
105 std::cout
<< "Welcome.\n"
106 "This program will generate spot tests for the inverse hyperbolic tan function:\n";
109 if(0 == get_user_parameter_info(arg1
, "z"))
111 data
.insert(atanh_data_generator(), arg1
);
113 std::cout
<< "Any more data [y/n]?";
114 std::getline(std::cin
, line
);
115 boost::algorithm::trim(line
);
116 cont
= (line
== "y");
119 std::cout
<< "Enter name of test data file [default=atanh_data.ipp]";
120 std::getline(std::cin
, line
);
121 boost::algorithm::trim(line
);
123 line
= "atanh_data.ipp";
125 ofs
.open(line
.c_str());
126 ofs
<< std::scientific
<< std::setprecision(40);
127 write_code(ofs
, data
, "atanh_data");