2016-01-14 Edward Smith-Rowland <3dw4rd@verizon.net>
[official-gcc.git] / libstdc++-v3 / testsuite / special_functions / 09_cyl_bessel_k / check_value.cc
blob2bd1fa2799326920295b3c0f74cf671d2ccea85f
1 // { dg-options "-D__STDCPP_WANT_MATH_SPEC_FUNCS__" }
2 //
3 // Copyright (C) 2016 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.
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/>.
20 // cyl_bessel_k
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/
23 #include <limits>
24 #include <cmath>
25 #if defined(__TEST_DEBUG)
26 # include <iostream>
27 # define VERIFY(A) \
28 if (!(A)) \
29 { \
30 std::cout << "line " << __LINE__ \
31 << " max_abs_frac = " << max_abs_frac \
32 << std::endl; \
34 #else
35 # include <testsuite_hooks.h>
36 #endif
37 #include <specfun_testcase.h>
40 // Test data for nu=0.0000000000000000.
41 // max(|f - f_GSL|): 2.2204460492503131e-16
42 // max(|f - f_GSL| / |f_GSL|): 1.7863051312335036e-16
43 const testcase_cyl_bessel_k<double>
44 data001[20] =
46 { 1.5415067512483025, 0.0000000000000000, 0.25000000000000000 },
47 { 0.92441907122766565, 0.0000000000000000, 0.50000000000000000 },
48 { 0.61058242211646430, 0.0000000000000000, 0.75000000000000000 },
49 { 0.42102443824070829, 0.0000000000000000, 1.0000000000000000 },
50 { 0.29760308908410588, 0.0000000000000000, 1.2500000000000000 },
51 { 0.21380556264752565, 0.0000000000000000, 1.5000000000000000 },
52 { 0.15537981238660362, 0.0000000000000000, 1.7500000000000000 },
53 { 0.11389387274953360, 0.0000000000000000, 2.0000000000000000 },
54 { 0.084043111974658191, 0.0000000000000000, 2.2500000000000000 },
55 { 0.062347553200366168, 0.0000000000000000, 2.5000000000000000 },
56 { 0.046454901308760774, 0.0000000000000000, 2.7500000000000000 },
57 { 0.034739504386279256, 0.0000000000000000, 3.0000000000000000 },
58 { 0.026058755255154966, 0.0000000000000000, 3.2500000000000000 },
59 { 0.019598897170368501, 0.0000000000000000, 3.5000000000000000 },
60 { 0.014774250877128706, 0.0000000000000000, 3.7500000000000000 },
61 { 0.011159676085853026, 0.0000000000000000, 4.0000000000000000 },
62 { 0.0084443877245429649, 0.0000000000000000, 4.2500000000000000 },
63 { 0.0063998572432339747, 0.0000000000000000, 4.5000000000000000 },
64 { 0.0048572045578879524, 0.0000000000000000, 4.7500000000000000 },
65 { 0.0036910983340425947, 0.0000000000000000, 5.0000000000000000 },
67 const double toler001 = 2.5000000000000020e-13;
69 // Test data for nu=0.33333333333333331.
70 // max(|f - f_GSL|): 1.3322676295501878e-15
71 // max(|f - f_GSL| / |f_GSL|): 4.3522010494015439e-15
72 const testcase_cyl_bessel_k<double>
73 data002[20] =
75 { 1.7144912564234518, 0.33333333333333331, 0.25000000000000000 },
76 { 0.98903107424672421, 0.33333333333333331, 0.50000000000000000 },
77 { 0.64216899667282989, 0.33333333333333331, 0.75000000000000000 },
78 { 0.43843063344153432, 0.33333333333333331, 1.0000000000000000 },
79 { 0.30788192414945043, 0.33333333333333331, 1.2500000000000000 },
80 { 0.22015769026776688, 0.33333333333333331, 1.5000000000000000 },
81 { 0.15943413057311245, 0.33333333333333331, 1.7500000000000000 },
82 { 0.11654496129616534, 0.33333333333333331, 2.0000000000000000 },
83 { 0.085809609306439674, 0.33333333333333331, 2.2500000000000000 },
84 { 0.063542537454733386, 0.33333333333333331, 2.5000000000000000 },
85 { 0.047273354184795509, 0.33333333333333331, 2.7500000000000000 },
86 { 0.035305904902162587, 0.33333333333333331, 3.0000000000000000 },
87 { 0.026454186892773169, 0.33333333333333331, 3.2500000000000000 },
88 { 0.019877061407943805, 0.33333333333333331, 3.5000000000000000 },
89 { 0.014971213514760214, 0.33333333333333331, 3.7500000000000000 },
90 { 0.011299947573672165, 0.33333333333333331, 4.0000000000000000 },
91 { 0.0085447959546110473, 0.33333333333333331, 4.2500000000000000 },
92 { 0.0064720581217078237, 0.33333333333333331, 4.5000000000000000 },
93 { 0.0049093342803275264, 0.33333333333333331, 4.7500000000000000 },
94 { 0.0037288750960535887, 0.33333333333333331, 5.0000000000000000 },
96 const double toler002 = 2.5000000000000020e-13;
98 // Test data for nu=0.50000000000000000.
99 // max(|f - f_GSL|): 1.3322676295501878e-15
100 // max(|f - f_GSL| / |f_GSL|): 1.5172850443872369e-15
101 const testcase_cyl_bessel_k<double>
102 data003[20] =
104 { 1.9521640631515476, 0.50000000000000000, 0.25000000000000000 },
105 { 1.0750476034999195, 0.50000000000000000, 0.50000000000000000 },
106 { 0.68361006034952421, 0.50000000000000000, 0.75000000000000000 },
107 { 0.46106850444789454, 0.50000000000000000, 1.0000000000000000 },
108 { 0.32117137397144746, 0.50000000000000000, 1.2500000000000000 },
109 { 0.22833505222826550, 0.50000000000000000, 1.5000000000000000 },
110 { 0.16463628997380864, 0.50000000000000000, 1.7500000000000000 },
111 { 0.11993777196806145, 0.50000000000000000, 2.0000000000000000 },
112 { 0.088065558803650454, 0.50000000000000000, 2.2500000000000000 },
113 { 0.065065943154009986, 0.50000000000000000, 2.5000000000000000 },
114 { 0.048315198301417825, 0.50000000000000000, 2.7500000000000000 },
115 { 0.036025985131764589, 0.50000000000000000, 3.0000000000000000 },
116 { 0.026956356532443351, 0.50000000000000000, 3.2500000000000000 },
117 { 0.020229969578139294, 0.50000000000000000, 3.5000000000000000 },
118 { 0.015220888252975564, 0.50000000000000000, 3.7500000000000000 },
119 { 0.011477624576608052, 0.50000000000000000, 4.0000000000000000 },
120 { 0.0086718932956978342, 0.50000000000000000, 4.2500000000000000 },
121 { 0.0065633945646345407, 0.50000000000000000, 4.5000000000000000 },
122 { 0.0049752435421262292, 0.50000000000000000, 4.7500000000000000 },
123 { 0.0037766133746428825, 0.50000000000000000, 5.0000000000000000 },
125 const double toler003 = 2.5000000000000020e-13;
127 // Test data for nu=0.66666666666666663.
128 // max(|f - f_GSL|): 4.4408920985006262e-16
129 // max(|f - f_GSL| / |f_GSL|): 8.1483075013172610e-16
130 const testcase_cyl_bessel_k<double>
131 data004[20] =
133 { 2.3289060745544101, 0.66666666666666663, 0.25000000000000000 },
134 { 1.2059304647203353, 0.66666666666666663, 0.50000000000000000 },
135 { 0.74547232976647215, 0.66666666666666663, 0.75000000000000000 },
136 { 0.49447506210420827, 0.66666666666666663, 1.0000000000000000 },
137 { 0.34062994813514252, 0.66666666666666663, 1.2500000000000000 },
138 { 0.24024045240315581, 0.66666666666666663, 1.5000000000000000 },
139 { 0.17217716908452310, 0.66666666666666663, 1.7500000000000000 },
140 { 0.12483892748812841, 0.66666666666666663, 2.0000000000000000 },
141 { 0.091315296079621050, 0.66666666666666663, 2.2500000000000000 },
142 { 0.067255322171623361, 0.66666666666666663, 2.5000000000000000 },
143 { 0.049809546542402224, 0.66666666666666663, 2.7500000000000000 },
144 { 0.037057074495188531, 0.66666666666666663, 3.0000000000000000 },
145 { 0.027674365504886729, 0.66666666666666663, 3.2500000000000000 },
146 { 0.020733915836010912, 0.66666666666666663, 3.5000000000000000 },
147 { 0.015577015510251332, 0.66666666666666663, 3.7500000000000000 },
148 { 0.011730801456525336, 0.66666666666666663, 4.0000000000000000 },
149 { 0.0088528343204658851, 0.66666666666666663, 4.2500000000000000 },
150 { 0.0066933190915775560, 0.66666666666666663, 4.5000000000000000 },
151 { 0.0050689292106255480, 0.66666666666666663, 4.7500000000000000 },
152 { 0.0038444246344968226, 0.66666666666666663, 5.0000000000000000 },
154 const double toler004 = 2.5000000000000020e-13;
156 // Test data for nu=1.0000000000000000.
157 // max(|f - f_GSL|): 5.5511151231257827e-17
158 // max(|f - f_GSL| / |f_GSL|): 2.7422040631145076e-16
159 const testcase_cyl_bessel_k<double>
160 data005[20] =
162 { 3.7470259744407115, 1.0000000000000000, 0.25000000000000000 },
163 { 1.6564411200033007, 1.0000000000000000, 0.50000000000000000 },
164 { 0.94958046696214016, 1.0000000000000000, 0.75000000000000000 },
165 { 0.60190723019723458, 1.0000000000000000, 1.0000000000000000 },
166 { 0.40212407978419540, 1.0000000000000000, 1.2500000000000000 },
167 { 0.27738780045684375, 1.0000000000000000, 1.5000000000000000 },
168 { 0.19547745347439310, 1.0000000000000000, 1.7500000000000000 },
169 { 0.13986588181652262, 1.0000000000000000, 2.0000000000000000 },
170 { 0.10121630256832535, 1.0000000000000000, 2.2500000000000000 },
171 { 0.073890816347747038, 1.0000000000000000, 2.5000000000000000 },
172 { 0.054318522758919859, 1.0000000000000000, 2.7500000000000000 },
173 { 0.040156431128194198, 1.0000000000000000, 3.0000000000000000 },
174 { 0.029825529796040143, 1.0000000000000000, 3.2500000000000000 },
175 { 0.022239392925923845, 1.0000000000000000, 3.5000000000000000 },
176 { 0.016638191754688912, 1.0000000000000000, 3.7500000000000000 },
177 { 0.012483498887268435, 1.0000000000000000, 4.0000000000000000 },
178 { 0.0093896806560432589, 1.0000000000000000, 4.2500000000000000 },
179 { 0.0070780949089680901, 1.0000000000000000, 4.5000000000000000 },
180 { 0.0053459218178228390, 1.0000000000000000, 4.7500000000000000 },
181 { 0.0040446134454521655, 1.0000000000000000, 5.0000000000000000 },
183 const double toler005 = 2.5000000000000020e-13;
185 // Test data for nu=2.0000000000000000.
186 // max(|f - f_GSL|): 3.5527136788005009e-15
187 // max(|f - f_GSL| / |f_GSL|): 1.9937716861613039e-16
188 const testcase_cyl_bessel_k<double>
189 data006[20] =
191 { 31.517714546773998, 2.0000000000000000, 0.25000000000000000 },
192 { 7.5501835512408695, 2.0000000000000000, 0.50000000000000000 },
193 { 3.1427970006821715, 2.0000000000000000, 0.75000000000000000 },
194 { 1.6248388986351774, 2.0000000000000000, 1.0000000000000000 },
195 { 0.94100161673881855, 2.0000000000000000, 1.2500000000000000 },
196 { 0.58365596325665070, 2.0000000000000000, 1.5000000000000000 },
197 { 0.37878261635733856, 2.0000000000000000, 1.7500000000000000 },
198 { 0.25375975456605621, 2.0000000000000000, 2.0000000000000000 },
199 { 0.17401315870205850, 2.0000000000000000, 2.2500000000000000 },
200 { 0.12146020627856381, 2.0000000000000000, 2.5000000000000000 },
201 { 0.085959281497066137, 2.0000000000000000, 2.7500000000000000 },
202 { 0.061510458471742059, 2.0000000000000000, 3.0000000000000000 },
203 { 0.044412927437333515, 2.0000000000000000, 3.2500000000000000 },
204 { 0.032307121699467839, 2.0000000000000000, 3.5000000000000000 },
205 { 0.023647953146296127, 2.0000000000000000, 3.7500000000000000 },
206 { 0.017401425529487244, 2.0000000000000000, 4.0000000000000000 },
207 { 0.012863060974445674, 2.0000000000000000, 4.2500000000000000 },
208 { 0.0095456772027753475, 2.0000000000000000, 4.5000000000000000 },
209 { 0.0071081190074975690, 2.0000000000000000, 4.7500000000000000 },
210 { 0.0053089437122234608, 2.0000000000000000, 5.0000000000000000 },
212 const double toler006 = 2.5000000000000020e-13;
214 // Test data for nu=5.0000000000000000.
215 // max(|f - f_GSL|): 5.8207660913467407e-11
216 // max(|f - f_GSL| / |f_GSL|): 2.4867363835720159e-16
217 const testcase_cyl_bessel_k<double>
218 data007[20] =
220 { 391683.98962334893, 5.0000000000000000, 0.25000000000000000 },
221 { 12097.979476096394, 5.0000000000000000, 0.50000000000000000 },
222 { 1562.5870339691098, 5.0000000000000000, 0.75000000000000000 },
223 { 360.96058960124066, 5.0000000000000000, 1.0000000000000000 },
224 { 114.29321426334016, 5.0000000000000000, 1.2500000000000000 },
225 { 44.067781159301056, 5.0000000000000000, 1.5000000000000000 },
226 { 19.426568687730292, 5.0000000000000000, 1.7500000000000000 },
227 { 9.4310491005964820, 5.0000000000000000, 2.0000000000000000 },
228 { 4.9221270549918685, 5.0000000000000000, 2.2500000000000000 },
229 { 2.7168842907865423, 5.0000000000000000, 2.5000000000000000 },
230 { 1.5677685890536335, 5.0000000000000000, 2.7500000000000000 },
231 { 0.93777360238680818, 5.0000000000000000, 3.0000000000000000 },
232 { 0.57775534736785106, 5.0000000000000000, 3.2500000000000000 },
233 { 0.36482440208451983, 5.0000000000000000, 3.5000000000000000 },
234 { 0.23520290620082257, 5.0000000000000000, 3.7500000000000000 },
235 { 0.15434254872599723, 5.0000000000000000, 4.0000000000000000 },
236 { 0.10283347176876455, 5.0000000000000000, 4.2500000000000000 },
237 { 0.069423643150881773, 5.0000000000000000, 4.5000000000000000 },
238 { 0.047410616917942211, 5.0000000000000000, 4.7500000000000000 },
239 { 0.032706273712031865, 5.0000000000000000, 5.0000000000000000 },
241 const double toler007 = 2.5000000000000020e-13;
243 // Test data for nu=10.000000000000000.
244 // max(|f - f_GSL|): 6.1035156250000000e-05
245 // max(|f - f_GSL| / |f_GSL|): 7.7998476565326393e-16
246 const testcase_cyl_bessel_k<double>
247 data008[20] =
249 { 194481817927839.88, 10.000000000000000, 0.25000000000000000 },
250 { 188937569319.90030, 10.000000000000000, 0.50000000000000000 },
251 { 3248187687.8018155, 10.000000000000000, 0.75000000000000000 },
252 { 180713289.90102941, 10.000000000000000, 1.0000000000000000 },
253 { 19104425.945252180, 10.000000000000000, 1.2500000000000000 },
254 { 3027483.5236822353, 10.000000000000000, 1.5000000000000000 },
255 { 633724.71555087867, 10.000000000000000, 1.7500000000000000 },
256 { 162482.40397955943, 10.000000000000000, 2.0000000000000000 },
257 { 48602.446087749791, 10.000000000000000, 2.2500000000000000 },
258 { 16406.916416341937, 10.000000000000000, 2.5000000000000000 },
259 { 6104.1720745909606, 10.000000000000000, 2.7500000000000000 },
260 { 2459.6204220569480, 10.000000000000000, 3.0000000000000000 },
261 { 1059.2358443703381, 10.000000000000000, 3.2500000000000000 },
262 { 482.53582096664758, 10.000000000000000, 3.5000000000000000 },
263 { 230.64249314993776, 10.000000000000000, 3.7500000000000000 },
264 { 114.91408364049620, 10.000000000000000, 4.0000000000000000 },
265 { 59.361613632706479, 10.000000000000000, 4.2500000000000000 },
266 { 31.652958759229868, 10.000000000000000, 4.5000000000000000 },
267 { 17.357723966417399, 10.000000000000000, 4.7500000000000000 },
268 { 9.7585628291778121, 10.000000000000000, 5.0000000000000000 },
270 const double toler008 = 2.5000000000000020e-13;
272 // Test data for nu=20.000000000000000.
273 // max(|f - f_GSL|): 2.7670116110564327e+19
274 // max(|f - f_GSL| / |f_GSL|): 1.2737005853777639e-15
275 const testcase_cyl_bessel_k<double>
276 data009[20] =
278 { 7.0065983661641184e+34, 20.000000000000000, 0.25000000000000000 },
279 { 6.6655498744171593e+28, 20.000000000000000, 0.50000000000000000 },
280 { 1.9962989615380379e+25, 20.000000000000000, 0.75000000000000000 },
281 { 6.2943693604245335e+22, 20.000000000000000, 1.0000000000000000 },
282 { 7.2034511920074182e+20, 20.000000000000000, 1.2500000000000000 },
283 { 1.8620549984645546e+19, 20.000000000000000, 1.5000000000000000 },
284 { 8.4415605303952486e+17, 20.000000000000000, 1.7500000000000000 },
285 { 57708568527002520., 20.000000000000000, 2.0000000000000000 },
286 { 5396824209986879.0, 20.000000000000000, 2.2500000000000000 },
287 { 645996884063683.62, 20.000000000000000, 2.5000000000000000 },
288 { 94387401970996.328, 20.000000000000000, 2.7500000000000000 },
289 { 16254643952204.371, 20.000000000000000, 3.0000000000000000 },
290 { 3212694836166.4053, 20.000000000000000, 3.2500000000000000 },
291 { 713857897923.74072, 20.000000000000000, 3.5000000000000000 },
292 { 175423421958.35925, 20.000000000000000, 3.7500000000000000 },
293 { 47050078926.298080, 20.000000000000000, 4.0000000000000000 },
294 { 13625066095.067503, 20.000000000000000, 4.2500000000000000 },
295 { 4222179870.6810656, 20.000000000000000, 4.5000000000000000 },
296 { 1389634112.7516634, 20.000000000000000, 4.7500000000000000 },
297 { 482700052.06214869, 20.000000000000000, 5.0000000000000000 },
299 const double toler009 = 2.5000000000000020e-13;
301 // Test data for nu=50.000000000000000.
302 // max(|f - f_GSL|): 3.9111090745622133e+92
303 // max(|f - f_GSL| / |f_GSL|): 3.7220730535457535e-15
304 const testcase_cyl_bessel_k<double>
305 data010[20] =
307 { 4.3394604622138714e+107, 50.000000000000000, 0.25000000000000000 },
308 { 3.8505298918269003e+92, 50.000000000000000, 0.50000000000000000 },
309 { 6.0292756894842793e+83, 50.000000000000000, 0.75000000000000000 },
310 { 3.4068968541616991e+77, 50.000000000000000, 1.0000000000000000 },
311 { 4.8485527365039051e+72, 50.000000000000000, 1.2500000000000000 },
312 { 5.3091717574907920e+68, 50.000000000000000, 1.5000000000000000 },
313 { 2.3762245257445824e+65, 50.000000000000000, 1.7500000000000000 },
314 { 2.9799817396049268e+62, 50.000000000000000, 2.0000000000000000 },
315 { 8.2079431233488581e+59, 50.000000000000000, 2.2500000000000000 },
316 { 4.2046528212987503e+57, 50.000000000000000, 2.5000000000000000 },
317 { 3.5578676911884825e+55, 50.000000000000000, 2.7500000000000000 },
318 { 4.5559542293221535e+53, 50.000000000000000, 3.0000000000000000 },
319 { 8.2606735967628997e+51, 50.000000000000000, 3.2500000000000000 },
320 { 2.0139406747903812e+50, 50.000000000000000, 3.5000000000000000 },
321 { 6.3368727837484600e+48, 50.000000000000000, 3.7500000000000000 },
322 { 2.4897317389325753e+47, 50.000000000000000, 4.0000000000000000 },
323 { 1.1888958173039699e+46, 50.000000000000000, 4.2500000000000000 },
324 { 6.7472593648148542e+44, 50.000000000000000, 4.5000000000000000 },
325 { 4.4664266585930700e+43, 50.000000000000000, 4.7500000000000000 },
326 { 3.3943222434301628e+42, 50.000000000000000, 5.0000000000000000 },
328 const double toler010 = 2.5000000000000020e-13;
330 // Test data for nu=100.00000000000000.
331 // max(|f - f_GSL|): 8.5970689361151757e+232
332 // max(|f - f_GSL| / |f_GSL|): 9.0457919481999128e-14
333 const testcase_cyl_bessel_k<double>
334 data011[20] =
336 { 9.5039428115809898e+245, 100.00000000000000, 0.25000000000000000 },
337 { 7.4937399313533112e+215, 100.00000000000000, 0.50000000000000000 },
338 { 1.8417471020730701e+198, 100.00000000000000, 0.75000000000000000 },
339 { 5.9003331836386410e+185, 100.00000000000000, 1.0000000000000000 },
340 { 1.2002130935576950e+176, 100.00000000000000, 1.2500000000000000 },
341 { 1.4467044226487075e+168, 100.00000000000000, 1.5000000000000000 },
342 { 2.9161498411497642e+161, 100.00000000000000, 1.7500000000000000 },
343 { 4.6194159776013925e+155, 100.00000000000000, 2.0000000000000000 },
344 { 3.5332121583541727e+150, 100.00000000000000, 2.2500000000000000 },
345 { 9.3566097231039940e+145, 100.00000000000000, 2.5000000000000000 },
346 { 6.7672283615134532e+141, 100.00000000000000, 2.7500000000000000 },
347 { 1.1219630864949494e+138, 100.00000000000000, 3.0000000000000000 },
348 { 3.7329723699990903e+134, 100.00000000000000, 3.2500000000000000 },
349 { 2.2476893883855163e+131, 100.00000000000000, 3.5000000000000000 },
350 { 2.2564559319883196e+128, 100.00000000000000, 3.7500000000000000 },
351 { 3.5353340499626455e+125, 100.00000000000000, 4.0000000000000000 },
352 { 8.1898439213010234e+122, 100.00000000000000, 4.2500000000000000 },
353 { 2.6823744110726800e+120, 100.00000000000000, 4.5000000000000000 },
354 { 1.1963963615212274e+118, 100.00000000000000, 4.7500000000000000 },
355 { 7.0398601930616815e+115, 100.00000000000000, 5.0000000000000000 },
357 const double toler011 = 5.0000000000000029e-12;
358 // cyl_bessel_k
360 // Test data for nu=0.0000000000000000.
361 // max(|f - f_GSL|): 4.3368086899420177e-19
362 // max(|f - f_GSL| / |f_GSL|): 1.8009631353873430e-16
363 const testcase_cyl_bessel_k<double>
364 data012[20] =
366 { 0.0036910983340425947, 0.0000000000000000, 5.0000000000000000 },
367 { 1.7780062316167650e-05, 0.0000000000000000, 10.000000000000000 },
368 { 9.8195364823964333e-08, 0.0000000000000000, 15.000000000000000 },
369 { 5.7412378153365238e-10, 0.0000000000000000, 20.000000000000000 },
370 { 3.4641615622131151e-12, 0.0000000000000000, 25.000000000000000 },
371 { 2.1324774964630566e-14, 0.0000000000000000, 30.000000000000000 },
372 { 1.3310351491429464e-16, 0.0000000000000000, 35.000000000000000 },
373 { 8.3928611000995700e-19, 0.0000000000000000, 40.000000000000000 },
374 { 5.3334561226187247e-21, 0.0000000000000000, 45.000000000000000 },
375 { 3.4101677497894956e-23, 0.0000000000000000, 50.000000000000000 },
376 { 2.1913102183534147e-25, 0.0000000000000000, 55.000000000000000 },
377 { 1.4138978405591074e-27, 0.0000000000000000, 60.000000000000000 },
378 { 9.1544673210030045e-30, 0.0000000000000000, 65.000000000000000 },
379 { 5.9446613372925013e-32, 0.0000000000000000, 70.000000000000000 },
380 { 3.8701170455869113e-34, 0.0000000000000000, 75.000000000000000 },
381 { 2.5251198425054723e-36, 0.0000000000000000, 80.000000000000000 },
382 { 1.6507623579783908e-38, 0.0000000000000000, 85.000000000000000 },
383 { 1.0810242556984256e-40, 0.0000000000000000, 90.000000000000000 },
384 { 7.0901249699001278e-43, 0.0000000000000000, 95.000000000000000 },
385 { 4.6566282291759032e-45, 0.0000000000000000, 100.00000000000000 },
387 const double toler012 = 2.5000000000000020e-13;
389 // Test data for nu=0.33333333333333331.
390 // max(|f - f_GSL|): 1.0339757656912846e-25
391 // max(|f - f_GSL| / |f_GSL|): 1.7960859646361972e-16
392 const testcase_cyl_bessel_k<double>
393 data013[20] =
395 { 0.0037288750960535887, 0.33333333333333331, 5.0000000000000000 },
396 { 1.7874608271055339e-05, 0.33333333333333331, 10.000000000000000 },
397 { 9.8548341568798317e-08, 0.33333333333333331, 15.000000000000000 },
398 { 5.7568278247790865e-10, 0.33333333333333331, 20.000000000000000 },
399 { 3.4717201424907059e-12, 0.33333333333333331, 25.000000000000000 },
400 { 2.1363664736611189e-14, 0.33333333333333331, 30.000000000000000 },
401 { 1.3331202314165813e-16, 0.33333333333333331, 35.000000000000000 },
402 { 8.4043837769480934e-19, 0.33333333333333331, 40.000000000000000 },
403 { 5.3399731261024948e-21, 0.33333333333333331, 45.000000000000000 },
404 { 3.4139217813583632e-23, 0.33333333333333331, 50.000000000000000 },
405 { 2.1935050179185627e-25, 0.33333333333333331, 55.000000000000000 },
406 { 1.4151968805623662e-27, 0.33333333333333331, 60.000000000000000 },
407 { 9.1622357217019043e-30, 0.33333333333333331, 65.000000000000000 },
408 { 5.9493479703461315e-32, 0.33333333333333331, 70.000000000000000 },
409 { 3.8729660011055947e-34, 0.33333333333333331, 75.000000000000000 },
410 { 2.5268631828013877e-36, 0.33333333333333331, 80.000000000000000 },
411 { 1.6518353676138867e-38, 0.33333333333333331, 85.000000000000000 },
412 { 1.0816880942511494e-40, 0.33333333333333331, 90.000000000000000 },
413 { 7.0942508599231512e-43, 0.33333333333333331, 95.000000000000000 },
414 { 4.6592031570213454e-45, 0.33333333333333331, 100.00000000000000 },
416 const double toler013 = 2.5000000000000020e-13;
418 // Test data for nu=0.50000000000000000.
419 // max(|f - f_GSL|): 1.5046327690525280e-36
420 // max(|f - f_GSL| / |f_GSL|): 0.0000000000000000
421 const testcase_cyl_bessel_k<double>
422 data014[20] =
424 { 0.0037766133746428825, 0.50000000000000000, 5.0000000000000000 },
425 { 1.7993478093705181e-05, 0.50000000000000000, 10.000000000000000 },
426 { 9.8991312032877236e-08, 0.50000000000000000, 15.000000000000000 },
427 { 5.7763739747074450e-10, 0.50000000000000000, 20.000000000000000 },
428 { 3.4811912768406949e-12, 0.50000000000000000, 25.000000000000000 },
429 { 2.1412375659560111e-14, 0.50000000000000000, 30.000000000000000 },
430 { 1.3357311366035824e-16, 0.50000000000000000, 35.000000000000000 },
431 { 8.4188091949489049e-19, 0.50000000000000000, 40.000000000000000 },
432 { 5.3481305002517408e-21, 0.50000000000000000, 45.000000000000000 },
433 { 3.4186200954570754e-23, 0.50000000000000000, 50.000000000000000 },
434 { 2.1962515908772453e-25, 0.50000000000000000, 55.000000000000000 },
435 { 1.4168223500353693e-27, 0.50000000000000000, 60.000000000000000 },
436 { 9.1719554473256892e-30, 0.50000000000000000, 65.000000000000000 },
437 { 5.9552114337788932e-32, 0.50000000000000000, 70.000000000000000 },
438 { 3.8765301321409432e-34, 0.50000000000000000, 75.000000000000000 },
439 { 2.5290440439442910e-36, 0.50000000000000000, 80.000000000000000 },
440 { 1.6531776067605980e-38, 0.50000000000000000, 85.000000000000000 },
441 { 1.0825184636529955e-40, 0.50000000000000000, 90.000000000000000 },
442 { 7.0994115873258822e-43, 0.50000000000000000, 95.000000000000000 },
443 { 4.6624238126346715e-45, 0.50000000000000000, 100.00000000000000 },
445 const double toler014 = 2.5000000000000020e-13;
447 // Test data for nu=0.66666666666666663.
448 // max(|f - f_GSL|): 4.3368086899420177e-19
449 // max(|f - f_GSL| / |f_GSL|): 3.5630695000470094e-16
450 const testcase_cyl_bessel_k<double>
451 data015[20] =
453 { 0.0038444246344968226, 0.66666666666666663, 5.0000000000000000 },
454 { 1.8161187569530204e-05, 0.66666666666666663, 10.000000000000000 },
455 { 9.9614751542305571e-08, 0.66666666666666663, 15.000000000000000 },
456 { 5.8038484271925811e-10, 0.66666666666666663, 20.000000000000000 },
457 { 3.4944937498488603e-12, 0.66666666666666663, 25.000000000000000 },
458 { 2.1480755645577720e-14, 0.66666666666666663, 30.000000000000000 },
459 { 1.3393949190152161e-16, 0.66666666666666663, 35.000000000000000 },
460 { 8.4390460553642992e-19, 0.66666666666666663, 40.000000000000000 },
461 { 5.3595716143622089e-21, 0.66666666666666663, 45.000000000000000 },
462 { 3.4252085301433749e-23, 0.66666666666666663, 50.000000000000000 },
463 { 2.2001025377982308e-25, 0.66666666666666663, 55.000000000000000 },
464 { 1.4191011274172078e-27, 0.66666666666666663, 60.000000000000000 },
465 { 9.1855803020269763e-30, 0.66666666666666663, 65.000000000000000 },
466 { 5.9634299472578764e-32, 0.66666666666666663, 70.000000000000000 },
467 { 3.8815254026478500e-34, 0.66666666666666663, 75.000000000000000 },
468 { 2.5321003991943851e-36, 0.66666666666666663, 80.000000000000000 },
469 { 1.6550585670593067e-38, 0.66666666666666663, 85.000000000000000 },
470 { 1.0836820479428605e-40, 0.66666666666666663, 90.000000000000000 },
471 { 7.1066428916285356e-43, 0.66666666666666663, 95.000000000000000 },
472 { 4.6669364587280465e-45, 0.66666666666666663, 100.00000000000000 },
474 const double toler015 = 2.5000000000000020e-13;
476 // Test data for nu=1.0000000000000000.
477 // max(|f - f_GSL|): 1.0339757656912846e-25
478 // max(|f - f_GSL| / |f_GSL|): 2.9112857291682056e-16
479 const testcase_cyl_bessel_k<double>
480 data016[20] =
482 { 0.0040446134454521655, 1.0000000000000000, 5.0000000000000000 },
483 { 1.8648773453825582e-05, 1.0000000000000000, 10.000000000000000 },
484 { 1.0141729369762091e-07, 1.0000000000000000, 15.000000000000000 },
485 { 5.8830579695570384e-10, 1.0000000000000000, 20.000000000000000 },
486 { 3.5327780731999345e-12, 1.0000000000000000, 25.000000000000000 },
487 { 2.1677320018915498e-14, 1.0000000000000000, 30.000000000000000 },
488 { 1.3499178340011053e-16, 1.0000000000000000, 35.000000000000000 },
489 { 8.4971319548610435e-19, 1.0000000000000000, 40.000000000000000 },
490 { 5.3923945937225035e-21, 1.0000000000000000, 45.000000000000000 },
491 { 3.4441022267175555e-23, 1.0000000000000000, 50.000000000000000 },
492 { 2.2111422716117463e-25, 1.0000000000000000, 55.000000000000000 },
493 { 1.4256320265171041e-27, 1.0000000000000000, 60.000000000000000 },
494 { 9.2246195278906156e-30, 1.0000000000000000, 65.000000000000000 },
495 { 5.9869736739138550e-32, 1.0000000000000000, 70.000000000000000 },
496 { 3.8958329467421912e-34, 1.0000000000000000, 75.000000000000000 },
497 { 2.5408531275211708e-36, 1.0000000000000000, 80.000000000000000 },
498 { 1.6604444948567571e-38, 1.0000000000000000, 85.000000000000000 },
499 { 1.0870134457498335e-40, 1.0000000000000000, 90.000000000000000 },
500 { 7.1273442329907240e-43, 1.0000000000000000, 95.000000000000000 },
501 { 4.6798537356369101e-45, 1.0000000000000000, 100.00000000000000 },
503 const double toler016 = 2.5000000000000020e-13;
505 // Test data for nu=2.0000000000000000.
506 // max(|f - f_GSL|): 8.6736173798840355e-19
507 // max(|f - f_GSL| / |f_GSL|): 1.6337745981208381e-16
508 const testcase_cyl_bessel_k<double>
509 data017[20] =
511 { 0.0053089437122234608, 2.0000000000000000, 5.0000000000000000 },
512 { 2.1509817006932767e-05, 2.0000000000000000, 10.000000000000000 },
513 { 1.1171767065031378e-07, 2.0000000000000000, 15.000000000000000 },
514 { 6.3295436122922281e-10, 2.0000000000000000, 20.000000000000000 },
515 { 3.7467838080691102e-12, 2.0000000000000000, 25.000000000000000 },
516 { 2.2769929632558265e-14, 2.0000000000000000, 30.000000000000000 },
517 { 1.4081733110858665e-16, 2.0000000000000000, 35.000000000000000 },
518 { 8.8177176978426223e-19, 2.0000000000000000, 40.000000000000000 },
519 { 5.5731181045619470e-21, 2.0000000000000000, 45.000000000000000 },
520 { 3.5479318388581979e-23, 2.0000000000000000, 50.000000000000000 },
521 { 2.2717153918665688e-25, 2.0000000000000000, 55.000000000000000 },
522 { 1.4614189081096777e-27, 2.0000000000000000, 60.000000000000000 },
523 { 9.4383017680150234e-30, 2.0000000000000000, 65.000000000000000 },
524 { 6.1157177279757537e-32, 2.0000000000000000, 70.000000000000000 },
525 { 3.9740059241667034e-34, 2.0000000000000000, 75.000000000000000 },
526 { 2.5886411706935015e-36, 2.0000000000000000, 80.000000000000000 },
527 { 1.6898316402103142e-38, 2.0000000000000000, 85.000000000000000 },
528 { 1.1051801100484218e-40, 2.0000000000000000, 90.000000000000000 },
529 { 7.2401743221736176e-43, 2.0000000000000000, 95.000000000000000 },
530 { 4.7502253038886413e-45, 2.0000000000000000, 100.00000000000000 },
532 const double toler017 = 2.5000000000000020e-13;
534 // Test data for nu=5.0000000000000000.
535 // max(|f - f_GSL|): 6.9388939039072284e-18
536 // max(|f - f_GSL| / |f_GSL|): 2.3552470349020973e-16
537 const testcase_cyl_bessel_k<double>
538 data018[20] =
540 { 0.032706273712031865, 5.0000000000000000, 5.0000000000000000 },
541 { 5.7541849985312288e-05, 5.0000000000000000, 10.000000000000000 },
542 { 2.1878261369258224e-07, 5.0000000000000000, 15.000000000000000 },
543 { 1.0538660139974233e-09, 5.0000000000000000, 20.000000000000000 },
544 { 5.6485921365284157e-12, 5.0000000000000000, 25.000000000000000 },
545 { 3.2103335105890266e-14, 5.0000000000000000, 30.000000000000000 },
546 { 1.8919208406439644e-16, 5.0000000000000000, 35.000000000000000 },
547 { 1.1423814375953188e-18, 5.0000000000000000, 40.000000000000000 },
548 { 7.0181216822204101e-21, 5.0000000000000000, 45.000000000000000 },
549 { 4.3671822541009859e-23, 5.0000000000000000, 50.000000000000000 },
550 { 2.7444967640357869e-25, 5.0000000000000000, 55.000000000000000 },
551 { 1.7382232741886986e-27, 5.0000000000000000, 60.000000000000000 },
552 { 1.1078474298959669e-29, 5.0000000000000000, 65.000000000000000 },
553 { 7.0974537081794416e-32, 5.0000000000000000, 70.000000000000000 },
554 { 4.5667269500061064e-34, 5.0000000000000000, 75.000000000000000 },
555 { 2.9491764420206150e-36, 5.0000000000000000, 80.000000000000000 },
556 { 1.9105685973117463e-38, 5.0000000000000000, 85.000000000000000 },
557 { 1.2411034311592645e-40, 5.0000000000000000, 90.000000000000000 },
558 { 8.0814211331379146e-43, 5.0000000000000000, 95.000000000000000 },
559 { 5.2732561132929509e-45, 5.0000000000000000, 100.00000000000000 },
561 const double toler018 = 2.5000000000000020e-13;
563 // Test data for nu=10.000000000000000.
564 // max(|f - f_GSL|): 5.3290705182007514e-15
565 // max(|f - f_GSL| / |f_GSL|): 5.4609173619982130e-16
566 const testcase_cyl_bessel_k<double>
567 data019[20] =
569 { 9.7585628291778121, 10.000000000000000, 5.0000000000000000 },
570 { 0.0016142553003906700, 10.000000000000000, 10.000000000000000 },
571 { 2.2605303776606435e-06, 10.000000000000000, 15.000000000000000 },
572 { 6.3162145283215804e-09, 10.000000000000000, 20.000000000000000 },
573 { 2.4076769602801233e-11, 10.000000000000000, 25.000000000000000 },
574 { 1.0842816942222975e-13, 10.000000000000000, 30.000000000000000 },
575 { 5.3976770429777191e-16, 10.000000000000000, 35.000000000000000 },
576 { 2.8680293113671932e-18, 10.000000000000000, 40.000000000000000 },
577 { 1.5939871900169600e-20, 10.000000000000000, 45.000000000000000 },
578 { 9.1509882099879962e-23, 10.000000000000000, 50.000000000000000 },
579 { 5.3823846249592858e-25, 10.000000000000000, 55.000000000000000 },
580 { 3.2253408700563144e-27, 10.000000000000000, 60.000000000000000 },
581 { 1.9613367530075138e-29, 10.000000000000000, 65.000000000000000 },
582 { 1.2068471495933484e-31, 10.000000000000000, 70.000000000000000 },
583 { 7.4979152649449644e-34, 10.000000000000000, 75.000000000000000 },
584 { 4.6957285830490538e-36, 10.000000000000000, 80.000000000000000 },
585 { 2.9606323347034079e-38, 10.000000000000000, 85.000000000000000 },
586 { 1.8773542561131613e-40, 10.000000000000000, 90.000000000000000 },
587 { 1.1962899527846350e-42, 10.000000000000000, 95.000000000000000 },
588 { 7.6554279773881018e-45, 10.000000000000000, 100.00000000000000 },
590 const double toler019 = 2.5000000000000020e-13;
592 // Test data for nu=20.000000000000000.
593 // max(|f - f_GSL|): 4.1723251342773438e-07
594 // max(|f - f_GSL| / |f_GSL|): 1.2224656515794909e-15
595 const testcase_cyl_bessel_k<double>
596 data020[20] =
598 { 482700052.06214869, 20.000000000000000, 5.0000000000000000 },
599 { 178.74427820770546, 20.000000000000000, 10.000000000000000 },
600 { 0.012141257729731143, 20.000000000000000, 15.000000000000000 },
601 { 5.5431116361258155e-06, 20.000000000000000, 20.000000000000000 },
602 { 6.3744029330352113e-09, 20.000000000000000, 25.000000000000000 },
603 { 1.2304516475442478e-11, 20.000000000000000, 30.000000000000000 },
604 { 3.2673136479809018e-14, 20.000000000000000, 35.000000000000000 },
605 { 1.0703023799997383e-16, 20.000000000000000, 40.000000000000000 },
606 { 4.0549953175660457e-19, 20.000000000000000, 45.000000000000000 },
607 { 1.7061483797220349e-21, 20.000000000000000, 50.000000000000000 },
608 { 7.7617008115659413e-24, 20.000000000000000, 55.000000000000000 },
609 { 3.7482954006874720e-26, 20.000000000000000, 60.000000000000000 },
610 { 1.8966880763956576e-28, 20.000000000000000, 65.000000000000000 },
611 { 9.9615763479998864e-31, 20.000000000000000, 70.000000000000000 },
612 { 5.3921623063091066e-33, 20.000000000000000, 75.000000000000000 },
613 { 2.9920407657642272e-35, 20.000000000000000, 80.000000000000000 },
614 { 1.6948662723618255e-37, 20.000000000000000, 85.000000000000000 },
615 { 9.7689149642963042e-40, 20.000000000000000, 90.000000000000000 },
616 { 5.7143603019220823e-42, 20.000000000000000, 95.000000000000000 },
617 { 3.3852054148901700e-44, 20.000000000000000, 100.00000000000000 },
619 const double toler020 = 2.5000000000000020e-13;
621 // Test data for nu=50.000000000000000.
622 // max(|f - f_GSL|): 8.6655802749976619e+27
623 // max(|f - f_GSL| / |f_GSL|): 2.6684549464729312e-15
624 const testcase_cyl_bessel_k<double>
625 data021[20] =
627 { 3.3943222434301628e+42, 50.000000000000000, 5.0000000000000000 },
628 { 2.0613737753892557e+27, 50.000000000000000, 10.000000000000000 },
629 { 1.7267736974519188e+18, 50.000000000000000, 15.000000000000000 },
630 { 411711209122.01788, 50.000000000000000, 20.000000000000000 },
631 { 1972478.7419813874, 50.000000000000000, 25.000000000000000 },
632 { 58.770686258007267, 50.000000000000000, 30.000000000000000 },
633 { 0.0058659391182535178, 50.000000000000000, 35.000000000000000 },
634 { 1.3634854128794101e-06, 50.000000000000000, 40.000000000000000 },
635 { 5.8652396362160819e-10, 50.000000000000000, 45.000000000000000 },
636 { 4.0060134766400893e-13, 50.000000000000000, 50.000000000000000 },
637 { 3.9062324485711016e-16, 50.000000000000000, 55.000000000000000 },
638 { 5.0389298085176510e-19, 50.000000000000000, 60.000000000000000 },
639 { 8.1305344250110424e-22, 50.000000000000000, 65.000000000000000 },
640 { 1.5732816234948991e-24, 50.000000000000000, 70.000000000000000 },
641 { 3.5349854993874412e-27, 50.000000000000000, 75.000000000000000 },
642 { 8.9940101003189485e-30, 50.000000000000000, 80.000000000000000 },
643 { 2.5403205503080723e-32, 50.000000000000000, 85.000000000000000 },
644 { 7.8397596486715721e-35, 50.000000000000000, 90.000000000000000 },
645 { 2.6098900651329542e-37, 50.000000000000000, 95.000000000000000 },
646 { 9.2745226536133258e-40, 50.000000000000000, 100.00000000000000 },
648 const double toler021 = 2.5000000000000020e-13;
650 // Test data for nu=100.00000000000000.
651 // max(|f - f_GSL|): 3.4996011596528191e+101
652 // max(|f - f_GSL| / |f_GSL|): 4.9711230957426436e-15
653 const testcase_cyl_bessel_k<double>
654 data022[20] =
656 { 7.0398601930616815e+115, 100.00000000000000, 5.0000000000000000 },
657 { 4.5966740842695238e+85, 100.00000000000000, 10.000000000000000 },
658 { 8.2565552242653946e+67, 100.00000000000000, 15.000000000000000 },
659 { 1.7081356456876041e+55, 100.00000000000000, 20.000000000000000 },
660 { 1.9858028128780610e+45, 100.00000000000000, 25.000000000000000 },
661 { 1.2131584253026677e+37, 100.00000000000000, 30.000000000000000 },
662 { 1.1016916354696688e+30, 100.00000000000000, 35.000000000000000 },
663 { 7.0074023297775712e+23, 100.00000000000000, 40.000000000000000 },
664 { 1.9236643958470894e+18, 100.00000000000000, 45.000000000000000 },
665 { 16394035276269.250, 100.00000000000000, 50.000000000000000 },
666 { 343254952.89495474, 100.00000000000000, 55.000000000000000 },
667 { 14870.012754946298, 100.00000000000000, 60.000000000000000 },
668 { 1.1708099078572216, 100.00000000000000, 65.000000000000000 },
669 { 0.00015161193930722313, 100.00000000000000, 70.000000000000000 },
670 { 2.9850234381623443e-08, 100.00000000000000, 75.000000000000000 },
671 { 8.3928710724649129e-12, 100.00000000000000, 80.000000000000000 },
672 { 3.2033435630927732e-15, 100.00000000000000, 85.000000000000000 },
673 { 1.5922281431788096e-18, 100.00000000000000, 90.000000000000000 },
674 { 9.9589454577674131e-22, 100.00000000000000, 95.000000000000000 },
675 { 7.6171296304940840e-25, 100.00000000000000, 100.00000000000000 },
677 const double toler022 = 2.5000000000000020e-13;
679 template<typename Tp, unsigned int Num>
680 void
681 test(const testcase_cyl_bessel_k<Tp> (&data)[Num], Tp toler)
683 bool test __attribute__((unused)) = true;
684 const Tp eps = std::numeric_limits<Tp>::epsilon();
685 Tp max_abs_diff = -Tp(1);
686 Tp max_abs_frac = -Tp(1);
687 unsigned int num_datum = Num;
688 for (unsigned int i = 0; i < num_datum; ++i)
690 const Tp f = std::cyl_bessel_k(data[i].nu, data[i].x);
691 const Tp f0 = data[i].f0;
692 const Tp diff = f - f0;
693 if (std::abs(diff) > max_abs_diff)
694 max_abs_diff = std::abs(diff);
695 if (std::abs(f0) > Tp(10) * eps
696 && std::abs(f) > Tp(10) * eps)
698 const Tp frac = diff / f0;
699 if (std::abs(frac) > max_abs_frac)
700 max_abs_frac = std::abs(frac);
703 VERIFY(max_abs_frac < toler);
707 main()
709 test(data001, toler001);
710 test(data002, toler002);
711 test(data003, toler003);
712 test(data004, toler004);
713 test(data005, toler005);
714 test(data006, toler006);
715 test(data007, toler007);
716 test(data008, toler008);
717 test(data009, toler009);
718 test(data010, toler010);
719 test(data011, toler011);
720 test(data012, toler012);
721 test(data013, toler013);
722 test(data014, toler014);
723 test(data015, toler015);
724 test(data016, toler016);
725 test(data017, toler017);
726 test(data018, toler018);
727 test(data019, toler019);
728 test(data020, toler020);
729 test(data021, toler021);
730 test(data022, toler022);
731 return 0;