• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //  (C) Copyright John Maddock 2007.
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/tools/test_data.hpp>
7 #include <boost/math/special_functions/laguerre.hpp>
8 #include <boost/math/special_functions/gamma.hpp>
9 #include <fstream>
10 #include <boost/math/tools/test_data.hpp>
11 #include "mp_t.hpp"
12 
13 using namespace boost::math::tools;
14 using namespace boost::math;
15 using namespace std;
16 
17 
18 template<class T>
laguerre2_data(T n,T x)19 boost::math::tuple<T, T, T> laguerre2_data(T n, T x)
20 {
21    n = floor(n);
22    T r1 = laguerre(boost::math::tools::real_cast<unsigned>(n), x);
23    return boost::math::make_tuple(n, x, r1);
24 }
25 
26 template<class T>
laguerre3_data(T n,T m,T x)27 boost::math::tuple<T, T, T, T> laguerre3_data(T n, T m, T x)
28 {
29    n = floor(n);
30    m = floor(m);
31    T r1 = laguerre(real_cast<unsigned>(n), real_cast<unsigned>(m), x);
32    return boost::math::make_tuple(n, m, x, r1);
33 }
34 
main(int argc,char * argv[])35 int main(int argc, char*argv [])
36 {
37    using namespace boost::math::tools;
38 
39    parameter_info<mp_t> arg1, arg2, arg3;
40    test_data<mp_t> data;
41 
42    bool cont;
43    std::string line;
44 
45    if(argc < 2)
46       return 1;
47 
48    if(strcmp(argv[1], "--laguerre2") == 0)
49    {
50       do{
51          if(0 == get_user_parameter_info(arg1, "n"))
52             return 1;
53          if(0 == get_user_parameter_info(arg2, "x"))
54             return 1;
55          arg1.type |= dummy_param;
56          arg2.type |= dummy_param;
57 
58          data.insert(&laguerre2_data<mp_t>, arg1, arg2);
59 
60          std::cout << "Any more data [y/n]?";
61          std::getline(std::cin, line);
62          boost::algorithm::trim(line);
63          cont = (line == "y");
64       }while(cont);
65    }
66    else if(strcmp(argv[1], "--laguerre3") == 0)
67    {
68       do{
69          if(0 == get_user_parameter_info(arg1, "n"))
70             return 1;
71          if(0 == get_user_parameter_info(arg2, "m"))
72             return 1;
73          if(0 == get_user_parameter_info(arg3, "x"))
74             return 1;
75          arg1.type |= dummy_param;
76          arg2.type |= dummy_param;
77          arg3.type |= dummy_param;
78 
79          data.insert(&laguerre3_data<mp_t>, arg1, arg2, arg3);
80 
81          std::cout << "Any more data [y/n]?";
82          std::getline(std::cin, line);
83          boost::algorithm::trim(line);
84          cont = (line == "y");
85       }while(cont);
86    }
87 
88 
89    std::cout << "Enter name of test data file [default=laguerre.ipp]";
90    std::getline(std::cin, line);
91    boost::algorithm::trim(line);
92    if(line == "")
93       line = "laguerre.ipp";
94    std::ofstream ofs(line.c_str());
95    line.erase(line.find('.'));
96    ofs << std::scientific << std::setprecision(40);
97    write_code(ofs, data, line.c_str());
98 
99    return 0;
100 }
101 
102