• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <boost/math/special_functions/digamma.hpp>
7 #include <boost/test/included/prg_exec_monitor.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 float external_f;
force_truncate(const float * f)16 float force_truncate(const float* f)
17 {
18    external_f = *f;
19    return external_f;
20 }
21 
truncate_to_float(mp_t r)22 float truncate_to_float(mp_t r)
23 {
24    float f = boost::math::tools::real_cast<float>(r);
25    return force_truncate(&f);
26 }
27 
cpp_main(int argc,char * argv[])28 int cpp_main(int argc, char*argv [])
29 {
30    parameter_info<mp_t> arg1;
31    test_data<mp_t> data;
32 
33    bool cont;
34    std::string line;
35 
36    std::cout << "Welcome.\n"
37       "This program will generate spot tests for the digamma function:\n"
38       "  digamma(z)\n\n";
39 
40    do{
41       if(0 == get_user_parameter_info(arg1, "z"))
42          return 1;
43       data.insert(&boost::math::digamma<mp_t>, arg1);
44 
45       std::cout << "Any more data [y/n]?";
46       std::getline(std::cin, line);
47       boost::algorithm::trim(line);
48       cont = (line == "y");
49    }while(cont);
50 
51    std::cout << "Enter name of test data file [default=digamma_data.ipp]";
52    std::getline(std::cin, line);
53    boost::algorithm::trim(line);
54    if(line == "")
55       line = "digamma_data.ipp";
56    std::ofstream ofs(line.c_str());
57    ofs << std::scientific << std::setprecision(40);
58    write_code(ofs, data, "digamma_data");
59 
60    return 0;
61 }
62 
63 
64 
65