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/bindings/rr.hpp>
7 #include <boost/math/tools/test_data.hpp>
8 #include <boost/test/included/test_exec_monitor.hpp>
9 #include <boost/math/special_functions/legendre.hpp>
10 #include <boost/math/special_functions/gamma.hpp>
12 #include <boost/math/tools/test_data.hpp>
13 #include <boost/tr1/random.hpp>
15 using namespace boost::math::tools;
16 using namespace boost::math;
21 boost::math::tuple<T, T, T, T> legendre_p_data(T n, T x)
24 T r1 = legendre_p(boost::math::tools::real_cast<int>(n), x);
25 T r2 = legendre_q(boost::math::tools::real_cast<int>(n), x);
26 return boost::math::make_tuple(n, x, r1, r2);
30 boost::math::tuple<T, T, T, T> assoc_legendre_p_data(T n, T x)
32 static tr1::mt19937 r;
33 int l = real_cast<int>(floor(n));
34 tr1::uniform_int<> ui((std::max)(-l, -40), (std::min)(l, 40));
36 T r1 = legendre_p(l, m, x);
37 return boost::math::make_tuple(n, m, x, r1);
40 int test_main(int argc, char*argv [])
42 using namespace boost::math::tools;
44 boost::math::ntl::RR::SetOutputPrecision(50);
45 boost::math::ntl::RR::SetPrecision(1000);
47 parameter_info<boost::math::ntl::RR> arg1, arg2;
48 test_data<boost::math::ntl::RR> data;
56 if(strcmp(argv[1], "--legendre2") == 0)
59 if(0 == get_user_parameter_info(arg1, "l"))
61 if(0 == get_user_parameter_info(arg2, "x"))
63 arg1.type |= dummy_param;
64 arg2.type |= dummy_param;
66 data.insert(&legendre_p_data<boost::math::ntl::RR>, arg1, arg2);
68 std::cout << "Any more data [y/n]?";
69 std::getline(std::cin, line);
70 boost::algorithm::trim(line);
74 else if(strcmp(argv[1], "--legendre3") == 0)
77 if(0 == get_user_parameter_info(arg1, "l"))
79 if(0 == get_user_parameter_info(arg2, "x"))
81 arg1.type |= dummy_param;
82 arg2.type |= dummy_param;
84 data.insert(&assoc_legendre_p_data<boost::math::ntl::RR>, arg1, arg2);
86 std::cout << "Any more data [y/n]?";
87 std::getline(std::cin, line);
88 boost::algorithm::trim(line);
94 std::cout << "Enter name of test data file [default=legendre_p.ipp]";
95 std::getline(std::cin, line);
96 boost::algorithm::trim(line);
98 line = "legendre_p.ipp";
99 std::ofstream ofs(line.c_str());
100 line.erase(line.find('.'));
101 write_code(ofs, data, line.c_str());