]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/special_functions/16_laguerre/check_value.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / special_functions / 16_laguerre / check_value.cc
CommitLineData
196c9e7a 1// { dg-do run { target c++11 } }
2be75957
ESR
2// { dg-options "-D__STDCPP_WANT_MATH_SPEC_FUNCS__" }
3//
a945c346 4// Copyright (C) 2016-2024 Free Software Foundation, Inc.
2be75957
ESR
5//
6// This file is part of the GNU ISO C++ Library. This library is free
7// software; you can redistribute it and/or modify it under the
8// terms of the GNU General Public License as published by the
9// Free Software Foundation; either version 3, or (at your option)
10// any later version.
11//
12// This library is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License along
18// with this library; see the file COPYING3. If not see
19// <http://www.gnu.org/licenses/>.
20
21// laguerre
22// Compare against values generated by the GNU Scientific Library.
23// The GSL can be found on the web: http://www.gnu.org/software/gsl/
24#include <limits>
25#include <cmath>
26#if defined(__TEST_DEBUG)
27# include <iostream>
28# define VERIFY(A) \
29 if (!(A)) \
30 { \
31 std::cout << "line " << __LINE__ \
32 << " max_abs_frac = " << max_abs_frac \
33 << std::endl; \
34 }
35#else
36# include <testsuite_hooks.h>
37#endif
38#include <specfun_testcase.h>
39
2be75957 40// Test data for n=0.
b4688136 41// max(|f - f_GSL|): 0.0000000000000000 at index 0
2be75957 42// max(|f - f_GSL| / |f_GSL|): 0.0000000000000000
b4688136
ESR
43// mean(f - f_GSL): 0.0000000000000000
44// variance(f - f_GSL): 0.0000000000000000
45// stddev(f - f_GSL): 0.0000000000000000
2be75957
ESR
46const testcase_laguerre<double>
47data001[21] =
48{
b4688136
ESR
49 { 1.0000000000000000, 0, 0.0000000000000000, 0.0 },
50 { 1.0000000000000000, 0, 5.0000000000000000, 0.0 },
51 { 1.0000000000000000, 0, 10.000000000000000, 0.0 },
52 { 1.0000000000000000, 0, 15.000000000000000, 0.0 },
53 { 1.0000000000000000, 0, 20.000000000000000, 0.0 },
54 { 1.0000000000000000, 0, 25.000000000000000, 0.0 },
55 { 1.0000000000000000, 0, 30.000000000000000, 0.0 },
56 { 1.0000000000000000, 0, 35.000000000000000, 0.0 },
57 { 1.0000000000000000, 0, 40.000000000000000, 0.0 },
58 { 1.0000000000000000, 0, 45.000000000000000, 0.0 },
59 { 1.0000000000000000, 0, 50.000000000000000, 0.0 },
60 { 1.0000000000000000, 0, 55.000000000000000, 0.0 },
61 { 1.0000000000000000, 0, 60.000000000000000, 0.0 },
62 { 1.0000000000000000, 0, 65.000000000000000, 0.0 },
63 { 1.0000000000000000, 0, 70.000000000000000, 0.0 },
64 { 1.0000000000000000, 0, 75.000000000000000, 0.0 },
65 { 1.0000000000000000, 0, 80.000000000000000, 0.0 },
66 { 1.0000000000000000, 0, 85.000000000000000, 0.0 },
67 { 1.0000000000000000, 0, 90.000000000000000, 0.0 },
68 { 1.0000000000000000, 0, 95.000000000000000, 0.0 },
69 { 1.0000000000000000, 0, 100.00000000000000, 0.0 },
2be75957
ESR
70};
71const double toler001 = 2.5000000000000020e-13;
72
73// Test data for n=1.
b4688136 74// max(|f - f_GSL|): 0.0000000000000000 at index 0
2be75957 75// max(|f - f_GSL| / |f_GSL|): 0.0000000000000000
b4688136
ESR
76// mean(f - f_GSL): 0.0000000000000000
77// variance(f - f_GSL): 0.0000000000000000
78// stddev(f - f_GSL): 0.0000000000000000
2be75957
ESR
79const testcase_laguerre<double>
80data002[21] =
81{
b4688136
ESR
82 { 1.0000000000000000, 1, 0.0000000000000000, 0.0 },
83 { -4.0000000000000000, 1, 5.0000000000000000, 0.0 },
84 { -9.0000000000000000, 1, 10.000000000000000, 0.0 },
85 { -14.000000000000000, 1, 15.000000000000000, 0.0 },
86 { -19.000000000000000, 1, 20.000000000000000, 0.0 },
87 { -24.000000000000000, 1, 25.000000000000000, 0.0 },
88 { -29.000000000000000, 1, 30.000000000000000, 0.0 },
89 { -34.000000000000000, 1, 35.000000000000000, 0.0 },
90 { -39.000000000000000, 1, 40.000000000000000, 0.0 },
91 { -44.000000000000000, 1, 45.000000000000000, 0.0 },
92 { -49.000000000000000, 1, 50.000000000000000, 0.0 },
93 { -54.000000000000000, 1, 55.000000000000000, 0.0 },
94 { -59.000000000000000, 1, 60.000000000000000, 0.0 },
95 { -64.000000000000000, 1, 65.000000000000000, 0.0 },
96 { -69.000000000000000, 1, 70.000000000000000, 0.0 },
97 { -74.000000000000000, 1, 75.000000000000000, 0.0 },
98 { -79.000000000000000, 1, 80.000000000000000, 0.0 },
99 { -84.000000000000000, 1, 85.000000000000000, 0.0 },
100 { -89.000000000000000, 1, 90.000000000000000, 0.0 },
101 { -94.000000000000000, 1, 95.000000000000000, 0.0 },
102 { -99.000000000000000, 1, 100.00000000000000, 0.0 },
2be75957
ESR
103};
104const double toler002 = 2.5000000000000020e-13;
105
106// Test data for n=2.
b4688136 107// max(|f - f_GSL|): 0.0000000000000000 at index 0
2be75957 108// max(|f - f_GSL| / |f_GSL|): 0.0000000000000000
b4688136
ESR
109// mean(f - f_GSL): 0.0000000000000000
110// variance(f - f_GSL): 0.0000000000000000
111// stddev(f - f_GSL): 0.0000000000000000
2be75957
ESR
112const testcase_laguerre<double>
113data003[21] =
114{
b4688136
ESR
115 { 1.0000000000000000, 2, 0.0000000000000000, 0.0 },
116 { 3.5000000000000000, 2, 5.0000000000000000, 0.0 },
117 { 31.000000000000000, 2, 10.000000000000000, 0.0 },
118 { 83.500000000000000, 2, 15.000000000000000, 0.0 },
119 { 161.00000000000000, 2, 20.000000000000000, 0.0 },
120 { 263.50000000000000, 2, 25.000000000000000, 0.0 },
121 { 391.00000000000000, 2, 30.000000000000000, 0.0 },
122 { 543.50000000000000, 2, 35.000000000000000, 0.0 },
123 { 721.00000000000000, 2, 40.000000000000000, 0.0 },
124 { 923.50000000000000, 2, 45.000000000000000, 0.0 },
125 { 1151.0000000000000, 2, 50.000000000000000, 0.0 },
126 { 1403.5000000000000, 2, 55.000000000000000, 0.0 },
127 { 1681.0000000000000, 2, 60.000000000000000, 0.0 },
128 { 1983.5000000000000, 2, 65.000000000000000, 0.0 },
129 { 2311.0000000000000, 2, 70.000000000000000, 0.0 },
130 { 2663.5000000000000, 2, 75.000000000000000, 0.0 },
131 { 3041.0000000000000, 2, 80.000000000000000, 0.0 },
132 { 3443.5000000000000, 2, 85.000000000000000, 0.0 },
133 { 3871.0000000000000, 2, 90.000000000000000, 0.0 },
134 { 4323.5000000000000, 2, 95.000000000000000, 0.0 },
135 { 4801.0000000000000, 2, 100.00000000000000, 0.0 },
2be75957
ESR
136};
137const double toler003 = 2.5000000000000020e-13;
138
139// Test data for n=5.
b4688136 140// max(|f - f_GSL|): 7.4505805969238281e-09 at index 20
2be75957 141// max(|f - f_GSL| / |f_GSL|): 1.9501553136894460e-16
b4688136
ESR
142// mean(f - f_GSL): -9.1645146498075565e-11
143// variance(f - f_GSL): 2.8430813755854757e-18
144// stddev(f - f_GSL): 1.6861439367934980e-09
2be75957
ESR
145const testcase_laguerre<double>
146data004[21] =
147{
b4688136
ESR
148 { 1.0000000000000000, 5, 0.0000000000000000, 0.0 },
149 { -3.1666666666666665, 5, 5.0000000000000000, 0.0 },
150 { 34.333333333333329, 5, 10.000000000000000, 0.0 },
151 { -355.25000000000000, 5, 15.000000000000000, 0.0 },
152 { -4765.6666666666670, 5, 20.000000000000000, 0.0 },
153 { -23040.666666666664, 5, 25.000000000000000, 0.0 },
154 { -74399.000000000000, 5, 30.000000000000000, 0.0 },
155 { -190559.41666666663, 5, 35.000000000000000, 0.0 },
156 { -418865.66666666663, 5, 40.000000000000000, 0.0 },
157 { -825411.50000000000, 5, 45.000000000000000, 0.0 },
158 { -1498165.6666666665, 5, 50.000000000000000, 0.0 },
159 { -2550096.9166666670, 5, 55.000000000000000, 0.0 },
160 { -4122299.0000000000, 5, 60.000000000000000, 0.0 },
161 { -6387115.6666666670, 5, 65.000000000000000, 0.0 },
162 { -9551265.6666666679, 5, 70.000000000000000, 0.0 },
163 { -13858967.750000000, 5, 75.000000000000000, 0.0 },
164 { -19595065.666666664, 5, 80.000000000000000, 0.0 },
165 { -27088153.166666668, 5, 85.000000000000000, 0.0 },
166 { -36713699.000000000, 5, 90.000000000000000, 0.0 },
167 { -48897171.916666657, 5, 95.000000000000000, 0.0 },
168 { -64117165.666666664, 5, 100.00000000000000, 0.0 },
2be75957
ESR
169};
170const double toler004 = 2.5000000000000020e-13;
171
172// Test data for n=10.
b4688136 173// max(|f - f_GSL|): 0.0029296875000000000 at index 19
2be75957 174// max(|f - f_GSL| / |f_GSL|): 6.1315986390500118e-15
b4688136
ESR
175// mean(f - f_GSL): -0.00011841882388131082
176// variance(f - f_GSL): 7.3638903636883773e-10
177// stddev(f - f_GSL): 2.7136489020668051e-05
2be75957
ESR
178const testcase_laguerre<double>
179data005[21] =
180{
b4688136
ESR
181 { 1.0000000000000000, 10, 0.0000000000000000, 0.0 },
182 { 1.7562761794532631, 10, 5.0000000000000000, 0.0 },
183 { 27.984126984126977, 10, 10.000000000000000, 0.0 },
184 { -237.51841517857147, 10, 15.000000000000000, 0.0 },
185 { 3227.8077601410932, 10, 20.000000000000000, 0.0 },
186 { -45786.199797453693, 10, 25.000000000000000, 0.0 },
187 { 15129.571428571455, 10, 30.000000000000000, 0.0 },
188 { 7764800.8179494590, 10, 35.000000000000000, 0.0 },
189 { 79724066.608465582, 10, 40.000000000000000, 0.0 },
190 { 469865425.65122765, 10, 45.000000000000000, 0.0 },
191 { 2037190065.3738980, 10, 50.000000000000000, 0.0 },
192 { 7187828002.9825764, 10, 55.000000000000000, 0.0 },
193 { 21804200401.000000, 10, 60.000000000000000, 0.0 },
194 { 58854343015.616211, 10, 65.000000000000000, 0.0 },
195 { 144688291819.51855, 10, 70.000000000000000, 0.0 },
196 { 329425241736.70038, 10, 75.000000000000000, 0.0 },
197 { 703324772760.08276, 10, 80.000000000000000, 0.0 },
198 { 1421627560118.6157, 10, 85.000000000000000, 0.0 },
199 { 2741055412243.8569, 10, 90.000000000000000, 0.0 },
200 { 5071986977681.8652, 10, 95.000000000000000, 0.0 },
201 { 9051283795429.5723, 10, 100.00000000000000, 0.0 },
2be75957
ESR
202};
203const double toler005 = 5.0000000000000039e-13;
204
205// Test data for n=20.
b4688136 206// max(|f - f_GSL|): 2048.0000000000000 at index 19
2be75957 207// max(|f - f_GSL| / |f_GSL|): 7.1189246999774008e-15
b4688136
ESR
208// mean(f - f_GSL): -96.983562564903480
209// variance(f - f_GSL): 8.4641159685539344e+21
210// stddev(f - f_GSL): 92000630261.721222
2be75957
ESR
211const testcase_laguerre<double>
212data006[21] =
213{
b4688136
ESR
214 { 1.0000000000000000, 20, 0.0000000000000000, 0.0 },
215 { 2.0202257444769134, 20, 5.0000000000000000, 0.0 },
216 { -11.961333867812119, 20, 10.000000000000000, 0.0 },
217 { -50.151037960139455, 20, 15.000000000000000, 0.0 },
218 { 2829.4728613531743, 20, 20.000000000000000, 0.0 },
219 { -11583.947899113540, 20, 25.000000000000000, 0.0 },
220 { -18439.424502520938, 20, 30.000000000000000, 0.0 },
221 { -38838.223606979285, 20, 35.000000000000000, 0.0 },
222 { 24799805.877530713, 20, 40.000000000000000, 0.0 },
223 { -673953823.59913278, 20, 45.000000000000000, 0.0 },
224 { 7551960453.7672548, 20, 50.000000000000000, 0.0 },
225 { 31286508510.614746, 20, 55.000000000000000, 0.0 },
226 { -1379223608444.9155, 20, 60.000000000000000, 0.0 },
227 { -6692517968212.9717, 20, 65.000000000000000, 0.0 },
228 { 165423821874449.94, 20, 70.000000000000000, 0.0 },
229 { 3082390018008546.5, 20, 75.000000000000000, 0.0 },
230 { 29500368536981676., 20, 80.000000000000000, 0.0 },
231 { 2.0353526354974186e+17, 20, 85.000000000000000, 0.0 },
232 { 1.1292309514432901e+18, 20, 90.000000000000000, 0.0 },
233 { 5.3239262855563100e+18, 20, 95.000000000000000, 0.0 },
234 { 2.2061882785931735e+19, 20, 100.00000000000000, 0.0 },
2be75957
ESR
235};
236const double toler006 = 5.0000000000000039e-13;
237
238// Test data for n=50.
b4688136 239// max(|f - f_GSL|): 196608.00000000000 at index 20
2be75957 240// max(|f - f_GSL| / |f_GSL|): 4.2910775919271532e-15
b4688136
ESR
241// mean(f - f_GSL): -8840.7163987470722
242// variance(f - f_GSL): 9.4918743844066836e+19
243// stddev(f - f_GSL): 9742625100.2523346
2be75957
ESR
244const testcase_laguerre<double>
245data007[21] =
246{
b4688136
ESR
247 { 1.0000000000000000, 50, 0.0000000000000000, 0.0 },
248 { 1.4735258819430543, 50, 5.0000000000000000, 0.0 },
249 { 17.534183446338233, 50, 10.000000000000000, 0.0 },
250 { -195.62436619077380, 50, 15.000000000000000, 0.0 },
251 { 980.26961889791028, 50, 20.000000000000000, 0.0 },
252 { 24812.277673870878, 50, 25.000000000000000, 0.0 },
253 { 293000.50735962362, 50, 30.000000000000000, 0.0 },
254 { 2316195.5013375278, 50, 35.000000000000000, 0.0 },
255 { -14896937.968694873, 50, 40.000000000000000, 0.0 },
256 { -502066598.00813466, 50, 45.000000000000000, 0.0 },
257 { 2513677852.6916871, 50, 50.000000000000000, 0.0 },
258 { 45129675503.538910, 50, 55.000000000000000, 0.0 },
259 { -883876565337.99219, 50, 60.000000000000000, 0.0 },
260 { 9361319947203.8418, 50, 65.000000000000000, 0.0 },
261 { -80967880733583.234, 50, 70.000000000000000, 0.0 },
262 { 717391079438942.62, 50, 75.000000000000000, 0.0 },
263 { -8217471769564841.0, 50, 80.000000000000000, 0.0 },
264 { 1.2595276229009978e+17, 50, 85.000000000000000, 0.0 },
265 { -2.1140031308048891e+18, 50, 90.000000000000000, 0.0 },
266 { 3.2438187475835134e+19, 50, 95.000000000000000, 0.0 },
267 { -3.9710103487094692e+20, 50, 100.00000000000000, 0.0 },
2be75957
ESR
268};
269const double toler007 = 2.5000000000000020e-13;
270
271// Test data for n=100.
b4688136 272// max(|f - f_GSL|): 98304.000000000000 at index 20
2be75957 273// max(|f - f_GSL| / |f_GSL|): 3.8776197831393928e-15
b4688136
ESR
274// mean(f - f_GSL): -3668.6107413234895
275// variance(f - f_GSL): 2.7407314162194493e+19
276// stddev(f - f_GSL): 5235199534.1337748
2be75957
ESR
277const testcase_laguerre<double>
278data008[21] =
279{
b4688136
ESR
280 { 1.0000000000000000, 100, 0.0000000000000000, 0.0 },
281 { 1.4555271625328801, 100, 5.0000000000000000, 0.0 },
282 { 13.277662844303450, 100, 10.000000000000000, 0.0 },
283 { 91.737038454342454, 100, 15.000000000000000, 0.0 },
284 { 1854.0367283243388, 100, 20.000000000000000, 0.0 },
285 { -11281.698886837261, 100, 25.000000000000000, 0.0 },
286 { 170141.86987046551, 100, 30.000000000000000, 0.0 },
287 { -2950092.7025822806, 100, 35.000000000000000, 0.0 },
288 { -7272442.3156006960, 100, 40.000000000000000, 0.0 },
289 { 295697471.90876162, 100, 45.000000000000000, 0.0 },
290 { 4847420871.2690506, 100, 50.000000000000000, 0.0 },
291 { 59406998102.392288, 100, 55.000000000000000, 0.0 },
292 { 693492765740.29688, 100, 60.000000000000000, 0.0 },
293 { 6606192010150.3154, 100, 65.000000000000000, 0.0 },
294 { 17125518672239.770, 100, 70.000000000000000, 0.0 },
295 { -870493767065150.12, 100, 75.000000000000000, 0.0 },
296 { -13763178176383768., 100, 80.000000000000000, 0.0 },
297 { 30667078414479584., 100, 85.000000000000000, 0.0 },
298 { 2.1307220490380173e+18, 100, 90.000000000000000, 0.0 },
299 { -7.2706523009007821e+18, 100, 95.000000000000000, 0.0 },
300 { -2.6292260693068916e+20, 100, 100.00000000000000, 0.0 },
2be75957
ESR
301};
302const double toler008 = 2.5000000000000020e-13;
303
b4688136 304template<typename Ret, unsigned int Num>
2be75957 305 void
b4688136 306 test(const testcase_laguerre<Ret> (&data)[Num], Ret toler)
2be75957 307 {
b4688136
ESR
308 bool test __attribute__((unused)) = true;
309 const Ret eps = std::numeric_limits<Ret>::epsilon();
310 Ret max_abs_diff = -Ret(1);
311 Ret max_abs_frac = -Ret(1);
2be75957
ESR
312 unsigned int num_datum = Num;
313 for (unsigned int i = 0; i < num_datum; ++i)
314 {
b4688136
ESR
315 const Ret f = std::laguerre(data[i].n, data[i].x);
316 const Ret f0 = data[i].f0;
317 const Ret diff = f - f0;
2be75957
ESR
318 if (std::abs(diff) > max_abs_diff)
319 max_abs_diff = std::abs(diff);
b4688136
ESR
320 if (std::abs(f0) > Ret(10) * eps
321 && std::abs(f) > Ret(10) * eps)
2be75957 322 {
b4688136 323 const Ret frac = diff / f0;
2be75957
ESR
324 if (std::abs(frac) > max_abs_frac)
325 max_abs_frac = std::abs(frac);
326 }
327 }
328 VERIFY(max_abs_frac < toler);
329 }
330
331int
332main()
333{
334 test(data001, toler001);
335 test(data002, toler002);
336 test(data003, toler003);
337 test(data004, toler004);
338 test(data005, toler005);
339 test(data006, toler006);
340 test(data007, toler007);
341 test(data008, toler008);
342 return 0;
343}