• 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 
28 template <class T>
naive_sinc(T const & x)29 T naive_sinc(T const& x)
30 {
31    using std::sin;
32    return sin(x) / x;
33 }
34 
cpp_main(int argc,char * argv[])35 int cpp_main(int argc, char*argv [])
36 {
37    parameter_info<mp_t> arg1;
38    test_data<mp_t> data;
39 
40    bool cont;
41    std::string line;
42 
43    std::cout << "Welcome.\n"
44       "This program will generate spot tests for the sinc function:\n"
45       "  sinc_pi(z)\n\n";
46 
47    do{
48       if(0 == get_user_parameter_info(arg1, "z"))
49          return 1;
50       data.insert(&::naive_sinc<mp_t>, arg1);
51 
52       std::cout << "Any more data [y/n]?";
53       std::getline(std::cin, line);
54       boost::algorithm::trim(line);
55       cont = (line == "y");
56    }while(cont);
57 
58    std::cout << "Enter name of test data file [default=sinc_data.ipp]";
59    std::getline(std::cin, line);
60    boost::algorithm::trim(line);
61    if(line == "")
62       line = "sinc_data.ipp";
63    std::ofstream ofs(line.c_str());
64    ofs << std::scientific << std::setprecision(40);
65    write_code(ofs, data, "sinc_data");
66 
67    return 0;
68 }
69 
70 
71 
72