1 // { dg-options "-D__STDCPP_WANT_MATH_SPEC_FUNCS__" }
3 // Copyright (C) 2016 Free Software Foundation, Inc.
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)
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.
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/>.
21 // Compare against values generated by the GNU Scientific Library.
22 // The GSL can be found on the web: http://www.gnu.org/software/gsl/
25 #if defined(__TEST_DEBUG)
30 std::cout << "line " << __LINE__ \
31 << " max_abs_frac = " << max_abs_frac \
35 # include <testsuite_hooks.h>
37 #include <specfun_testcase.h>
41 // max(|f - f_GSL|): 0.0000000000000000
42 // max(|f - f_GSL| / |f_GSL|): 0.0000000000000000
43 const testcase_laguerre
<double>
46 { 1.0000000000000000, 0, 0.0000000000000000 },
47 { 1.0000000000000000, 0, 5.0000000000000000 },
48 { 1.0000000000000000, 0, 10.000000000000000 },
49 { 1.0000000000000000, 0, 15.000000000000000 },
50 { 1.0000000000000000, 0, 20.000000000000000 },
51 { 1.0000000000000000, 0, 25.000000000000000 },
52 { 1.0000000000000000, 0, 30.000000000000000 },
53 { 1.0000000000000000, 0, 35.000000000000000 },
54 { 1.0000000000000000, 0, 40.000000000000000 },
55 { 1.0000000000000000, 0, 45.000000000000000 },
56 { 1.0000000000000000, 0, 50.000000000000000 },
57 { 1.0000000000000000, 0, 55.000000000000000 },
58 { 1.0000000000000000, 0, 60.000000000000000 },
59 { 1.0000000000000000, 0, 65.000000000000000 },
60 { 1.0000000000000000, 0, 70.000000000000000 },
61 { 1.0000000000000000, 0, 75.000000000000000 },
62 { 1.0000000000000000, 0, 80.000000000000000 },
63 { 1.0000000000000000, 0, 85.000000000000000 },
64 { 1.0000000000000000, 0, 90.000000000000000 },
65 { 1.0000000000000000, 0, 95.000000000000000 },
66 { 1.0000000000000000, 0, 100.00000000000000 },
68 const double toler001
= 2.5000000000000020e-13;
71 // max(|f - f_GSL|): 0.0000000000000000
72 // max(|f - f_GSL| / |f_GSL|): 0.0000000000000000
73 const testcase_laguerre
<double>
76 { 1.0000000000000000, 1, 0.0000000000000000 },
77 { -4.0000000000000000, 1, 5.0000000000000000 },
78 { -9.0000000000000000, 1, 10.000000000000000 },
79 { -14.000000000000000, 1, 15.000000000000000 },
80 { -19.000000000000000, 1, 20.000000000000000 },
81 { -24.000000000000000, 1, 25.000000000000000 },
82 { -29.000000000000000, 1, 30.000000000000000 },
83 { -34.000000000000000, 1, 35.000000000000000 },
84 { -39.000000000000000, 1, 40.000000000000000 },
85 { -44.000000000000000, 1, 45.000000000000000 },
86 { -49.000000000000000, 1, 50.000000000000000 },
87 { -54.000000000000000, 1, 55.000000000000000 },
88 { -59.000000000000000, 1, 60.000000000000000 },
89 { -64.000000000000000, 1, 65.000000000000000 },
90 { -69.000000000000000, 1, 70.000000000000000 },
91 { -74.000000000000000, 1, 75.000000000000000 },
92 { -79.000000000000000, 1, 80.000000000000000 },
93 { -84.000000000000000, 1, 85.000000000000000 },
94 { -89.000000000000000, 1, 90.000000000000000 },
95 { -94.000000000000000, 1, 95.000000000000000 },
96 { -99.000000000000000, 1, 100.00000000000000 },
98 const double toler002
= 2.5000000000000020e-13;
100 // Test data for n=2.
101 // max(|f - f_GSL|): 0.0000000000000000
102 // max(|f - f_GSL| / |f_GSL|): 0.0000000000000000
103 const testcase_laguerre
<double>
106 { 1.0000000000000000, 2, 0.0000000000000000 },
107 { 3.5000000000000000, 2, 5.0000000000000000 },
108 { 31.000000000000000, 2, 10.000000000000000 },
109 { 83.500000000000000, 2, 15.000000000000000 },
110 { 161.00000000000000, 2, 20.000000000000000 },
111 { 263.50000000000000, 2, 25.000000000000000 },
112 { 391.00000000000000, 2, 30.000000000000000 },
113 { 543.50000000000000, 2, 35.000000000000000 },
114 { 721.00000000000000, 2, 40.000000000000000 },
115 { 923.50000000000000, 2, 45.000000000000000 },
116 { 1151.0000000000000, 2, 50.000000000000000 },
117 { 1403.5000000000000, 2, 55.000000000000000 },
118 { 1681.0000000000000, 2, 60.000000000000000 },
119 { 1983.5000000000000, 2, 65.000000000000000 },
120 { 2311.0000000000000, 2, 70.000000000000000 },
121 { 2663.5000000000000, 2, 75.000000000000000 },
122 { 3041.0000000000000, 2, 80.000000000000000 },
123 { 3443.5000000000000, 2, 85.000000000000000 },
124 { 3871.0000000000000, 2, 90.000000000000000 },
125 { 4323.5000000000000, 2, 95.000000000000000 },
126 { 4801.0000000000000, 2, 100.00000000000000 },
128 const double toler003
= 2.5000000000000020e-13;
130 // Test data for n=5.
131 // max(|f - f_GSL|): 7.4505805969238281e-09
132 // max(|f - f_GSL| / |f_GSL|): 1.9501553136894460e-16
133 const testcase_laguerre
<double>
136 { 1.0000000000000000, 5, 0.0000000000000000 },
137 { -3.1666666666666665, 5, 5.0000000000000000 },
138 { 34.333333333333329, 5, 10.000000000000000 },
139 { -355.25000000000000, 5, 15.000000000000000 },
140 { -4765.6666666666670, 5, 20.000000000000000 },
141 { -23040.666666666664, 5, 25.000000000000000 },
142 { -74399.000000000000, 5, 30.000000000000000 },
143 { -190559.41666666663, 5, 35.000000000000000 },
144 { -418865.66666666663, 5, 40.000000000000000 },
145 { -825411.50000000000, 5, 45.000000000000000 },
146 { -1498165.6666666665, 5, 50.000000000000000 },
147 { -2550096.9166666670, 5, 55.000000000000000 },
148 { -4122299.0000000000, 5, 60.000000000000000 },
149 { -6387115.6666666670, 5, 65.000000000000000 },
150 { -9551265.6666666679, 5, 70.000000000000000 },
151 { -13858967.750000000, 5, 75.000000000000000 },
152 { -19595065.666666664, 5, 80.000000000000000 },
153 { -27088153.166666668, 5, 85.000000000000000 },
154 { -36713699.000000000, 5, 90.000000000000000 },
155 { -48897171.916666657, 5, 95.000000000000000 },
156 { -64117165.666666664, 5, 100.00000000000000 },
158 const double toler004
= 2.5000000000000020e-13;
160 // Test data for n=10.
161 // max(|f - f_GSL|): 0.0029296875000000000
162 // max(|f - f_GSL| / |f_GSL|): 6.1315986390500118e-15
163 const testcase_laguerre
<double>
166 { 1.0000000000000000, 10, 0.0000000000000000 },
167 { 1.7562761794532631, 10, 5.0000000000000000 },
168 { 27.984126984126977, 10, 10.000000000000000 },
169 { -237.51841517857147, 10, 15.000000000000000 },
170 { 3227.8077601410932, 10, 20.000000000000000 },
171 { -45786.199797453693, 10, 25.000000000000000 },
172 { 15129.571428571455, 10, 30.000000000000000 },
173 { 7764800.8179494590, 10, 35.000000000000000 },
174 { 79724066.608465582, 10, 40.000000000000000 },
175 { 469865425.65122765, 10, 45.000000000000000 },
176 { 2037190065.3738980, 10, 50.000000000000000 },
177 { 7187828002.9825764, 10, 55.000000000000000 },
178 { 21804200401.000000, 10, 60.000000000000000 },
179 { 58854343015.616211, 10, 65.000000000000000 },
180 { 144688291819.51855, 10, 70.000000000000000 },
181 { 329425241736.70038, 10, 75.000000000000000 },
182 { 703324772760.08276, 10, 80.000000000000000 },
183 { 1421627560118.6157, 10, 85.000000000000000 },
184 { 2741055412243.8569, 10, 90.000000000000000 },
185 { 5071986977681.8652, 10, 95.000000000000000 },
186 { 9051283795429.5723, 10, 100.00000000000000 },
188 const double toler005
= 5.0000000000000039e-13;
190 // Test data for n=20.
191 // max(|f - f_GSL|): 2048.0000000000000
192 // max(|f - f_GSL| / |f_GSL|): 7.1189246999774008e-15
193 const testcase_laguerre
<double>
196 { 1.0000000000000000, 20, 0.0000000000000000 },
197 { 2.0202257444769134, 20, 5.0000000000000000 },
198 { -11.961333867812119, 20, 10.000000000000000 },
199 { -50.151037960139455, 20, 15.000000000000000 },
200 { 2829.4728613531743, 20, 20.000000000000000 },
201 { -11583.947899113540, 20, 25.000000000000000 },
202 { -18439.424502520938, 20, 30.000000000000000 },
203 { -38838.223606979285, 20, 35.000000000000000 },
204 { 24799805.877530713, 20, 40.000000000000000 },
205 { -673953823.59913278, 20, 45.000000000000000 },
206 { 7551960453.7672548, 20, 50.000000000000000 },
207 { 31286508510.614746, 20, 55.000000000000000 },
208 { -1379223608444.9155, 20, 60.000000000000000 },
209 { -6692517968212.9717, 20, 65.000000000000000 },
210 { 165423821874449.94, 20, 70.000000000000000 },
211 { 3082390018008546.5, 20, 75.000000000000000 },
212 { 29500368536981676., 20, 80.000000000000000 },
213 { 2.0353526354974186e+17, 20, 85.000000000000000 },
214 { 1.1292309514432901e+18, 20, 90.000000000000000 },
215 { 5.3239262855563100e+18, 20, 95.000000000000000 },
216 { 2.2061882785931735e+19, 20, 100.00000000000000 },
218 const double toler006
= 5.0000000000000039e-13;
220 // Test data for n=50.
221 // max(|f - f_GSL|): 196608.00000000000
222 // max(|f - f_GSL| / |f_GSL|): 4.2910775919271532e-15
223 const testcase_laguerre
<double>
226 { 1.0000000000000000, 50, 0.0000000000000000 },
227 { 1.4735258819430543, 50, 5.0000000000000000 },
228 { 17.534183446338233, 50, 10.000000000000000 },
229 { -195.62436619077380, 50, 15.000000000000000 },
230 { 980.26961889791028, 50, 20.000000000000000 },
231 { 24812.277673870878, 50, 25.000000000000000 },
232 { 293000.50735962362, 50, 30.000000000000000 },
233 { 2316195.5013375278, 50, 35.000000000000000 },
234 { -14896937.968694873, 50, 40.000000000000000 },
235 { -502066598.00813466, 50, 45.000000000000000 },
236 { 2513677852.6916871, 50, 50.000000000000000 },
237 { 45129675503.538910, 50, 55.000000000000000 },
238 { -883876565337.99219, 50, 60.000000000000000 },
239 { 9361319947203.8418, 50, 65.000000000000000 },
240 { -80967880733583.234, 50, 70.000000000000000 },
241 { 717391079438942.62, 50, 75.000000000000000 },
242 { -8217471769564841.0, 50, 80.000000000000000 },
243 { 1.2595276229009978e+17, 50, 85.000000000000000 },
244 { -2.1140031308048891e+18, 50, 90.000000000000000 },
245 { 3.2438187475835134e+19, 50, 95.000000000000000 },
246 { -3.9710103487094692e+20, 50, 100.00000000000000 },
248 const double toler007
= 2.5000000000000020e-13;
250 // Test data for n=100.
251 // max(|f - f_GSL|): 98304.000000000000
252 // max(|f - f_GSL| / |f_GSL|): 3.8776197831393928e-15
253 const testcase_laguerre
<double>
256 { 1.0000000000000000, 100, 0.0000000000000000 },
257 { 1.4555271625328801, 100, 5.0000000000000000 },
258 { 13.277662844303450, 100, 10.000000000000000 },
259 { 91.737038454342454, 100, 15.000000000000000 },
260 { 1854.0367283243388, 100, 20.000000000000000 },
261 { -11281.698886837261, 100, 25.000000000000000 },
262 { 170141.86987046551, 100, 30.000000000000000 },
263 { -2950092.7025822806, 100, 35.000000000000000 },
264 { -7272442.3156006960, 100, 40.000000000000000 },
265 { 295697471.90876162, 100, 45.000000000000000 },
266 { 4847420871.2690506, 100, 50.000000000000000 },
267 { 59406998102.392288, 100, 55.000000000000000 },
268 { 693492765740.29688, 100, 60.000000000000000 },
269 { 6606192010150.3154, 100, 65.000000000000000 },
270 { 17125518672239.770, 100, 70.000000000000000 },
271 { -870493767065150.12, 100, 75.000000000000000 },
272 { -13763178176383768., 100, 80.000000000000000 },
273 { 30667078414479584., 100, 85.000000000000000 },
274 { 2.1307220490380173e+18, 100, 90.000000000000000 },
275 { -7.2706523009007821e+18, 100, 95.000000000000000 },
276 { -2.6292260693068916e+20, 100, 100.00000000000000 },
278 const double toler008
= 2.5000000000000020e-13;
280 template<typename Tp
, unsigned int Num
>
282 test(const testcase_laguerre
<Tp
> (&data
)[Num
], Tp toler
)
284 bool test
__attribute__((unused
)) = true;
285 const Tp eps
= std::numeric_limits
<Tp
>::epsilon();
286 Tp max_abs_diff
= -Tp(1);
287 Tp max_abs_frac
= -Tp(1);
288 unsigned int num_datum
= Num
;
289 for (unsigned int i
= 0; i
< num_datum
; ++i
)
291 const Tp f
= std::laguerre(data
[i
].n
, data
[i
].x
);
292 const Tp f0
= data
[i
].f0
;
293 const Tp diff
= f
- f0
;
294 if (std::abs(diff
) > max_abs_diff
)
295 max_abs_diff
= std::abs(diff
);
296 if (std::abs(f0
) > Tp(10) * eps
297 && std::abs(f
) > Tp(10) * eps
)
299 const Tp frac
= diff
/ f0
;
300 if (std::abs(frac
) > max_abs_frac
)
301 max_abs_frac
= std::abs(frac
);
304 VERIFY(max_abs_frac
< toler
);
310 test(data001
, toler001
);
311 test(data002
, toler002
);
312 test(data003
, toler003
);
313 test(data004
, toler004
);
314 test(data005
, toler005
);
315 test(data006
, toler006
);
316 test(data007
, toler007
);
317 test(data008
, toler008
);