1 |
424 |
jeremybenn |
// 2007-02-04 Edward Smith-Rowland <3dw4rd@verizon.net>
|
2 |
|
|
//
|
3 |
|
|
// Copyright (C) 2007, 2009 Free Software Foundation, Inc.
|
4 |
|
|
//
|
5 |
|
|
// This file is part of the GNU ISO C++ Library. This library is free
|
6 |
|
|
// software; you can redistribute it and/or modify it under the
|
7 |
|
|
// terms of the GNU General Public License as published by the
|
8 |
|
|
// Free Software Foundation; either version 3, or (at your option)
|
9 |
|
|
// any later version.
|
10 |
|
|
//
|
11 |
|
|
// This library is distributed in the hope that it will be useful,
|
12 |
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
|
|
// GNU General Public License for more details.
|
15 |
|
|
//
|
16 |
|
|
// You should have received a copy of the GNU General Public License along
|
17 |
|
|
// with this library; see the file COPYING3. If not see
|
18 |
|
|
// <http://www.gnu.org/licenses/>.
|
19 |
|
|
|
20 |
|
|
// laguerre
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
// Compare against values generated by the GNU Scientific Library.
|
24 |
|
|
// The GSL can be found on the web: http://www.gnu.org/software/gsl/
|
25 |
|
|
|
26 |
|
|
#include <tr1/cmath>
|
27 |
|
|
#if defined(__TEST_DEBUG)
|
28 |
|
|
#include <iostream>
|
29 |
|
|
#define VERIFY(A) \
|
30 |
|
|
if (!(A)) \
|
31 |
|
|
{ \
|
32 |
|
|
std::cout << "line " << __LINE__ \
|
33 |
|
|
<< " max_abs_frac = " << max_abs_frac \
|
34 |
|
|
<< std::endl; \
|
35 |
|
|
}
|
36 |
|
|
#else
|
37 |
|
|
#include <testsuite_hooks.h>
|
38 |
|
|
#endif
|
39 |
|
|
#include "../testcase.h"
|
40 |
|
|
|
41 |
|
|
|
42 |
|
|
// Test data for n=0.
|
43 |
|
|
testcase_laguerre<double> data001[] = {
|
44 |
|
|
{ 1.0000000000000000, 0, 0.0000000000000000 },
|
45 |
|
|
{ 1.0000000000000000, 0, 5.0000000000000000 },
|
46 |
|
|
{ 1.0000000000000000, 0, 10.000000000000000 },
|
47 |
|
|
{ 1.0000000000000000, 0, 15.000000000000000 },
|
48 |
|
|
{ 1.0000000000000000, 0, 20.000000000000000 },
|
49 |
|
|
{ 1.0000000000000000, 0, 25.000000000000000 },
|
50 |
|
|
{ 1.0000000000000000, 0, 30.000000000000000 },
|
51 |
|
|
{ 1.0000000000000000, 0, 35.000000000000000 },
|
52 |
|
|
{ 1.0000000000000000, 0, 40.000000000000000 },
|
53 |
|
|
{ 1.0000000000000000, 0, 45.000000000000000 },
|
54 |
|
|
{ 1.0000000000000000, 0, 50.000000000000000 },
|
55 |
|
|
{ 1.0000000000000000, 0, 55.000000000000000 },
|
56 |
|
|
{ 1.0000000000000000, 0, 60.000000000000000 },
|
57 |
|
|
{ 1.0000000000000000, 0, 65.000000000000000 },
|
58 |
|
|
{ 1.0000000000000000, 0, 70.000000000000000 },
|
59 |
|
|
{ 1.0000000000000000, 0, 75.000000000000000 },
|
60 |
|
|
{ 1.0000000000000000, 0, 80.000000000000000 },
|
61 |
|
|
{ 1.0000000000000000, 0, 85.000000000000000 },
|
62 |
|
|
{ 1.0000000000000000, 0, 90.000000000000000 },
|
63 |
|
|
{ 1.0000000000000000, 0, 95.000000000000000 },
|
64 |
|
|
{ 1.0000000000000000, 0, 100.00000000000000 },
|
65 |
|
|
};
|
66 |
|
|
|
67 |
|
|
// Test function for n=0.
|
68 |
|
|
template <typename Tp>
|
69 |
|
|
void test001()
|
70 |
|
|
{
|
71 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
72 |
|
|
Tp max_abs_diff = -Tp(1);
|
73 |
|
|
Tp max_abs_frac = -Tp(1);
|
74 |
|
|
unsigned int num_datum = sizeof(data001)
|
75 |
|
|
/ sizeof(testcase_laguerre<double>);
|
76 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
77 |
|
|
{
|
78 |
|
|
const Tp f = std::tr1::laguerre(Tp(data001[i].n), Tp(data001[i].x));
|
79 |
|
|
const Tp f0 = data001[i].f0;
|
80 |
|
|
const Tp diff = f - f0;
|
81 |
|
|
if (std::abs(diff) > max_abs_diff)
|
82 |
|
|
max_abs_diff = std::abs(diff);
|
83 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
84 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
85 |
|
|
{
|
86 |
|
|
const Tp frac = diff / f0;
|
87 |
|
|
if (std::abs(frac) > max_abs_frac)
|
88 |
|
|
max_abs_frac = std::abs(frac);
|
89 |
|
|
}
|
90 |
|
|
}
|
91 |
|
|
VERIFY(max_abs_frac < Tp(2.5000000000000020e-13));
|
92 |
|
|
}
|
93 |
|
|
|
94 |
|
|
// Test data for n=1.
|
95 |
|
|
testcase_laguerre<double> data002[] = {
|
96 |
|
|
{ 1.0000000000000000, 1, 0.0000000000000000 },
|
97 |
|
|
{ -4.0000000000000000, 1, 5.0000000000000000 },
|
98 |
|
|
{ -9.0000000000000000, 1, 10.000000000000000 },
|
99 |
|
|
{ -14.000000000000000, 1, 15.000000000000000 },
|
100 |
|
|
{ -19.000000000000000, 1, 20.000000000000000 },
|
101 |
|
|
{ -24.000000000000000, 1, 25.000000000000000 },
|
102 |
|
|
{ -29.000000000000000, 1, 30.000000000000000 },
|
103 |
|
|
{ -34.000000000000000, 1, 35.000000000000000 },
|
104 |
|
|
{ -39.000000000000000, 1, 40.000000000000000 },
|
105 |
|
|
{ -44.000000000000000, 1, 45.000000000000000 },
|
106 |
|
|
{ -49.000000000000000, 1, 50.000000000000000 },
|
107 |
|
|
{ -54.000000000000000, 1, 55.000000000000000 },
|
108 |
|
|
{ -59.000000000000000, 1, 60.000000000000000 },
|
109 |
|
|
{ -64.000000000000000, 1, 65.000000000000000 },
|
110 |
|
|
{ -69.000000000000000, 1, 70.000000000000000 },
|
111 |
|
|
{ -74.000000000000000, 1, 75.000000000000000 },
|
112 |
|
|
{ -79.000000000000000, 1, 80.000000000000000 },
|
113 |
|
|
{ -84.000000000000000, 1, 85.000000000000000 },
|
114 |
|
|
{ -89.000000000000000, 1, 90.000000000000000 },
|
115 |
|
|
{ -94.000000000000000, 1, 95.000000000000000 },
|
116 |
|
|
{ -99.000000000000000, 1, 100.00000000000000 },
|
117 |
|
|
};
|
118 |
|
|
|
119 |
|
|
// Test function for n=1.
|
120 |
|
|
template <typename Tp>
|
121 |
|
|
void test002()
|
122 |
|
|
{
|
123 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
124 |
|
|
Tp max_abs_diff = -Tp(1);
|
125 |
|
|
Tp max_abs_frac = -Tp(1);
|
126 |
|
|
unsigned int num_datum = sizeof(data002)
|
127 |
|
|
/ sizeof(testcase_laguerre<double>);
|
128 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
129 |
|
|
{
|
130 |
|
|
const Tp f = std::tr1::laguerre(Tp(data002[i].n), Tp(data002[i].x));
|
131 |
|
|
const Tp f0 = data002[i].f0;
|
132 |
|
|
const Tp diff = f - f0;
|
133 |
|
|
if (std::abs(diff) > max_abs_diff)
|
134 |
|
|
max_abs_diff = std::abs(diff);
|
135 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
136 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
137 |
|
|
{
|
138 |
|
|
const Tp frac = diff / f0;
|
139 |
|
|
if (std::abs(frac) > max_abs_frac)
|
140 |
|
|
max_abs_frac = std::abs(frac);
|
141 |
|
|
}
|
142 |
|
|
}
|
143 |
|
|
VERIFY(max_abs_frac < Tp(2.5000000000000020e-13));
|
144 |
|
|
}
|
145 |
|
|
|
146 |
|
|
// Test data for n=2.
|
147 |
|
|
testcase_laguerre<double> data003[] = {
|
148 |
|
|
{ 1.0000000000000000, 2, 0.0000000000000000 },
|
149 |
|
|
{ 3.5000000000000000, 2, 5.0000000000000000 },
|
150 |
|
|
{ 31.000000000000000, 2, 10.000000000000000 },
|
151 |
|
|
{ 83.500000000000000, 2, 15.000000000000000 },
|
152 |
|
|
{ 161.00000000000000, 2, 20.000000000000000 },
|
153 |
|
|
{ 263.50000000000000, 2, 25.000000000000000 },
|
154 |
|
|
{ 391.00000000000000, 2, 30.000000000000000 },
|
155 |
|
|
{ 543.50000000000000, 2, 35.000000000000000 },
|
156 |
|
|
{ 721.00000000000000, 2, 40.000000000000000 },
|
157 |
|
|
{ 923.50000000000000, 2, 45.000000000000000 },
|
158 |
|
|
{ 1151.0000000000000, 2, 50.000000000000000 },
|
159 |
|
|
{ 1403.5000000000000, 2, 55.000000000000000 },
|
160 |
|
|
{ 1681.0000000000000, 2, 60.000000000000000 },
|
161 |
|
|
{ 1983.5000000000000, 2, 65.000000000000000 },
|
162 |
|
|
{ 2311.0000000000000, 2, 70.000000000000000 },
|
163 |
|
|
{ 2663.5000000000000, 2, 75.000000000000000 },
|
164 |
|
|
{ 3041.0000000000000, 2, 80.000000000000000 },
|
165 |
|
|
{ 3443.5000000000000, 2, 85.000000000000000 },
|
166 |
|
|
{ 3871.0000000000000, 2, 90.000000000000000 },
|
167 |
|
|
{ 4323.5000000000000, 2, 95.000000000000000 },
|
168 |
|
|
{ 4801.0000000000000, 2, 100.00000000000000 },
|
169 |
|
|
};
|
170 |
|
|
|
171 |
|
|
// Test function for n=2.
|
172 |
|
|
template <typename Tp>
|
173 |
|
|
void test003()
|
174 |
|
|
{
|
175 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
176 |
|
|
Tp max_abs_diff = -Tp(1);
|
177 |
|
|
Tp max_abs_frac = -Tp(1);
|
178 |
|
|
unsigned int num_datum = sizeof(data003)
|
179 |
|
|
/ sizeof(testcase_laguerre<double>);
|
180 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
181 |
|
|
{
|
182 |
|
|
const Tp f = std::tr1::laguerre(Tp(data003[i].n), Tp(data003[i].x));
|
183 |
|
|
const Tp f0 = data003[i].f0;
|
184 |
|
|
const Tp diff = f - f0;
|
185 |
|
|
if (std::abs(diff) > max_abs_diff)
|
186 |
|
|
max_abs_diff = std::abs(diff);
|
187 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
188 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
189 |
|
|
{
|
190 |
|
|
const Tp frac = diff / f0;
|
191 |
|
|
if (std::abs(frac) > max_abs_frac)
|
192 |
|
|
max_abs_frac = std::abs(frac);
|
193 |
|
|
}
|
194 |
|
|
}
|
195 |
|
|
VERIFY(max_abs_frac < Tp(2.5000000000000020e-13));
|
196 |
|
|
}
|
197 |
|
|
|
198 |
|
|
// Test data for n=5.
|
199 |
|
|
testcase_laguerre<double> data004[] = {
|
200 |
|
|
{ 1.0000000000000000, 5, 0.0000000000000000 },
|
201 |
|
|
{ -3.1666666666666665, 5, 5.0000000000000000 },
|
202 |
|
|
{ 34.333333333333329, 5, 10.000000000000000 },
|
203 |
|
|
{ -355.25000000000000, 5, 15.000000000000000 },
|
204 |
|
|
{ -4765.6666666666670, 5, 20.000000000000000 },
|
205 |
|
|
{ -23040.666666666664, 5, 25.000000000000000 },
|
206 |
|
|
{ -74399.000000000000, 5, 30.000000000000000 },
|
207 |
|
|
{ -190559.41666666663, 5, 35.000000000000000 },
|
208 |
|
|
{ -418865.66666666663, 5, 40.000000000000000 },
|
209 |
|
|
{ -825411.50000000000, 5, 45.000000000000000 },
|
210 |
|
|
{ -1498165.6666666665, 5, 50.000000000000000 },
|
211 |
|
|
{ -2550096.9166666670, 5, 55.000000000000000 },
|
212 |
|
|
{ -4122299.0000000000, 5, 60.000000000000000 },
|
213 |
|
|
{ -6387115.6666666670, 5, 65.000000000000000 },
|
214 |
|
|
{ -9551265.6666666679, 5, 70.000000000000000 },
|
215 |
|
|
{ -13858967.750000000, 5, 75.000000000000000 },
|
216 |
|
|
{ -19595065.666666664, 5, 80.000000000000000 },
|
217 |
|
|
{ -27088153.166666668, 5, 85.000000000000000 },
|
218 |
|
|
{ -36713699.000000000, 5, 90.000000000000000 },
|
219 |
|
|
{ -48897171.916666657, 5, 95.000000000000000 },
|
220 |
|
|
{ -64117165.666666664, 5, 100.00000000000000 },
|
221 |
|
|
};
|
222 |
|
|
|
223 |
|
|
// Test function for n=5.
|
224 |
|
|
template <typename Tp>
|
225 |
|
|
void test004()
|
226 |
|
|
{
|
227 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
228 |
|
|
Tp max_abs_diff = -Tp(1);
|
229 |
|
|
Tp max_abs_frac = -Tp(1);
|
230 |
|
|
unsigned int num_datum = sizeof(data004)
|
231 |
|
|
/ sizeof(testcase_laguerre<double>);
|
232 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
233 |
|
|
{
|
234 |
|
|
const Tp f = std::tr1::laguerre(Tp(data004[i].n), Tp(data004[i].x));
|
235 |
|
|
const Tp f0 = data004[i].f0;
|
236 |
|
|
const Tp diff = f - f0;
|
237 |
|
|
if (std::abs(diff) > max_abs_diff)
|
238 |
|
|
max_abs_diff = std::abs(diff);
|
239 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
240 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
241 |
|
|
{
|
242 |
|
|
const Tp frac = diff / f0;
|
243 |
|
|
if (std::abs(frac) > max_abs_frac)
|
244 |
|
|
max_abs_frac = std::abs(frac);
|
245 |
|
|
}
|
246 |
|
|
}
|
247 |
|
|
VERIFY(max_abs_frac < Tp(2.5000000000000020e-13));
|
248 |
|
|
}
|
249 |
|
|
|
250 |
|
|
// Test data for n=10.
|
251 |
|
|
testcase_laguerre<double> data005[] = {
|
252 |
|
|
{ 1.0000000000000000, 10, 0.0000000000000000 },
|
253 |
|
|
{ 1.7562761794532620, 10, 5.0000000000000000 },
|
254 |
|
|
{ 27.984126984126981, 10, 10.000000000000000 },
|
255 |
|
|
{ -237.51841517857147, 10, 15.000000000000000 },
|
256 |
|
|
{ 3227.8077601410932, 10, 20.000000000000000 },
|
257 |
|
|
{ -45786.199797453693, 10, 25.000000000000000 },
|
258 |
|
|
{ 15129.571428571489, 10, 30.000000000000000 },
|
259 |
|
|
{ 7764800.8179494590, 10, 35.000000000000000 },
|
260 |
|
|
{ 79724066.608465582, 10, 40.000000000000000 },
|
261 |
|
|
{ 469865425.65122765, 10, 45.000000000000000 },
|
262 |
|
|
{ 2037190065.3738980, 10, 50.000000000000000 },
|
263 |
|
|
{ 7187828002.9825764, 10, 55.000000000000000 },
|
264 |
|
|
{ 21804200401.000000, 10, 60.000000000000000 },
|
265 |
|
|
{ 58854343015.616211, 10, 65.000000000000000 },
|
266 |
|
|
{ 144688291819.51855, 10, 70.000000000000000 },
|
267 |
|
|
{ 329425241736.70038, 10, 75.000000000000000 },
|
268 |
|
|
{ 703324772760.08276, 10, 80.000000000000000 },
|
269 |
|
|
{ 1421627560118.6157, 10, 85.000000000000000 },
|
270 |
|
|
{ 2741055412243.8569, 10, 90.000000000000000 },
|
271 |
|
|
{ 5071986977681.8652, 10, 95.000000000000000 },
|
272 |
|
|
{ 9051283795429.5723, 10, 100.00000000000000 },
|
273 |
|
|
};
|
274 |
|
|
|
275 |
|
|
// Test function for n=10.
|
276 |
|
|
template <typename Tp>
|
277 |
|
|
void test005()
|
278 |
|
|
{
|
279 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
280 |
|
|
Tp max_abs_diff = -Tp(1);
|
281 |
|
|
Tp max_abs_frac = -Tp(1);
|
282 |
|
|
unsigned int num_datum = sizeof(data005)
|
283 |
|
|
/ sizeof(testcase_laguerre<double>);
|
284 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
285 |
|
|
{
|
286 |
|
|
const Tp f = std::tr1::laguerre(Tp(data005[i].n), Tp(data005[i].x));
|
287 |
|
|
const Tp f0 = data005[i].f0;
|
288 |
|
|
const Tp diff = f - f0;
|
289 |
|
|
if (std::abs(diff) > max_abs_diff)
|
290 |
|
|
max_abs_diff = std::abs(diff);
|
291 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
292 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
293 |
|
|
{
|
294 |
|
|
const Tp frac = diff / f0;
|
295 |
|
|
if (std::abs(frac) > max_abs_frac)
|
296 |
|
|
max_abs_frac = std::abs(frac);
|
297 |
|
|
}
|
298 |
|
|
}
|
299 |
|
|
VERIFY(max_abs_frac < Tp(5.0000000000000039e-13));
|
300 |
|
|
}
|
301 |
|
|
|
302 |
|
|
// Test data for n=20.
|
303 |
|
|
testcase_laguerre<double> data006[] = {
|
304 |
|
|
{ 1.0000000000000000, 20, 0.0000000000000000 },
|
305 |
|
|
{ 2.0202257444769129, 20, 5.0000000000000000 },
|
306 |
|
|
{ -11.961333867812119, 20, 10.000000000000000 },
|
307 |
|
|
{ -50.151037960139455, 20, 15.000000000000000 },
|
308 |
|
|
{ 2829.4728613531738, 20, 20.000000000000000 },
|
309 |
|
|
{ -11583.947899113535, 20, 25.000000000000000 },
|
310 |
|
|
{ -18439.424502520938, 20, 30.000000000000000 },
|
311 |
|
|
{ -38838.223606979467, 20, 35.000000000000000 },
|
312 |
|
|
{ 24799805.877530701, 20, 40.000000000000000 },
|
313 |
|
|
{ -673953823.59913290, 20, 45.000000000000000 },
|
314 |
|
|
{ 7551960453.7672529, 20, 50.000000000000000 },
|
315 |
|
|
{ 31286508510.614754, 20, 55.000000000000000 },
|
316 |
|
|
{ -1379223608444.9155, 20, 60.000000000000000 },
|
317 |
|
|
{ -6692517968212.9727, 20, 65.000000000000000 },
|
318 |
|
|
{ 165423821874449.94, 20, 70.000000000000000 },
|
319 |
|
|
{ 3082390018008546.5, 20, 75.000000000000000 },
|
320 |
|
|
{ 29500368536981676., 20, 80.000000000000000 },
|
321 |
|
|
{ 2.0353526354974186e+17, 20, 85.000000000000000 },
|
322 |
|
|
{ 1.1292309514432899e+18, 20, 90.000000000000000 },
|
323 |
|
|
{ 5.3239262855563100e+18, 20, 95.000000000000000 },
|
324 |
|
|
{ 2.2061882785931735e+19, 20, 100.00000000000000 },
|
325 |
|
|
};
|
326 |
|
|
|
327 |
|
|
// Test function for n=20.
|
328 |
|
|
template <typename Tp>
|
329 |
|
|
void test006()
|
330 |
|
|
{
|
331 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
332 |
|
|
Tp max_abs_diff = -Tp(1);
|
333 |
|
|
Tp max_abs_frac = -Tp(1);
|
334 |
|
|
unsigned int num_datum = sizeof(data006)
|
335 |
|
|
/ sizeof(testcase_laguerre<double>);
|
336 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
337 |
|
|
{
|
338 |
|
|
const Tp f = std::tr1::laguerre(Tp(data006[i].n), Tp(data006[i].x));
|
339 |
|
|
const Tp f0 = data006[i].f0;
|
340 |
|
|
const Tp diff = f - f0;
|
341 |
|
|
if (std::abs(diff) > max_abs_diff)
|
342 |
|
|
max_abs_diff = std::abs(diff);
|
343 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
344 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
345 |
|
|
{
|
346 |
|
|
const Tp frac = diff / f0;
|
347 |
|
|
if (std::abs(frac) > max_abs_frac)
|
348 |
|
|
max_abs_frac = std::abs(frac);
|
349 |
|
|
}
|
350 |
|
|
}
|
351 |
|
|
VERIFY(max_abs_frac < Tp(1.0000000000000008e-12));
|
352 |
|
|
}
|
353 |
|
|
|
354 |
|
|
// Test data for n=50.
|
355 |
|
|
testcase_laguerre<double> data007[] = {
|
356 |
|
|
{ 1.0000000000000000, 50, 0.0000000000000000 },
|
357 |
|
|
{ 1.4735258819430563, 50, 5.0000000000000000 },
|
358 |
|
|
{ 17.534183446338233, 50, 10.000000000000000 },
|
359 |
|
|
{ -195.62436619077388, 50, 15.000000000000000 },
|
360 |
|
|
{ 980.26961889790766, 50, 20.000000000000000 },
|
361 |
|
|
{ 24812.277673870871, 50, 25.000000000000000 },
|
362 |
|
|
{ 293000.50735962350, 50, 30.000000000000000 },
|
363 |
|
|
{ 2316195.5013375296, 50, 35.000000000000000 },
|
364 |
|
|
{ -14896937.968694847, 50, 40.000000000000000 },
|
365 |
|
|
{ -502066598.00813466, 50, 45.000000000000000 },
|
366 |
|
|
{ 2513677852.6916885, 50, 50.000000000000000 },
|
367 |
|
|
{ 45129675503.538948, 50, 55.000000000000000 },
|
368 |
|
|
{ -883876565337.99207, 50, 60.000000000000000 },
|
369 |
|
|
{ 9361319947203.8379, 50, 65.000000000000000 },
|
370 |
|
|
{ -80967880733583.219, 50, 70.000000000000000 },
|
371 |
|
|
{ 717391079438942.88, 50, 75.000000000000000 },
|
372 |
|
|
{ -8217471769564850.0, 50, 80.000000000000000 },
|
373 |
|
|
{ 1.2595276229009984e+17, 50, 85.000000000000000 },
|
374 |
|
|
{ -2.1140031308048906e+18, 50, 90.000000000000000 },
|
375 |
|
|
{ 3.2438187475835138e+19, 50, 95.000000000000000 },
|
376 |
|
|
{ -3.9710103487094673e+20, 50, 100.00000000000000 },
|
377 |
|
|
};
|
378 |
|
|
|
379 |
|
|
// Test function for n=50.
|
380 |
|
|
template <typename Tp>
|
381 |
|
|
void test007()
|
382 |
|
|
{
|
383 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
384 |
|
|
Tp max_abs_diff = -Tp(1);
|
385 |
|
|
Tp max_abs_frac = -Tp(1);
|
386 |
|
|
unsigned int num_datum = sizeof(data007)
|
387 |
|
|
/ sizeof(testcase_laguerre<double>);
|
388 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
389 |
|
|
{
|
390 |
|
|
const Tp f = std::tr1::laguerre(Tp(data007[i].n), Tp(data007[i].x));
|
391 |
|
|
const Tp f0 = data007[i].f0;
|
392 |
|
|
const Tp diff = f - f0;
|
393 |
|
|
if (std::abs(diff) > max_abs_diff)
|
394 |
|
|
max_abs_diff = std::abs(diff);
|
395 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
396 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
397 |
|
|
{
|
398 |
|
|
const Tp frac = diff / f0;
|
399 |
|
|
if (std::abs(frac) > max_abs_frac)
|
400 |
|
|
max_abs_frac = std::abs(frac);
|
401 |
|
|
}
|
402 |
|
|
}
|
403 |
|
|
VERIFY(max_abs_frac < Tp(2.5000000000000020e-13));
|
404 |
|
|
}
|
405 |
|
|
|
406 |
|
|
// Test data for n=100.
|
407 |
|
|
testcase_laguerre<double> data008[] = {
|
408 |
|
|
{ 1.0000000000000000, 100, 0.0000000000000000 },
|
409 |
|
|
{ 1.4555271625328832, 100, 5.0000000000000000 },
|
410 |
|
|
{ 13.277662844303402, 100, 10.000000000000000 },
|
411 |
|
|
{ 91.737038454342013, 100, 15.000000000000000 },
|
412 |
|
|
{ 1854.0367283243393, 100, 20.000000000000000 },
|
413 |
|
|
{ -11281.698886837237, 100, 25.000000000000000 },
|
414 |
|
|
{ 170141.86987046539, 100, 30.000000000000000 },
|
415 |
|
|
{ -2950092.7025822792, 100, 35.000000000000000 },
|
416 |
|
|
{ -7272442.3156007063, 100, 40.000000000000000 },
|
417 |
|
|
{ 295697471.90876174, 100, 45.000000000000000 },
|
418 |
|
|
{ 4847420871.2690468, 100, 50.000000000000000 },
|
419 |
|
|
{ 59406998102.392273, 100, 55.000000000000000 },
|
420 |
|
|
{ 693492765740.29736, 100, 60.000000000000000 },
|
421 |
|
|
{ 6606192010150.3096, 100, 65.000000000000000 },
|
422 |
|
|
{ 17125518672239.707, 100, 70.000000000000000 },
|
423 |
|
|
{ -870493767065151.38, 100, 75.000000000000000 },
|
424 |
|
|
{ -13763178176383754., 100, 80.000000000000000 },
|
425 |
|
|
{ 30667078414479724., 100, 85.000000000000000 },
|
426 |
|
|
{ 2.1307220490380198e+18, 100, 90.000000000000000 },
|
427 |
|
|
{ -7.2706523009007862e+18, 100, 95.000000000000000 },
|
428 |
|
|
{ -2.6292260693068920e+20, 100, 100.00000000000000 },
|
429 |
|
|
};
|
430 |
|
|
|
431 |
|
|
// Test function for n=100.
|
432 |
|
|
template <typename Tp>
|
433 |
|
|
void test008()
|
434 |
|
|
{
|
435 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
436 |
|
|
Tp max_abs_diff = -Tp(1);
|
437 |
|
|
Tp max_abs_frac = -Tp(1);
|
438 |
|
|
unsigned int num_datum = sizeof(data008)
|
439 |
|
|
/ sizeof(testcase_laguerre<double>);
|
440 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
441 |
|
|
{
|
442 |
|
|
const Tp f = std::tr1::laguerre(Tp(data008[i].n), Tp(data008[i].x));
|
443 |
|
|
const Tp f0 = data008[i].f0;
|
444 |
|
|
const Tp diff = f - f0;
|
445 |
|
|
if (std::abs(diff) > max_abs_diff)
|
446 |
|
|
max_abs_diff = std::abs(diff);
|
447 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
448 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
449 |
|
|
{
|
450 |
|
|
const Tp frac = diff / f0;
|
451 |
|
|
if (std::abs(frac) > max_abs_frac)
|
452 |
|
|
max_abs_frac = std::abs(frac);
|
453 |
|
|
}
|
454 |
|
|
}
|
455 |
|
|
VERIFY(max_abs_frac < Tp(2.5000000000000020e-13));
|
456 |
|
|
}
|
457 |
|
|
|
458 |
|
|
int main(int, char**)
|
459 |
|
|
{
|
460 |
|
|
test001<double>();
|
461 |
|
|
test002<double>();
|
462 |
|
|
test003<double>();
|
463 |
|
|
test004<double>();
|
464 |
|
|
test005<double>();
|
465 |
|
|
test006<double>();
|
466 |
|
|
test007<double>();
|
467 |
|
|
test008<double>();
|
468 |
|
|
return 0;
|
469 |
|
|
}
|