]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Copyright John Maddock 2013. |
2 | // Use, modification and distribution are subject to the | |
3 | // Boost Software License, Version 1.0. | |
4 | // (See accompanying file LICENSE_1_0.txt | |
5 | // or copy at http://www.boost.org/LICENSE_1_0.txt) | |
6 | ||
7 | //[special_data_example | |
8 | ||
9 | #include <boost/multiprecision/mpfr.hpp> | |
10 | #include <boost/math/tools/test_data.hpp> | |
11 | #include <boost/test/included/prg_exec_monitor.hpp> | |
12 | #include <boost/math/tools/tuple.hpp> | |
13 | #include <fstream> | |
14 | ||
15 | using namespace boost::math::tools; | |
16 | using namespace boost::math; | |
17 | using namespace std; | |
18 | using namespace boost::multiprecision; | |
19 | ||
20 | typedef number<mpfr_float_backend<1000> > mp_type; | |
21 | ||
22 | ||
23 | boost::math::tuple<mp_type, mp_type, mp_type> generate(mp_type a) | |
24 | { | |
25 | mp_type tg, lg; | |
26 | mpfr_gamma(tg.backend().data(), a.backend().data(), GMP_RNDN); | |
27 | mpfr_lngamma(lg.backend().data(), a.backend().data(), GMP_RNDN); | |
28 | return boost::math::make_tuple(a, tg, lg); | |
29 | } | |
30 | ||
31 | int cpp_main(int argc, char*argv []) | |
32 | { | |
33 | parameter_info<mp_type> arg1, arg2; | |
34 | test_data<mp_type> data; | |
35 | ||
36 | bool cont; | |
37 | std::string line; | |
38 | ||
39 | if(argc < 1) | |
40 | return 1; | |
41 | ||
42 | do{ | |
43 | // | |
44 | // User interface which prompts for | |
45 | // range of input parameters: | |
46 | // | |
47 | if(0 == get_user_parameter_info(arg1, "a")) | |
48 | return 1; | |
49 | arg1.type |= dummy_param; | |
50 | ||
20effc67 TL |
51 | typedef boost::math::tuple<mp_type, mp_type, mp_type>(*proc_type)(mp_type); |
52 | ||
53 | proc_type p = &generate; | |
54 | ||
55 | data.insert(p, arg1); | |
7c673cae FG |
56 | |
57 | std::cout << "Any more data [y/n]?"; | |
58 | std::getline(std::cin, line); | |
59 | boost::algorithm::trim(line); | |
60 | cont = (line == "y"); | |
61 | }while(cont); | |
62 | // | |
63 | // Just need to write the results to a file: | |
64 | // | |
65 | std::cout << "Enter name of test data file [default=gamma.ipp]"; | |
66 | std::getline(std::cin, line); | |
67 | boost::algorithm::trim(line); | |
68 | if(line == "") | |
69 | line = "gamma.ipp"; | |
70 | std::ofstream ofs(line.c_str()); | |
71 | line.erase(line.find('.')); | |
72 | ofs << std::scientific << std::setprecision(500); | |
73 | write_code(ofs, data, line.c_str()); | |
74 | ||
75 | return 0; | |
76 | } | |
77 | ||
78 | //] | |
79 |