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)
6 #include <boost/math/special_functions/legendre.hpp>
7 #include <boost/math/special_functions/gamma.hpp>
9 #include <boost/math/tools/test_data.hpp>
10 #include <boost/random.hpp>
13 using namespace boost::math::tools;
14 using namespace boost::math;
19 boost::math::tuple<T, T, T, T> legendre_p_data(T n, T x)
22 T r1 = legendre_p(boost::math::tools::real_cast<int>(n), x);
23 T r2 = legendre_q(boost::math::tools::real_cast<int>(n), x);
24 return boost::math::make_tuple(n, x, r1, r2);
28 boost::math::tuple<T, T, T, T> assoc_legendre_p_data(T n, T x)
30 static boost::mt19937 r;
31 int l = real_cast<int>(floor(n));
32 boost::uniform_int<> ui((std::max)(-l, -40), (std::min)(l, 40));
34 T r1 = legendre_p(l, m, x);
35 return boost::math::make_tuple(n, m, x, r1);
38 int main(int argc, char*argv [])
40 using namespace boost::math::tools;
42 parameter_info<mp_t> arg1, arg2;
51 if(strcmp(argv[1], "--legendre2") == 0)
54 if(0 == get_user_parameter_info(arg1, "l"))
56 if(0 == get_user_parameter_info(arg2, "x"))
58 arg1.type |= dummy_param;
59 arg2.type |= dummy_param;
61 data.insert(&legendre_p_data<mp_t>, arg1, arg2);
63 std::cout << "Any more data [y/n]?";
64 std::getline(std::cin, line);
65 boost::algorithm::trim(line);
69 else if(strcmp(argv[1], "--legendre3") == 0)
72 if(0 == get_user_parameter_info(arg1, "l"))
74 if(0 == get_user_parameter_info(arg2, "x"))
76 arg1.type |= dummy_param;
77 arg2.type |= dummy_param;
79 data.insert(&assoc_legendre_p_data<mp_t>, arg1, arg2);
81 std::cout << "Any more data [y/n]?";
82 std::getline(std::cin, line);
83 boost::algorithm::trim(line);
89 std::cout << "Enter name of test data file [default=legendre_p.ipp]";
90 std::getline(std::cin, line);
91 boost::algorithm::trim(line);
93 line = "legendre_p.ipp";
94 std::ofstream ofs(line.c_str());
95 ofs << std::scientific << std::setprecision(40);
96 line.erase(line.find('.'));
97 write_code(ofs, data, line.c_str());