summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/math/tools/gauss_kronrod_constants.cpp
blob: 73fee4c139f3b1333f9863b3d02aee6c04ddfd92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
//  Copyright (c) 2017 John Maddock
//  Use, modification and distribution are subject to the
//  Boost Software License, Version 1.0. (See accompanying file
//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#include <boost/math/quadrature/gauss_kronrod.hpp>
#include <boost/multiprecision/cpp_bin_float.hpp>

template <class T>
void print_gauss_constants(const char* suffix, int prec, int tag)
{
   auto ab = T::abscissa();
   auto w = T::weights();
   std::cout << std::setprecision(prec) << std::scientific;
   std::size_t order = (ab[0] == 0) ? (ab.size() * 2) - 1 : ab.size() * 2;
   std::cout <<
      "template <class T>\n"
      "class gauss_detail<T, " << order << ", " << tag << ">\n"
      "   {\n"
      "   public:\n"
      "      static " << (prec > 40 ? " " : "constexpr ") << "std::array<T, " << ab.size() << "> const & abscissa()\n"
      "      {\n"
      "         static " << (prec > 40 ? " " : "constexpr ") << "std::array<T, " << ab.size() << "> data = {\n";
   for (unsigned i = 0; i < ab.size(); ++i)
      std::cout << "            " << (prec > 40 ? "BOOST_MATH_HUGE_CONSTANT(T, 0, " : "") << ab[i] << (prec > 40 ? ")" : suffix) << ",\n";
   std::cout <<
      "};\n"
      "         return data;\n"
      "      }\n"
      "      static " << (prec > 40 ? " " : "constexpr ") << "std::array<T, " << w.size() << "> const & weights()\n"
      "      {\n"
      "         static " << (prec > 40 ? " " : "constexpr ") << "std::array<T, " << w.size() << "> data = {\n";
   for (unsigned i = 0; i < w.size(); ++i)
      std::cout << "            " << (prec > 40 ? "BOOST_MATH_HUGE_CONSTANT(T, 0, " : "") << w[i] << (prec > 40 ? ")" : suffix) << ",\n";

   std::cout << "         };\n"
      "         return data;\n"
      "      }\n"
      "   };\n\n";
}

template <class T>
void print_gauss_kronrod_constants(const char* suffix, int prec, int tag)
{
   auto ab = T::abscissa();
   auto w = T::weights();
   std::cout << std::setprecision(prec) << std::scientific;
   std::size_t order = (ab.size() * 2) - 1;
   std::cout <<
      "   template <class T>\n"
      "   class gauss_kronrod_detail<T, " << order << ", " << tag << ">\n"
      "   {\n"
      "   public:\n"
      "      static " << (prec > 40 ? " " : "constexpr ") << "std::array<T, " << ab.size() << "> const & abscissa()\n"
      "      {\n"
      "         static " << (prec > 40 ? " " : "constexpr ") << "std::array<T, " << ab.size() << "> data = {\n";

   for (unsigned i = 0; i < ab.size(); ++i)
      std::cout << "            " << (prec > 40 ? "BOOST_MATH_HUGE_CONSTANT(T, 0, " : "") << ab[i] << (prec > 40 ? ")" : suffix) << ",\n";

   std::cout << "         };\n"
      "         return data;\n"
      "      }\n"
      "      static " << (prec > 40 ? " " : "constexpr ") << "std::array<T, " << w.size() << "> const & weights()\n"
      "      {\n"
      "         static " << (prec > 40 ? " " : "constexpr ") << "std::array<T, " << w.size() << "> data = {\n";

   for (unsigned i = 0; i < w.size(); ++i)
      std::cout << "            " << (prec > 40 ? "BOOST_MATH_HUGE_CONSTANT(T, 0, " : "") << w[i] << (prec > 40 ? ")" : suffix) << ",\n";

   std::cout << "         };\n"
      "         return data;\n"
      "      }\n"
      "   };\n\n";
}



int main()
{
   typedef boost::multiprecision::number<boost::multiprecision::cpp_bin_float<250> > mp_type;

   print_gauss_constants<boost::math::quadrature::gauss<mp_type, 7> >("f", 9, 0);
   print_gauss_constants<boost::math::quadrature::gauss<mp_type, 7> >("", 17, 1);
   print_gauss_constants<boost::math::quadrature::gauss<mp_type, 7> >("L", 35, 2);
   print_gauss_constants<boost::math::quadrature::gauss<mp_type, 7> >("Q", 35, 3);
   print_gauss_constants<boost::math::quadrature::gauss<mp_type, 7> >("", 115, 4);

   print_gauss_constants<boost::math::quadrature::gauss<mp_type, 10> >("f", 9, 0);
   print_gauss_constants<boost::math::quadrature::gauss<mp_type, 10> >("", 17, 1);
   print_gauss_constants<boost::math::quadrature::gauss<mp_type, 10> >("L", 35, 2);
   print_gauss_constants<boost::math::quadrature::gauss<mp_type, 10> >("Q", 35, 3);
   print_gauss_constants<boost::math::quadrature::gauss<mp_type, 10> >("", 115, 4);

   print_gauss_constants<boost::math::quadrature::gauss<mp_type, 15> >("f", 9, 0);
   print_gauss_constants<boost::math::quadrature::gauss<mp_type, 15> >("", 17, 1);
   print_gauss_constants<boost::math::quadrature::gauss<mp_type, 15> >("L", 35, 2);
   print_gauss_constants<boost::math::quadrature::gauss<mp_type, 15> >("Q", 35, 3);
   print_gauss_constants<boost::math::quadrature::gauss<mp_type, 15> >("", 115, 4);

   print_gauss_constants<boost::math::quadrature::gauss<mp_type, 20> >("f", 9, 0);
   print_gauss_constants<boost::math::quadrature::gauss<mp_type, 20> >("", 17, 1);
   print_gauss_constants<boost::math::quadrature::gauss<mp_type, 20> >("L", 35, 2);
   print_gauss_constants<boost::math::quadrature::gauss<mp_type, 20> >("Q", 35, 3);
   print_gauss_constants<boost::math::quadrature::gauss<mp_type, 20> >("", 115, 4);

   print_gauss_constants<boost::math::quadrature::gauss<mp_type, 25> >("f", 9, 0);
   print_gauss_constants<boost::math::quadrature::gauss<mp_type, 25> >("", 17, 1);
   print_gauss_constants<boost::math::quadrature::gauss<mp_type, 25> >("L", 35, 2);
   print_gauss_constants<boost::math::quadrature::gauss<mp_type, 25> >("Q", 35, 3);
   print_gauss_constants<boost::math::quadrature::gauss<mp_type, 25> >("", 115, 4);

   print_gauss_constants<boost::math::quadrature::gauss<mp_type, 30> >("f", 9, 0);
   print_gauss_constants<boost::math::quadrature::gauss<mp_type, 30> >("", 17, 1);
   print_gauss_constants<boost::math::quadrature::gauss<mp_type, 30> >("L", 35, 2);
   print_gauss_constants<boost::math::quadrature::gauss<mp_type, 30> >("Q", 35, 3);
   print_gauss_constants<boost::math::quadrature::gauss<mp_type, 30> >("", 115, 4);


   print_gauss_kronrod_constants<boost::math::quadrature::gauss_kronrod<mp_type, 15> >("f", 9, 0);
   print_gauss_kronrod_constants<boost::math::quadrature::gauss_kronrod<mp_type, 15> >("", 17, 1);
   print_gauss_kronrod_constants<boost::math::quadrature::gauss_kronrod<mp_type, 15> >("L", 35, 2);
   print_gauss_kronrod_constants<boost::math::quadrature::gauss_kronrod<mp_type, 15> >("Q", 35, 3);
   print_gauss_kronrod_constants<boost::math::quadrature::gauss_kronrod<mp_type, 15> >("", 115, 4);

   print_gauss_kronrod_constants<boost::math::quadrature::gauss_kronrod<mp_type, 21> >("f", 9, 0);
   print_gauss_kronrod_constants<boost::math::quadrature::gauss_kronrod<mp_type, 21> >("", 17, 1);
   print_gauss_kronrod_constants<boost::math::quadrature::gauss_kronrod<mp_type, 21> >("L", 35, 2);
   print_gauss_kronrod_constants<boost::math::quadrature::gauss_kronrod<mp_type, 21> >("Q", 35, 3);
   print_gauss_kronrod_constants<boost::math::quadrature::gauss_kronrod<mp_type, 21> >("", 115, 4);

   print_gauss_kronrod_constants<boost::math::quadrature::gauss_kronrod<mp_type, 31> >("f", 9, 0);
   print_gauss_kronrod_constants<boost::math::quadrature::gauss_kronrod<mp_type, 31> >("", 17, 1);
   print_gauss_kronrod_constants<boost::math::quadrature::gauss_kronrod<mp_type, 31> >("L", 35, 2);
   print_gauss_kronrod_constants<boost::math::quadrature::gauss_kronrod<mp_type, 31> >("Q", 35, 3);
   print_gauss_kronrod_constants<boost::math::quadrature::gauss_kronrod<mp_type, 31> >("", 115, 4);

   print_gauss_kronrod_constants<boost::math::quadrature::gauss_kronrod<mp_type, 41> >("f", 9, 0);
   print_gauss_kronrod_constants<boost::math::quadrature::gauss_kronrod<mp_type, 41> >("", 17, 1);
   print_gauss_kronrod_constants<boost::math::quadrature::gauss_kronrod<mp_type, 41> >("L", 35, 2);
   print_gauss_kronrod_constants<boost::math::quadrature::gauss_kronrod<mp_type, 41> >("Q", 35, 3);
   print_gauss_kronrod_constants<boost::math::quadrature::gauss_kronrod<mp_type, 41> >("", 115, 4);

   print_gauss_kronrod_constants<boost::math::quadrature::gauss_kronrod<mp_type, 51> >("f", 9, 0);
   print_gauss_kronrod_constants<boost::math::quadrature::gauss_kronrod<mp_type, 51> >("", 17, 1);
   print_gauss_kronrod_constants<boost::math::quadrature::gauss_kronrod<mp_type, 51> >("L", 35, 2);
   print_gauss_kronrod_constants<boost::math::quadrature::gauss_kronrod<mp_type, 51> >("Q", 35, 3);
   print_gauss_kronrod_constants<boost::math::quadrature::gauss_kronrod<mp_type, 51> >("", 115, 4);

   print_gauss_kronrod_constants<boost::math::quadrature::gauss_kronrod<mp_type, 61> >("f", 9, 0);
   print_gauss_kronrod_constants<boost::math::quadrature::gauss_kronrod<mp_type, 61> >("", 17, 1);
   print_gauss_kronrod_constants<boost::math::quadrature::gauss_kronrod<mp_type, 61> >("L", 35, 2);
   print_gauss_kronrod_constants<boost::math::quadrature::gauss_kronrod<mp_type, 61> >("Q", 35, 3);
   print_gauss_kronrod_constants<boost::math::quadrature::gauss_kronrod<mp_type, 61> >("", 115, 4);

   return 0;
}