1 // { dg-do run { target c++11 } }
2 // { dg-options "-D__STDCPP_WANT_MATH_SPEC_FUNCS__" }
3 //
4 // Copyright (C) 2016-2018 Free Software Foundation, Inc.
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 //  cyl_bessel_k
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 <tr1/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 
40 // Test data for nu=0.0000000000000000.
41 // max(|f - f_GSL|): 2.2204460492503131e-16 at index 0
42 // max(|f - f_GSL| / |f_GSL|): 3.3025402038894216e-16
43 // mean(f - f_GSL): 1.0473392986209972e-17
44 // variance(f - f_GSL): 5.5842559222476003e-36
45 // stddev(f - f_GSL): 2.3631030282760842e-18
46 const testcase_cyl_bessel_k<double>
47 data007[20] =
48 {
49   { 1.5415067512483025, 0.0000000000000000, 0.25000000000000000, 0.0 },
50   { 0.92441907122766565, 0.0000000000000000, 0.50000000000000000, 0.0 },
51   { 0.61058242211646430, 0.0000000000000000, 0.75000000000000000, 0.0 },
52   { 0.42102443824070834, 0.0000000000000000, 1.0000000000000000, 0.0 },
53   { 0.29760308908410588, 0.0000000000000000, 1.2500000000000000, 0.0 },
54   { 0.21380556264752565, 0.0000000000000000, 1.5000000000000000, 0.0 },
55   { 0.15537981238660359, 0.0000000000000000, 1.7500000000000000, 0.0 },
56   { 0.11389387274953360, 0.0000000000000000, 2.0000000000000000, 0.0 },
57   { 0.084043111974658191, 0.0000000000000000, 2.2500000000000000, 0.0 },
58   { 0.062347553200366168, 0.0000000000000000, 2.5000000000000000, 0.0 },
59   { 0.046454901308760774, 0.0000000000000000, 2.7500000000000000, 0.0 },
60   { 0.034739504386279256, 0.0000000000000000, 3.0000000000000000, 0.0 },
61   { 0.026058755255154966, 0.0000000000000000, 3.2500000000000000, 0.0 },
62   { 0.019598897170368501, 0.0000000000000000, 3.5000000000000000, 0.0 },
63   { 0.014774250877128707, 0.0000000000000000, 3.7500000000000000, 0.0 },
64   { 0.011159676085853030, 0.0000000000000000, 4.0000000000000000, 0.0 },
65   { 0.0084443877245429649, 0.0000000000000000, 4.2500000000000000, 0.0 },
66   { 0.0063998572432339756, 0.0000000000000000, 4.5000000000000000, 0.0 },
67   { 0.0048572045578879524, 0.0000000000000000, 4.7500000000000000, 0.0 },
68   { 0.0036910983340425947, 0.0000000000000000, 5.0000000000000000, 0.0 },
69 };
70 const double toler007 = 2.5000000000000020e-13;
71 
72 // Test data for nu=0.33333333333333331.
73 // max(|f - f_GSL|): 9.1593399531575415e-16 at index 5
74 // max(|f - f_GSL| / |f_GSL|): 4.1603543087763551e-15
75 // mean(f - f_GSL): -2.0157486790850499e-16
76 // variance(f - f_GSL): 2.2511040095474369e-33
77 // stddev(f - f_GSL): 4.7445800757785052e-17
78 const testcase_cyl_bessel_k<double>
79 data008[20] =
80 {
81   { 1.7144912564234513, 0.33333333333333331, 0.25000000000000000, 0.0 },
82   { 0.98903107424672421, 0.33333333333333331, 0.50000000000000000, 0.0 },
83   { 0.64216899667282989, 0.33333333333333331, 0.75000000000000000, 0.0 },
84   { 0.43843063344153443, 0.33333333333333331, 1.0000000000000000, 0.0 },
85   { 0.30788192414945043, 0.33333333333333331, 1.2500000000000000, 0.0 },
86   { 0.22015769026776688, 0.33333333333333331, 1.5000000000000000, 0.0 },
87   { 0.15943413057311243, 0.33333333333333331, 1.7500000000000000, 0.0 },
88   { 0.11654496129616534, 0.33333333333333331, 2.0000000000000000, 0.0 },
89   { 0.085809609306439674, 0.33333333333333331, 2.2500000000000000, 0.0 },
90   { 0.063542537454733386, 0.33333333333333331, 2.5000000000000000, 0.0 },
91   { 0.047273354184795509, 0.33333333333333331, 2.7500000000000000, 0.0 },
92   { 0.035305904902162587, 0.33333333333333331, 3.0000000000000000, 0.0 },
93   { 0.026454186892773169, 0.33333333333333331, 3.2500000000000000, 0.0 },
94   { 0.019877061407943805, 0.33333333333333331, 3.5000000000000000, 0.0 },
95   { 0.014971213514760216, 0.33333333333333331, 3.7500000000000000, 0.0 },
96   { 0.011299947573672166, 0.33333333333333331, 4.0000000000000000, 0.0 },
97   { 0.0085447959546110473, 0.33333333333333331, 4.2500000000000000, 0.0 },
98   { 0.0064720581217078245, 0.33333333333333331, 4.5000000000000000, 0.0 },
99   { 0.0049093342803275264, 0.33333333333333331, 4.7500000000000000, 0.0 },
100   { 0.0037288750960535887, 0.33333333333333331, 5.0000000000000000, 0.0 },
101 };
102 const double toler008 = 2.5000000000000020e-13;
103 
104 // Test data for nu=0.50000000000000000.
105 // max(|f - f_GSL|): 1.3322676295501878e-15 at index 1
106 // max(|f - f_GSL| / |f_GSL|): 1.3827172837936134e-15
107 // mean(f - f_GSL): 7.5200262683594590e-17
108 // variance(f - f_GSL): 3.1330080374967473e-34
109 // stddev(f - f_GSL): 1.7700305188037711e-17
110 const testcase_cyl_bessel_k<double>
111 data009[20] =
112 {
113   { 1.9521640631515476, 0.50000000000000000, 0.25000000000000000, 0.0 },
114   { 1.0750476034999195, 0.50000000000000000, 0.50000000000000000, 0.0 },
115   { 0.68361006034952432, 0.50000000000000000, 0.75000000000000000, 0.0 },
116   { 0.46106850444789443, 0.50000000000000000, 1.0000000000000000, 0.0 },
117   { 0.32117137397144746, 0.50000000000000000, 1.2500000000000000, 0.0 },
118   { 0.22833505222826550, 0.50000000000000000, 1.5000000000000000, 0.0 },
119   { 0.16463628997380861, 0.50000000000000000, 1.7500000000000000, 0.0 },
120   { 0.11993777196806145, 0.50000000000000000, 2.0000000000000000, 0.0 },
121   { 0.088065558803650454, 0.50000000000000000, 2.2500000000000000, 0.0 },
122   { 0.065065943154009986, 0.50000000000000000, 2.5000000000000000, 0.0 },
123   { 0.048315198301417825, 0.50000000000000000, 2.7500000000000000, 0.0 },
124   { 0.036025985131764589, 0.50000000000000000, 3.0000000000000000, 0.0 },
125   { 0.026956356532443351, 0.50000000000000000, 3.2500000000000000, 0.0 },
126   { 0.020229969578139294, 0.50000000000000000, 3.5000000000000000, 0.0 },
127   { 0.015220888252975568, 0.50000000000000000, 3.7500000000000000, 0.0 },
128   { 0.011477624576608053, 0.50000000000000000, 4.0000000000000000, 0.0 },
129   { 0.0086718932956978342, 0.50000000000000000, 4.2500000000000000, 0.0 },
130   { 0.0065633945646345424, 0.50000000000000000, 4.5000000000000000, 0.0 },
131   { 0.0049752435421262292, 0.50000000000000000, 4.7500000000000000, 0.0 },
132   { 0.0037766133746428825, 0.50000000000000000, 5.0000000000000000, 0.0 },
133 };
134 const double toler009 = 2.5000000000000020e-13;
135 
136 // Test data for nu=0.66666666666666663.
137 // max(|f - f_GSL|): 8.3266726846886741e-16 at index 4
138 // max(|f - f_GSL| / |f_GSL|): 2.4444922503951783e-15
139 // mean(f - f_GSL): 1.5718763096694843e-16
140 // variance(f - f_GSL): 1.3764253709076715e-33
141 // stddev(f - f_GSL): 3.7100207154511570e-17
142 const testcase_cyl_bessel_k<double>
143 data010[20] =
144 {
145   { 2.3289060745544101, 0.66666666666666663, 0.25000000000000000, 0.0 },
146   { 1.2059304647203353, 0.66666666666666663, 0.50000000000000000, 0.0 },
147   { 0.74547232976647226, 0.66666666666666663, 0.75000000000000000, 0.0 },
148   { 0.49447506210420811, 0.66666666666666663, 1.0000000000000000, 0.0 },
149   { 0.34062994813514252, 0.66666666666666663, 1.2500000000000000, 0.0 },
150   { 0.24024045240315581, 0.66666666666666663, 1.5000000000000000, 0.0 },
151   { 0.17217716908452307, 0.66666666666666663, 1.7500000000000000, 0.0 },
152   { 0.12483892748812841, 0.66666666666666663, 2.0000000000000000, 0.0 },
153   { 0.091315296079621050, 0.66666666666666663, 2.2500000000000000, 0.0 },
154   { 0.067255322171623361, 0.66666666666666663, 2.5000000000000000, 0.0 },
155   { 0.049809546542402224, 0.66666666666666663, 2.7500000000000000, 0.0 },
156   { 0.037057074495188531, 0.66666666666666663, 3.0000000000000000, 0.0 },
157   { 0.027674365504886729, 0.66666666666666663, 3.2500000000000000, 0.0 },
158   { 0.020733915836010912, 0.66666666666666663, 3.5000000000000000, 0.0 },
159   { 0.015577015510251336, 0.66666666666666663, 3.7500000000000000, 0.0 },
160   { 0.011730801456525337, 0.66666666666666663, 4.0000000000000000, 0.0 },
161   { 0.0088528343204658851, 0.66666666666666663, 4.2500000000000000, 0.0 },
162   { 0.0066933190915775568, 0.66666666666666663, 4.5000000000000000, 0.0 },
163   { 0.0050689292106255480, 0.66666666666666663, 4.7500000000000000, 0.0 },
164   { 0.0038444246344968226, 0.66666666666666663, 5.0000000000000000, 0.0 },
165 };
166 const double toler010 = 2.5000000000000020e-13;
167 
168 // Test data for nu=1.0000000000000000.
169 // max(|f - f_GSL|): 5.5511151231257827e-17 at index 5
170 // max(|f - f_GSL| / |f_GSL|): 4.1133060946717609e-16
171 // mean(f - f_GSL): 9.1072982488782376e-19
172 // variance(f - f_GSL): 4.5951734844332747e-38
173 // stddev(f - f_GSL): 2.1436355764059512e-19
174 const testcase_cyl_bessel_k<double>
175 data011[20] =
176 {
177   { 3.7470259744407115, 1.0000000000000000, 0.25000000000000000, 0.0 },
178   { 1.6564411200033007, 1.0000000000000000, 0.50000000000000000, 0.0 },
179   { 0.94958046696214016, 1.0000000000000000, 0.75000000000000000, 0.0 },
180   { 0.60190723019723458, 1.0000000000000000, 1.0000000000000000, 0.0 },
181   { 0.40212407978419540, 1.0000000000000000, 1.2500000000000000, 0.0 },
182   { 0.27738780045684375, 1.0000000000000000, 1.5000000000000000, 0.0 },
183   { 0.19547745347439305, 1.0000000000000000, 1.7500000000000000, 0.0 },
184   { 0.13986588181652262, 1.0000000000000000, 2.0000000000000000, 0.0 },
185   { 0.10121630256832535, 1.0000000000000000, 2.2500000000000000, 0.0 },
186   { 0.073890816347747038, 1.0000000000000000, 2.5000000000000000, 0.0 },
187   { 0.054318522758919859, 1.0000000000000000, 2.7500000000000000, 0.0 },
188   { 0.040156431128194198, 1.0000000000000000, 3.0000000000000000, 0.0 },
189   { 0.029825529796040143, 1.0000000000000000, 3.2500000000000000, 0.0 },
190   { 0.022239392925923845, 1.0000000000000000, 3.5000000000000000, 0.0 },
191   { 0.016638191754688916, 1.0000000000000000, 3.7500000000000000, 0.0 },
192   { 0.012483498887268437, 1.0000000000000000, 4.0000000000000000, 0.0 },
193   { 0.0093896806560432589, 1.0000000000000000, 4.2500000000000000, 0.0 },
194   { 0.0070780949089680918, 1.0000000000000000, 4.5000000000000000, 0.0 },
195   { 0.0053459218178228390, 1.0000000000000000, 4.7500000000000000, 0.0 },
196   { 0.0040446134454521655, 1.0000000000000000, 5.0000000000000000, 0.0 },
197 };
198 const double toler011 = 2.5000000000000020e-13;
199 
200 // Test data for nu=2.0000000000000000.
201 // max(|f - f_GSL|): 3.5527136788005009e-15 at index 0
202 // max(|f - f_GSL| / |f_GSL|): 3.2289213139335320e-16
203 // mean(f - f_GSL): -2.2187113257743364e-16
204 // variance(f - f_GSL): 2.7486114598283265e-33
205 // stddev(f - f_GSL): 5.2427201525814123e-17
206 const testcase_cyl_bessel_k<double>
207 data012[20] =
208 {
209   { 31.517714546773998, 2.0000000000000000, 0.25000000000000000, 0.0 },
210   { 7.5501835512408695, 2.0000000000000000, 0.50000000000000000, 0.0 },
211   { 3.1427970006821715, 2.0000000000000000, 0.75000000000000000, 0.0 },
212   { 1.6248388986351774, 2.0000000000000000, 1.0000000000000000, 0.0 },
213   { 0.94100161673881855, 2.0000000000000000, 1.2500000000000000, 0.0 },
214   { 0.58365596325665070, 2.0000000000000000, 1.5000000000000000, 0.0 },
215   { 0.37878261635733851, 2.0000000000000000, 1.7500000000000000, 0.0 },
216   { 0.25375975456605621, 2.0000000000000000, 2.0000000000000000, 0.0 },
217   { 0.17401315870205850, 2.0000000000000000, 2.2500000000000000, 0.0 },
218   { 0.12146020627856381, 2.0000000000000000, 2.5000000000000000, 0.0 },
219   { 0.085959281497066137, 2.0000000000000000, 2.7500000000000000, 0.0 },
220   { 0.061510458471742059, 2.0000000000000000, 3.0000000000000000, 0.0 },
221   { 0.044412927437333515, 2.0000000000000000, 3.2500000000000000, 0.0 },
222   { 0.032307121699467839, 2.0000000000000000, 3.5000000000000000, 0.0 },
223   { 0.023647953146296131, 2.0000000000000000, 3.7500000000000000, 0.0 },
224   { 0.017401425529487247, 2.0000000000000000, 4.0000000000000000, 0.0 },
225   { 0.012863060974445674, 2.0000000000000000, 4.2500000000000000, 0.0 },
226   { 0.0095456772027753493, 2.0000000000000000, 4.5000000000000000, 0.0 },
227   { 0.0071081190074975690, 2.0000000000000000, 4.7500000000000000, 0.0 },
228   { 0.0053089437122234608, 2.0000000000000000, 5.0000000000000000, 0.0 },
229 };
230 const double toler012 = 2.5000000000000020e-13;
231 
232 // Test data for nu=5.0000000000000000.
233 // max(|f - f_GSL|): 5.8207660913467407e-11 at index 0
234 // max(|f - f_GSL| / |f_GSL|): 5.4133817134973930e-16
235 // mean(f - f_GSL): -3.0029749520377179e-12
236 // variance(f - f_GSL): 4.9960666134422494e-25
237 // stddev(f - f_GSL): 7.0682859403410163e-13
238 const testcase_cyl_bessel_k<double>
239 data013[20] =
240 {
241   { 391683.98962334893, 5.0000000000000000, 0.25000000000000000, 0.0 },
242   { 12097.979476096394, 5.0000000000000000, 0.50000000000000000, 0.0 },
243   { 1562.5870339691098, 5.0000000000000000, 0.75000000000000000, 0.0 },
244   { 360.96058960124071, 5.0000000000000000, 1.0000000000000000, 0.0 },
245   { 114.29321426334016, 5.0000000000000000, 1.2500000000000000, 0.0 },
246   { 44.067781159301056, 5.0000000000000000, 1.5000000000000000, 0.0 },
247   { 19.426568687730288, 5.0000000000000000, 1.7500000000000000, 0.0 },
248   { 9.4310491005964820, 5.0000000000000000, 2.0000000000000000, 0.0 },
249   { 4.9221270549918685, 5.0000000000000000, 2.2500000000000000, 0.0 },
250   { 2.7168842907865423, 5.0000000000000000, 2.5000000000000000, 0.0 },
251   { 1.5677685890536335, 5.0000000000000000, 2.7500000000000000, 0.0 },
252   { 0.93777360238680818, 5.0000000000000000, 3.0000000000000000, 0.0 },
253   { 0.57775534736785106, 5.0000000000000000, 3.2500000000000000, 0.0 },
254   { 0.36482440208451983, 5.0000000000000000, 3.5000000000000000, 0.0 },
255   { 0.23520290620082260, 5.0000000000000000, 3.7500000000000000, 0.0 },
256   { 0.15434254872599726, 5.0000000000000000, 4.0000000000000000, 0.0 },
257   { 0.10283347176876455, 5.0000000000000000, 4.2500000000000000, 0.0 },
258   { 0.069423643150881773, 5.0000000000000000, 4.5000000000000000, 0.0 },
259   { 0.047410616917942211, 5.0000000000000000, 4.7500000000000000, 0.0 },
260   { 0.032706273712031865, 5.0000000000000000, 5.0000000000000000, 0.0 },
261 };
262 const double toler013 = 2.5000000000000020e-13;
263 
264 // Test data for nu=10.000000000000000.
265 // max(|f - f_GSL|): 6.1035156250000000e-05 at index 1
266 // max(|f - f_GSL| / |f_GSL|): 7.7998476565326393e-16
267 // mean(f - f_GSL): -3.0495557438392496e-06
268 // variance(f - f_GSL): 5.1522383752309128e-13
269 // stddev(f - f_GSL): 7.1779094277031061e-07
270 const testcase_cyl_bessel_k<double>
271 data014[20] =
272 {
273   { 194481817927839.88, 10.000000000000000, 0.25000000000000000, 0.0 },
274   { 188937569319.90030, 10.000000000000000, 0.50000000000000000, 0.0 },
275   { 3248187687.8018155, 10.000000000000000, 0.75000000000000000, 0.0 },
276   { 180713289.90102944, 10.000000000000000, 1.0000000000000000, 0.0 },
277   { 19104425.945252180, 10.000000000000000, 1.2500000000000000, 0.0 },
278   { 3027483.5236822353, 10.000000000000000, 1.5000000000000000, 0.0 },
279   { 633724.71555087867, 10.000000000000000, 1.7500000000000000, 0.0 },
280   { 162482.40397955943, 10.000000000000000, 2.0000000000000000, 0.0 },
281   { 48602.446087749791, 10.000000000000000, 2.2500000000000000, 0.0 },
282   { 16406.916416341937, 10.000000000000000, 2.5000000000000000, 0.0 },
283   { 6104.1720745909606, 10.000000000000000, 2.7500000000000000, 0.0 },
284   { 2459.6204220569480, 10.000000000000000, 3.0000000000000000, 0.0 },
285   { 1059.2358443703381, 10.000000000000000, 3.2500000000000000, 0.0 },
286   { 482.53582096664758, 10.000000000000000, 3.5000000000000000, 0.0 },
287   { 230.64249314993782, 10.000000000000000, 3.7500000000000000, 0.0 },
288   { 114.91408364049623, 10.000000000000000, 4.0000000000000000, 0.0 },
289   { 59.361613632706479, 10.000000000000000, 4.2500000000000000, 0.0 },
290   { 31.652958759229872, 10.000000000000000, 4.5000000000000000, 0.0 },
291   { 17.357723966417399, 10.000000000000000, 4.7500000000000000, 0.0 },
292   { 9.7585628291778121, 10.000000000000000, 5.0000000000000000, 0.0 },
293 };
294 const double toler014 = 2.5000000000000020e-13;
295 
296 // Test data for nu=20.000000000000000.
297 // max(|f - f_GSL|): 2.7670116110564327e+19 at index 0
298 // max(|f - f_GSL| / |f_GSL|): 1.2737005853777639e-15
299 // mean(f - f_GSL): -1.3835066851362150e+18
300 // variance(f - f_GSL): inf
301 // stddev(f - f_GSL): inf
302 const testcase_cyl_bessel_k<double>
303 data015[20] =
304 {
305   { 7.0065983661641184e+34, 20.000000000000000, 0.25000000000000000, 0.0 },
306   { 6.6655498744171593e+28, 20.000000000000000, 0.50000000000000000, 0.0 },
307   { 1.9962989615380379e+25, 20.000000000000000, 0.75000000000000000, 0.0 },
308   { 6.2943693604245335e+22, 20.000000000000000, 1.0000000000000000, 0.0 },
309   { 7.2034511920074182e+20, 20.000000000000000, 1.2500000000000000, 0.0 },
310   { 1.8620549984645546e+19, 20.000000000000000, 1.5000000000000000, 0.0 },
311   { 8.4415605303952486e+17, 20.000000000000000, 1.7500000000000000, 0.0 },
312   { 57708568527002520., 20.000000000000000, 2.0000000000000000, 0.0 },
313   { 5396824209986879.0, 20.000000000000000, 2.2500000000000000, 0.0 },
314   { 645996884063683.62, 20.000000000000000, 2.5000000000000000, 0.0 },
315   { 94387401970996.328, 20.000000000000000, 2.7500000000000000, 0.0 },
316   { 16254643952204.371, 20.000000000000000, 3.0000000000000000, 0.0 },
317   { 3212694836166.4053, 20.000000000000000, 3.2500000000000000, 0.0 },
318   { 713857897923.74072, 20.000000000000000, 3.5000000000000000, 0.0 },
319   { 175423421958.35925, 20.000000000000000, 3.7500000000000000, 0.0 },
320   { 47050078926.298088, 20.000000000000000, 4.0000000000000000, 0.0 },
321   { 13625066095.067503, 20.000000000000000, 4.2500000000000000, 0.0 },
322   { 4222179870.6810660, 20.000000000000000, 4.5000000000000000, 0.0 },
323   { 1389634112.7516634, 20.000000000000000, 4.7500000000000000, 0.0 },
324   { 482700052.06214869, 20.000000000000000, 5.0000000000000000, 0.0 },
325 };
326 const double toler015 = 2.5000000000000020e-13;
327 
328 // Test data for nu=50.000000000000000.
329 // max(|f - f_GSL|): 3.9111090745622133e+92 at index 0
330 // max(|f - f_GSL| / |f_GSL|): 3.7220730535457535e-15
331 // mean(f - f_GSL): -1.9555545372811066e+91
332 // variance(f - f_GSL): inf
333 // stddev(f - f_GSL): inf
334 const testcase_cyl_bessel_k<double>
335 data016[20] =
336 {
337   { 4.3394604622138714e+107, 50.000000000000000, 0.25000000000000000, 0.0 },
338   { 3.8505298918269003e+92, 50.000000000000000, 0.50000000000000000, 0.0 },
339   { 6.0292756894842793e+83, 50.000000000000000, 0.75000000000000000, 0.0 },
340   { 3.4068968541617001e+77, 50.000000000000000, 1.0000000000000000, 0.0 },
341   { 4.8485527365039051e+72, 50.000000000000000, 1.2500000000000000, 0.0 },
342   { 5.3091717574907920e+68, 50.000000000000000, 1.5000000000000000, 0.0 },
343   { 2.3762245257445824e+65, 50.000000000000000, 1.7500000000000000, 0.0 },
344   { 2.9799817396049268e+62, 50.000000000000000, 2.0000000000000000, 0.0 },
345   { 8.2079431233488581e+59, 50.000000000000000, 2.2500000000000000, 0.0 },
346   { 4.2046528212987503e+57, 50.000000000000000, 2.5000000000000000, 0.0 },
347   { 3.5578676911884825e+55, 50.000000000000000, 2.7500000000000000, 0.0 },
348   { 4.5559542293221535e+53, 50.000000000000000, 3.0000000000000000, 0.0 },
349   { 8.2606735967628997e+51, 50.000000000000000, 3.2500000000000000, 0.0 },
350   { 2.0139406747903812e+50, 50.000000000000000, 3.5000000000000000, 0.0 },
351   { 6.3368727837484613e+48, 50.000000000000000, 3.7500000000000000, 0.0 },
352   { 2.4897317389325757e+47, 50.000000000000000, 4.0000000000000000, 0.0 },
353   { 1.1888958173039699e+46, 50.000000000000000, 4.2500000000000000, 0.0 },
354   { 6.7472593648148550e+44, 50.000000000000000, 4.5000000000000000, 0.0 },
355   { 4.4664266585930700e+43, 50.000000000000000, 4.7500000000000000, 0.0 },
356   { 3.3943222434301628e+42, 50.000000000000000, 5.0000000000000000, 0.0 },
357 };
358 const double toler016 = 2.5000000000000020e-13;
359 
360 // Test data for nu=100.00000000000000.
361 // max(|f - f_GSL|): 8.5970689361151757e+232 at index 0
362 // max(|f - f_GSL| / |f_GSL|): 9.0457919481999128e-14
363 // mean(f - f_GSL): -4.2985344680575876e+231
364 // variance(f - f_GSL): inf
365 // stddev(f - f_GSL): inf
366 const testcase_cyl_bessel_k<double>
367 data017[20] =
368 {
369   { 9.5039428115809898e+245, 100.00000000000000, 0.25000000000000000, 0.0 },
370   { 7.4937399313533112e+215, 100.00000000000000, 0.50000000000000000, 0.0 },
371   { 1.8417471020730699e+198, 100.00000000000000, 0.75000000000000000, 0.0 },
372   { 5.9003331836386410e+185, 100.00000000000000, 1.0000000000000000, 0.0 },
373   { 1.2002130935576950e+176, 100.00000000000000, 1.2500000000000000, 0.0 },
374   { 1.4467044226487075e+168, 100.00000000000000, 1.5000000000000000, 0.0 },
375   { 2.9161498411497642e+161, 100.00000000000000, 1.7500000000000000, 0.0 },
376   { 4.6194159776013925e+155, 100.00000000000000, 2.0000000000000000, 0.0 },
377   { 3.5332121583541727e+150, 100.00000000000000, 2.2500000000000000, 0.0 },
378   { 9.3566097231039940e+145, 100.00000000000000, 2.5000000000000000, 0.0 },
379   { 6.7672283615134532e+141, 100.00000000000000, 2.7500000000000000, 0.0 },
380   { 1.1219630864949494e+138, 100.00000000000000, 3.0000000000000000, 0.0 },
381   { 3.7329723699990903e+134, 100.00000000000000, 3.2500000000000000, 0.0 },
382   { 2.2476893883855163e+131, 100.00000000000000, 3.5000000000000000, 0.0 },
383   { 2.2564559319883200e+128, 100.00000000000000, 3.7500000000000000, 0.0 },
384   { 3.5353340499626463e+125, 100.00000000000000, 4.0000000000000000, 0.0 },
385   { 8.1898439213010234e+122, 100.00000000000000, 4.2500000000000000, 0.0 },
386   { 2.6823744110726800e+120, 100.00000000000000, 4.5000000000000000, 0.0 },
387   { 1.1963963615212274e+118, 100.00000000000000, 4.7500000000000000, 0.0 },
388   { 7.0398601930616815e+115, 100.00000000000000, 5.0000000000000000, 0.0 },
389 };
390 const double toler017 = 5.0000000000000029e-12;
391 //  cyl_bessel_k
392 
393 // Test data for nu=0.0000000000000000.
394 // max(|f - f_GSL|): 4.3368086899420177e-19 at index 0
395 // max(|f - f_GSL| / |f_GSL|): 2.3318588132773140e-16
396 // mean(f - f_GSL): 2.1684048659978596e-20
397 // variance(f - f_GSL): 2.6049748824837649e-41
398 // stddev(f - f_GSL): 5.1038954559079328e-21
399 const testcase_cyl_bessel_k<double>
400 data018[20] =
401 {
402   { 0.0036910983340425947, 0.0000000000000000, 5.0000000000000000, 0.0 },
403   { 1.7780062316167647e-05, 0.0000000000000000, 10.000000000000000, 0.0 },
404   { 9.8195364823964333e-08, 0.0000000000000000, 15.000000000000000, 0.0 },
405   { 5.7412378153365238e-10, 0.0000000000000000, 20.000000000000000, 0.0 },
406   { 3.4641615622131151e-12, 0.0000000000000000, 25.000000000000000, 0.0 },
407   { 2.1324774964630566e-14, 0.0000000000000000, 30.000000000000000, 0.0 },
408   { 1.3310351491429464e-16, 0.0000000000000000, 35.000000000000000, 0.0 },
409   { 8.3928611000995700e-19, 0.0000000000000000, 40.000000000000000, 0.0 },
410   { 5.3334561226187247e-21, 0.0000000000000000, 45.000000000000000, 0.0 },
411   { 3.4101677497894956e-23, 0.0000000000000000, 50.000000000000000, 0.0 },
412   { 2.1913102183534147e-25, 0.0000000000000000, 55.000000000000000, 0.0 },
413   { 1.4138978405591074e-27, 0.0000000000000000, 60.000000000000000, 0.0 },
414   { 9.1544673210030045e-30, 0.0000000000000000, 65.000000000000000, 0.0 },
415   { 5.9446613372925013e-32, 0.0000000000000000, 70.000000000000000, 0.0 },
416   { 3.8701170455869113e-34, 0.0000000000000000, 75.000000000000000, 0.0 },
417   { 2.5251198425054720e-36, 0.0000000000000000, 80.000000000000000, 0.0 },
418   { 1.6507623579783908e-38, 0.0000000000000000, 85.000000000000000, 0.0 },
419   { 1.0810242556984256e-40, 0.0000000000000000, 90.000000000000000, 0.0 },
420   { 7.0901249699001278e-43, 0.0000000000000000, 95.000000000000000, 0.0 },
421   { 4.6566282291759025e-45, 0.0000000000000000, 100.00000000000000, 0.0 },
422 };
423 const double toler018 = 2.5000000000000020e-13;
424 
425 // Test data for nu=0.33333333333333331.
426 // max(|f - f_GSL|): 1.0339757656912846e-25 at index 3
427 // max(|f - f_GSL| / |f_GSL|): 2.3267819230578392e-16
428 // mean(f - f_GSL): 5.2104262741326337e-27
429 // variance(f - f_GSL): 1.5040743467131125e-54
430 // stddev(f - f_GSL): 1.2264070884959499e-27
431 const testcase_cyl_bessel_k<double>
432 data019[20] =
433 {
434   { 0.0037288750960535887, 0.33333333333333331, 5.0000000000000000, 0.0 },
435   { 1.7874608271055336e-05, 0.33333333333333331, 10.000000000000000, 0.0 },
436   { 9.8548341568798317e-08, 0.33333333333333331, 15.000000000000000, 0.0 },
437   { 5.7568278247790865e-10, 0.33333333333333331, 20.000000000000000, 0.0 },
438   { 3.4717201424907059e-12, 0.33333333333333331, 25.000000000000000, 0.0 },
439   { 2.1363664736611189e-14, 0.33333333333333331, 30.000000000000000, 0.0 },
440   { 1.3331202314165813e-16, 0.33333333333333331, 35.000000000000000, 0.0 },
441   { 8.4043837769480934e-19, 0.33333333333333331, 40.000000000000000, 0.0 },
442   { 5.3399731261024948e-21, 0.33333333333333331, 45.000000000000000, 0.0 },
443   { 3.4139217813583632e-23, 0.33333333333333331, 50.000000000000000, 0.0 },
444   { 2.1935050179185627e-25, 0.33333333333333331, 55.000000000000000, 0.0 },
445   { 1.4151968805623662e-27, 0.33333333333333331, 60.000000000000000, 0.0 },
446   { 9.1622357217019043e-30, 0.33333333333333331, 65.000000000000000, 0.0 },
447   { 5.9493479703461315e-32, 0.33333333333333331, 70.000000000000000, 0.0 },
448   { 3.8729660011055947e-34, 0.33333333333333331, 75.000000000000000, 0.0 },
449   { 2.5268631828013874e-36, 0.33333333333333331, 80.000000000000000, 0.0 },
450   { 1.6518353676138867e-38, 0.33333333333333331, 85.000000000000000, 0.0 },
451   { 1.0816880942511494e-40, 0.33333333333333331, 90.000000000000000, 0.0 },
452   { 7.0942508599231512e-43, 0.33333333333333331, 95.000000000000000, 0.0 },
453   { 4.6592031570213448e-45, 0.33333333333333331, 100.00000000000000, 0.0 },
454 };
455 const double toler019 = 2.5000000000000020e-13;
456 
457 // Test data for nu=0.50000000000000000.
458 // max(|f - f_GSL|): 8.0779356694631609e-28 at index 4
459 // max(|f - f_GSL| / |f_GSL|): 2.3204515428965958e-16
460 // mean(f - f_GSL): 4.0547450415218674e-29
461 // variance(f - f_GSL): 9.1085636297762724e-59
462 // stddev(f - f_GSL): 9.5438795202874765e-30
463 const testcase_cyl_bessel_k<double>
464 data020[20] =
465 {
466   { 0.0037766133746428825, 0.50000000000000000, 5.0000000000000000, 0.0 },
467   { 1.7993478093705178e-05, 0.50000000000000000, 10.000000000000000, 0.0 },
468   { 9.8991312032877236e-08, 0.50000000000000000, 15.000000000000000, 0.0 },
469   { 5.7763739747074450e-10, 0.50000000000000000, 20.000000000000000, 0.0 },
470   { 3.4811912768406949e-12, 0.50000000000000000, 25.000000000000000, 0.0 },
471   { 2.1412375659560111e-14, 0.50000000000000000, 30.000000000000000, 0.0 },
472   { 1.3357311366035824e-16, 0.50000000000000000, 35.000000000000000, 0.0 },
473   { 8.4188091949489049e-19, 0.50000000000000000, 40.000000000000000, 0.0 },
474   { 5.3481305002517408e-21, 0.50000000000000000, 45.000000000000000, 0.0 },
475   { 3.4186200954570754e-23, 0.50000000000000000, 50.000000000000000, 0.0 },
476   { 2.1962515908772453e-25, 0.50000000000000000, 55.000000000000000, 0.0 },
477   { 1.4168223500353693e-27, 0.50000000000000000, 60.000000000000000, 0.0 },
478   { 9.1719554473256892e-30, 0.50000000000000000, 65.000000000000000, 0.0 },
479   { 5.9552114337788932e-32, 0.50000000000000000, 70.000000000000000, 0.0 },
480   { 3.8765301321409432e-34, 0.50000000000000000, 75.000000000000000, 0.0 },
481   { 2.5290440439442907e-36, 0.50000000000000000, 80.000000000000000, 0.0 },
482   { 1.6531776067605980e-38, 0.50000000000000000, 85.000000000000000, 0.0 },
483   { 1.0825184636529955e-40, 0.50000000000000000, 90.000000000000000, 0.0 },
484   { 7.0994115873258822e-43, 0.50000000000000000, 95.000000000000000, 0.0 },
485   { 4.6624238126346709e-45, 0.50000000000000000, 100.00000000000000, 0.0 },
486 };
487 const double toler020 = 2.5000000000000020e-13;
488 
489 // Test data for nu=0.66666666666666663.
490 // max(|f - f_GSL|): 4.3368086899420177e-19 at index 0
491 // max(|f - f_GSL| / |f_GSL|): 3.5630695000470094e-16
492 // mean(f - f_GSL): -2.1684694793857957e-20
493 // variance(f - f_GSL): 2.6051301291012209e-41
494 // stddev(f - f_GSL): 5.1040475400423349e-21
495 const testcase_cyl_bessel_k<double>
496 data021[20] =
497 {
498   { 0.0038444246344968226, 0.66666666666666663, 5.0000000000000000, 0.0 },
499   { 1.8161187569530204e-05, 0.66666666666666663, 10.000000000000000, 0.0 },
500   { 9.9614751542305571e-08, 0.66666666666666663, 15.000000000000000, 0.0 },
501   { 5.8038484271925811e-10, 0.66666666666666663, 20.000000000000000, 0.0 },
502   { 3.4944937498488603e-12, 0.66666666666666663, 25.000000000000000, 0.0 },
503   { 2.1480755645577720e-14, 0.66666666666666663, 30.000000000000000, 0.0 },
504   { 1.3393949190152161e-16, 0.66666666666666663, 35.000000000000000, 0.0 },
505   { 8.4390460553642992e-19, 0.66666666666666663, 40.000000000000000, 0.0 },
506   { 5.3595716143622089e-21, 0.66666666666666663, 45.000000000000000, 0.0 },
507   { 3.4252085301433749e-23, 0.66666666666666663, 50.000000000000000, 0.0 },
508   { 2.2001025377982308e-25, 0.66666666666666663, 55.000000000000000, 0.0 },
509   { 1.4191011274172078e-27, 0.66666666666666663, 60.000000000000000, 0.0 },
510   { 9.1855803020269763e-30, 0.66666666666666663, 65.000000000000000, 0.0 },
511   { 5.9634299472578764e-32, 0.66666666666666663, 70.000000000000000, 0.0 },
512   { 3.8815254026478500e-34, 0.66666666666666663, 75.000000000000000, 0.0 },
513   { 2.5321003991943847e-36, 0.66666666666666663, 80.000000000000000, 0.0 },
514   { 1.6550585670593067e-38, 0.66666666666666663, 85.000000000000000, 0.0 },
515   { 1.0836820479428605e-40, 0.66666666666666663, 90.000000000000000, 0.0 },
516   { 7.1066428916285356e-43, 0.66666666666666663, 95.000000000000000, 0.0 },
517   { 4.6669364587280459e-45, 0.66666666666666663, 100.00000000000000, 0.0 },
518 };
519 const double toler021 = 2.5000000000000020e-13;
520 
521 // Test data for nu=1.0000000000000000.
522 // max(|f - f_GSL|): 1.0339757656912846e-25 at index 3
523 // max(|f - f_GSL| / |f_GSL|): 1.7575481510496439e-16
524 // mean(f - f_GSL): 5.1899158905965940e-27
525 // variance(f - f_GSL): 1.4922563408014978e-54
526 // stddev(f - f_GSL): 1.2215794451452995e-27
527 const testcase_cyl_bessel_k<double>
528 data022[20] =
529 {
530   { 0.0040446134454521655, 1.0000000000000000, 5.0000000000000000, 0.0 },
531   { 1.8648773453825579e-05, 1.0000000000000000, 10.000000000000000, 0.0 },
532   { 1.0141729369762091e-07, 1.0000000000000000, 15.000000000000000, 0.0 },
533   { 5.8830579695570384e-10, 1.0000000000000000, 20.000000000000000, 0.0 },
534   { 3.5327780731999345e-12, 1.0000000000000000, 25.000000000000000, 0.0 },
535   { 2.1677320018915498e-14, 1.0000000000000000, 30.000000000000000, 0.0 },
536   { 1.3499178340011053e-16, 1.0000000000000000, 35.000000000000000, 0.0 },
537   { 8.4971319548610435e-19, 1.0000000000000000, 40.000000000000000, 0.0 },
538   { 5.3923945937225035e-21, 1.0000000000000000, 45.000000000000000, 0.0 },
539   { 3.4441022267175555e-23, 1.0000000000000000, 50.000000000000000, 0.0 },
540   { 2.2111422716117463e-25, 1.0000000000000000, 55.000000000000000, 0.0 },
541   { 1.4256320265171041e-27, 1.0000000000000000, 60.000000000000000, 0.0 },
542   { 9.2246195278906156e-30, 1.0000000000000000, 65.000000000000000, 0.0 },
543   { 5.9869736739138550e-32, 1.0000000000000000, 70.000000000000000, 0.0 },
544   { 3.8958329467421912e-34, 1.0000000000000000, 75.000000000000000, 0.0 },
545   { 2.5408531275211705e-36, 1.0000000000000000, 80.000000000000000, 0.0 },
546   { 1.6604444948567571e-38, 1.0000000000000000, 85.000000000000000, 0.0 },
547   { 1.0870134457498335e-40, 1.0000000000000000, 90.000000000000000, 0.0 },
548   { 7.1273442329907240e-43, 1.0000000000000000, 95.000000000000000, 0.0 },
549   { 4.6798537356369088e-45, 1.0000000000000000, 100.00000000000000, 0.0 },
550 };
551 const double toler022 = 2.5000000000000020e-13;
552 
553 // Test data for nu=2.0000000000000000.
554 // max(|f - f_GSL|): 8.6736173798840355e-19 at index 0
555 // max(|f - f_GSL| / |f_GSL|): 2.1559652446630200e-16
556 // mean(f - f_GSL): 4.3368092109689917e-20
557 // variance(f - f_GSL): 1.0419897026230187e-40
558 // stddev(f - f_GSL): 1.0207789685446202e-20
559 const testcase_cyl_bessel_k<double>
560 data023[20] =
561 {
562   { 0.0053089437122234608, 2.0000000000000000, 5.0000000000000000, 0.0 },
563   { 2.1509817006932763e-05, 2.0000000000000000, 10.000000000000000, 0.0 },
564   { 1.1171767065031378e-07, 2.0000000000000000, 15.000000000000000, 0.0 },
565   { 6.3295436122922281e-10, 2.0000000000000000, 20.000000000000000, 0.0 },
566   { 3.7467838080691102e-12, 2.0000000000000000, 25.000000000000000, 0.0 },
567   { 2.2769929632558265e-14, 2.0000000000000000, 30.000000000000000, 0.0 },
568   { 1.4081733110858665e-16, 2.0000000000000000, 35.000000000000000, 0.0 },
569   { 8.8177176978426223e-19, 2.0000000000000000, 40.000000000000000, 0.0 },
570   { 5.5731181045619470e-21, 2.0000000000000000, 45.000000000000000, 0.0 },
571   { 3.5479318388581979e-23, 2.0000000000000000, 50.000000000000000, 0.0 },
572   { 2.2717153918665688e-25, 2.0000000000000000, 55.000000000000000, 0.0 },
573   { 1.4614189081096777e-27, 2.0000000000000000, 60.000000000000000, 0.0 },
574   { 9.4383017680150234e-30, 2.0000000000000000, 65.000000000000000, 0.0 },
575   { 6.1157177279757537e-32, 2.0000000000000000, 70.000000000000000, 0.0 },
576   { 3.9740059241667034e-34, 2.0000000000000000, 75.000000000000000, 0.0 },
577   { 2.5886411706935012e-36, 2.0000000000000000, 80.000000000000000, 0.0 },
578   { 1.6898316402103142e-38, 2.0000000000000000, 85.000000000000000, 0.0 },
579   { 1.1051801100484218e-40, 2.0000000000000000, 90.000000000000000, 0.0 },
580   { 7.2401743221736176e-43, 2.0000000000000000, 95.000000000000000, 0.0 },
581   { 4.7502253038886407e-45, 2.0000000000000000, 100.00000000000000, 0.0 },
582 };
583 const double toler023 = 2.5000000000000020e-13;
584 
585 // Test data for nu=5.0000000000000000.
586 // max(|f - f_GSL|): 6.9388939039072284e-18 at index 0
587 // max(|f - f_GSL| / |f_GSL|): 2.1215788643493719e-16
588 // mean(f - f_GSL): 3.4694602906449006e-19
589 // variance(f - f_GSL): 6.6687837719455956e-39
590 // stddev(f - f_GSL): 8.1662621632822905e-20
591 const testcase_cyl_bessel_k<double>
592 data024[20] =
593 {
594   { 0.032706273712031865, 5.0000000000000000, 5.0000000000000000, 0.0 },
595   { 5.7541849985312275e-05, 5.0000000000000000, 10.000000000000000, 0.0 },
596   { 2.1878261369258224e-07, 5.0000000000000000, 15.000000000000000, 0.0 },
597   { 1.0538660139974233e-09, 5.0000000000000000, 20.000000000000000, 0.0 },
598   { 5.6485921365284157e-12, 5.0000000000000000, 25.000000000000000, 0.0 },
599   { 3.2103335105890266e-14, 5.0000000000000000, 30.000000000000000, 0.0 },
600   { 1.8919208406439644e-16, 5.0000000000000000, 35.000000000000000, 0.0 },
601   { 1.1423814375953188e-18, 5.0000000000000000, 40.000000000000000, 0.0 },
602   { 7.0181216822204101e-21, 5.0000000000000000, 45.000000000000000, 0.0 },
603   { 4.3671822541009859e-23, 5.0000000000000000, 50.000000000000000, 0.0 },
604   { 2.7444967640357869e-25, 5.0000000000000000, 55.000000000000000, 0.0 },
605   { 1.7382232741886986e-27, 5.0000000000000000, 60.000000000000000, 0.0 },
606   { 1.1078474298959669e-29, 5.0000000000000000, 65.000000000000000, 0.0 },
607   { 7.0974537081794416e-32, 5.0000000000000000, 70.000000000000000, 0.0 },
608   { 4.5667269500061064e-34, 5.0000000000000000, 75.000000000000000, 0.0 },
609   { 2.9491764420206146e-36, 5.0000000000000000, 80.000000000000000, 0.0 },
610   { 1.9105685973117463e-38, 5.0000000000000000, 85.000000000000000, 0.0 },
611   { 1.2411034311592645e-40, 5.0000000000000000, 90.000000000000000, 0.0 },
612   { 8.0814211331379146e-43, 5.0000000000000000, 95.000000000000000, 0.0 },
613   { 5.2732561132929503e-45, 5.0000000000000000, 100.00000000000000, 0.0 },
614 };
615 const double toler024 = 2.5000000000000020e-13;
616 
617 // Test data for nu=10.000000000000000.
618 // max(|f - f_GSL|): 5.3290705182007514e-15 at index 0
619 // max(|f - f_GSL| / |f_GSL|): 5.4609173619982130e-16
620 // mean(f - f_GSL): 2.6646441036645034e-16
621 // variance(f - f_GSL): 3.9336998333484790e-33
622 // stddev(f - f_GSL): 6.2719214227766586e-17
623 const testcase_cyl_bessel_k<double>
624 data025[20] =
625 {
626   { 9.7585628291778121, 10.000000000000000, 5.0000000000000000, 0.0 },
627   { 0.0016142553003906698, 10.000000000000000, 10.000000000000000, 0.0 },
628   { 2.2605303776606435e-06, 10.000000000000000, 15.000000000000000, 0.0 },
629   { 6.3162145283215804e-09, 10.000000000000000, 20.000000000000000, 0.0 },
630   { 2.4076769602801233e-11, 10.000000000000000, 25.000000000000000, 0.0 },
631   { 1.0842816942222975e-13, 10.000000000000000, 30.000000000000000, 0.0 },
632   { 5.3976770429777191e-16, 10.000000000000000, 35.000000000000000, 0.0 },
633   { 2.8680293113671932e-18, 10.000000000000000, 40.000000000000000, 0.0 },
634   { 1.5939871900169600e-20, 10.000000000000000, 45.000000000000000, 0.0 },
635   { 9.1509882099879962e-23, 10.000000000000000, 50.000000000000000, 0.0 },
636   { 5.3823846249592858e-25, 10.000000000000000, 55.000000000000000, 0.0 },
637   { 3.2253408700563144e-27, 10.000000000000000, 60.000000000000000, 0.0 },
638   { 1.9613367530075138e-29, 10.000000000000000, 65.000000000000000, 0.0 },
639   { 1.2068471495933484e-31, 10.000000000000000, 70.000000000000000, 0.0 },
640   { 7.4979152649449644e-34, 10.000000000000000, 75.000000000000000, 0.0 },
641   { 4.6957285830490531e-36, 10.000000000000000, 80.000000000000000, 0.0 },
642   { 2.9606323347034079e-38, 10.000000000000000, 85.000000000000000, 0.0 },
643   { 1.8773542561131613e-40, 10.000000000000000, 90.000000000000000, 0.0 },
644   { 1.1962899527846350e-42, 10.000000000000000, 95.000000000000000, 0.0 },
645   { 7.6554279773881006e-45, 10.000000000000000, 100.00000000000000, 0.0 },
646 };
647 const double toler025 = 2.5000000000000020e-13;
648 
649 // Test data for nu=20.000000000000000.
650 // max(|f - f_GSL|): 4.1723251342773438e-07 at index 0
651 // max(|f - f_GSL| / |f_GSL|): 1.2224656515794909e-15
652 // mean(f - f_GSL): 2.0861629934990416e-08
653 // variance(f - f_GSL): 2.4111224573101845e-17
654 // stddev(f - f_GSL): 4.9103181743245358e-09
655 const testcase_cyl_bessel_k<double>
656 data026[20] =
657 {
658   { 482700052.06214869, 20.000000000000000, 5.0000000000000000, 0.0 },
659   { 178.74427820770543, 20.000000000000000, 10.000000000000000, 0.0 },
660   { 0.012141257729731143, 20.000000000000000, 15.000000000000000, 0.0 },
661   { 5.5431116361258155e-06, 20.000000000000000, 20.000000000000000, 0.0 },
662   { 6.3744029330352113e-09, 20.000000000000000, 25.000000000000000, 0.0 },
663   { 1.2304516475442478e-11, 20.000000000000000, 30.000000000000000, 0.0 },
664   { 3.2673136479809018e-14, 20.000000000000000, 35.000000000000000, 0.0 },
665   { 1.0703023799997383e-16, 20.000000000000000, 40.000000000000000, 0.0 },
666   { 4.0549953175660457e-19, 20.000000000000000, 45.000000000000000, 0.0 },
667   { 1.7061483797220349e-21, 20.000000000000000, 50.000000000000000, 0.0 },
668   { 7.7617008115659413e-24, 20.000000000000000, 55.000000000000000, 0.0 },
669   { 3.7482954006874720e-26, 20.000000000000000, 60.000000000000000, 0.0 },
670   { 1.8966880763956576e-28, 20.000000000000000, 65.000000000000000, 0.0 },
671   { 9.9615763479998864e-31, 20.000000000000000, 70.000000000000000, 0.0 },
672   { 5.3921623063091066e-33, 20.000000000000000, 75.000000000000000, 0.0 },
673   { 2.9920407657642266e-35, 20.000000000000000, 80.000000000000000, 0.0 },
674   { 1.6948662723618255e-37, 20.000000000000000, 85.000000000000000, 0.0 },
675   { 9.7689149642963042e-40, 20.000000000000000, 90.000000000000000, 0.0 },
676   { 5.7143603019220823e-42, 20.000000000000000, 95.000000000000000, 0.0 },
677   { 3.3852054148901695e-44, 20.000000000000000, 100.00000000000000, 0.0 },
678 };
679 const double toler026 = 2.5000000000000020e-13;
680 
681 // Test data for nu=50.000000000000000.
682 // max(|f - f_GSL|): 8.6655802749976619e+27 at index 0
683 // max(|f - f_GSL| / |f_GSL|): 2.6684549464729312e-15
684 // mean(f - f_GSL): 4.3327901374988334e+26
685 // variance(f - f_GSL): inf
686 // stddev(f - f_GSL): inf
687 const testcase_cyl_bessel_k<double>
688 data027[20] =
689 {
690   { 3.3943222434301628e+42, 50.000000000000000, 5.0000000000000000, 0.0 },
691   { 2.0613737753892554e+27, 50.000000000000000, 10.000000000000000, 0.0 },
692   { 1.7267736974519188e+18, 50.000000000000000, 15.000000000000000, 0.0 },
693   { 411711209122.01788, 50.000000000000000, 20.000000000000000, 0.0 },
694   { 1972478.7419813874, 50.000000000000000, 25.000000000000000, 0.0 },
695   { 58.770686258007267, 50.000000000000000, 30.000000000000000, 0.0 },
696   { 0.0058659391182535178, 50.000000000000000, 35.000000000000000, 0.0 },
697   { 1.3634854128794101e-06, 50.000000000000000, 40.000000000000000, 0.0 },
698   { 5.8652396362160819e-10, 50.000000000000000, 45.000000000000000, 0.0 },
699   { 4.0060134766400893e-13, 50.000000000000000, 50.000000000000000, 0.0 },
700   { 3.9062324485711016e-16, 50.000000000000000, 55.000000000000000, 0.0 },
701   { 5.0389298085176510e-19, 50.000000000000000, 60.000000000000000, 0.0 },
702   { 8.1305344250110424e-22, 50.000000000000000, 65.000000000000000, 0.0 },
703   { 1.5732816234948991e-24, 50.000000000000000, 70.000000000000000, 0.0 },
704   { 3.5349854993874412e-27, 50.000000000000000, 75.000000000000000, 0.0 },
705   { 8.9940101003189471e-30, 50.000000000000000, 80.000000000000000, 0.0 },
706   { 2.5403205503080723e-32, 50.000000000000000, 85.000000000000000, 0.0 },
707   { 7.8397596486715721e-35, 50.000000000000000, 90.000000000000000, 0.0 },
708   { 2.6098900651329542e-37, 50.000000000000000, 95.000000000000000, 0.0 },
709   { 9.2745226536133242e-40, 50.000000000000000, 100.00000000000000, 0.0 },
710 };
711 const double toler027 = 2.5000000000000020e-13;
712 
713 // Test data for nu=100.00000000000000.
714 // max(|f - f_GSL|): 3.4996011596528191e+101 at index 0
715 // max(|f - f_GSL| / |f_GSL|): 5.1049818083452373e-15
716 // mean(f - f_GSL): 1.7498005798264095e+100
717 // variance(f - f_GSL): inf
718 // stddev(f - f_GSL): inf
719 const testcase_cyl_bessel_k<double>
720 data028[20] =
721 {
722   { 7.0398601930616815e+115, 100.00000000000000, 5.0000000000000000, 0.0 },
723   { 4.5966740842695231e+85, 100.00000000000000, 10.000000000000000, 0.0 },
724   { 8.2565552242653946e+67, 100.00000000000000, 15.000000000000000, 0.0 },
725   { 1.7081356456876041e+55, 100.00000000000000, 20.000000000000000, 0.0 },
726   { 1.9858028128780610e+45, 100.00000000000000, 25.000000000000000, 0.0 },
727   { 1.2131584253026677e+37, 100.00000000000000, 30.000000000000000, 0.0 },
728   { 1.1016916354696688e+30, 100.00000000000000, 35.000000000000000, 0.0 },
729   { 7.0074023297775712e+23, 100.00000000000000, 40.000000000000000, 0.0 },
730   { 1.9236643958470894e+18, 100.00000000000000, 45.000000000000000, 0.0 },
731   { 16394035276269.250, 100.00000000000000, 50.000000000000000, 0.0 },
732   { 343254952.89495474, 100.00000000000000, 55.000000000000000, 0.0 },
733   { 14870.012754946298, 100.00000000000000, 60.000000000000000, 0.0 },
734   { 1.1708099078572216, 100.00000000000000, 65.000000000000000, 0.0 },
735   { 0.00015161193930722313, 100.00000000000000, 70.000000000000000, 0.0 },
736   { 2.9850234381623443e-08, 100.00000000000000, 75.000000000000000, 0.0 },
737   { 8.3928710724649113e-12, 100.00000000000000, 80.000000000000000, 0.0 },
738   { 3.2033435630927732e-15, 100.00000000000000, 85.000000000000000, 0.0 },
739   { 1.5922281431788096e-18, 100.00000000000000, 90.000000000000000, 0.0 },
740   { 9.9589454577674131e-22, 100.00000000000000, 95.000000000000000, 0.0 },
741   { 7.6171296304940831e-25, 100.00000000000000, 100.00000000000000, 0.0 },
742 };
743 const double toler028 = 5.0000000000000039e-13;
744 
745 template<typename Ret, unsigned int Num>
746   void
test(const testcase_cyl_bessel_k<Ret> (& data)[Num],Ret toler)747   test(const testcase_cyl_bessel_k<Ret> (&data)[Num], Ret toler)
748   {
749     bool test __attribute__((unused)) = true;
750     const Ret eps = std::numeric_limits<Ret>::epsilon();
751     Ret max_abs_diff = -Ret(1);
752     Ret max_abs_frac = -Ret(1);
753     unsigned int num_datum = Num;
754     for (unsigned int i = 0; i < num_datum; ++i)
755       {
756 	const Ret f = std::tr1::cyl_bessel_k(data[i].nu, data[i].x);
757 	const Ret f0 = data[i].f0;
758 	const Ret diff = f - f0;
759 	if (std::abs(diff) > max_abs_diff)
760 	  max_abs_diff = std::abs(diff);
761 	if (std::abs(f0) > Ret(10) * eps
762 	 && std::abs(f) > Ret(10) * eps)
763 	  {
764 	    const Ret frac = diff / f0;
765 	    if (std::abs(frac) > max_abs_frac)
766 	      max_abs_frac = std::abs(frac);
767 	  }
768       }
769     VERIFY(max_abs_frac < toler);
770   }
771 
772 int
main()773 main()
774 {
775   test(data007, toler007);
776   test(data008, toler008);
777   test(data009, toler009);
778   test(data010, toler010);
779   test(data011, toler011);
780   test(data012, toler012);
781   test(data013, toler013);
782   test(data014, toler014);
783   test(data015, toler015);
784   test(data016, toler016);
785   test(data017, toler017);
786   test(data018, toler018);
787   test(data019, toler019);
788   test(data020, toler020);
789   test(data021, toler021);
790   test(data022, toler022);
791   test(data023, toler023);
792   test(data024, toler024);
793   test(data025, toler025);
794   test(data026, toler026);
795   test(data027, toler027);
796   test(data028, toler028);
797   return 0;
798 }
799