]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/special_functions/19_sph_bessel/check_value.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / special_functions / 19_sph_bessel / check_value.cc
CommitLineData
196c9e7a 1// { dg-do run { target c++11 } }
2be75957
ESR
2// { dg-options "-D__STDCPP_WANT_MATH_SPEC_FUNCS__" }
3//
8d9254fc 4// Copyright (C) 2016-2020 Free Software Foundation, Inc.
2be75957
ESR
5//
6// This file is part of the GNU ISO C++ Library. This library is free
7// software; you can redistribute it and/or modify it under the
8// terms of the GNU General Public License as published by the
9// Free Software Foundation; either version 3, or (at your option)
10// any later version.
11//
12// This library is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License along
18// with this library; see the file COPYING3. If not see
19// <http://www.gnu.org/licenses/>.
20
21// sph_bessel
22// Compare against values generated by the GNU Scientific Library.
23// The GSL can be found on the web: http://www.gnu.org/software/gsl/
24#include <limits>
25#include <cmath>
26#if defined(__TEST_DEBUG)
27# include <iostream>
28# define VERIFY(A) \
29 if (!(A)) \
30 { \
31 std::cout << "line " << __LINE__ \
32 << " max_abs_frac = " << max_abs_frac \
33 << std::endl; \
34 }
35#else
36# include <testsuite_hooks.h>
37#endif
38#include <specfun_testcase.h>
39
2be75957 40// Test data for n=0.
b4688136
ESR
41// max(|f - f_GSL|): 3.3306690738754696e-16 at index 1
42// max(|f - f_GSL| / |f_GSL|): 2.2927598190254308e-15
43// mean(f - f_GSL): -6.2780468654398733e-18
44// variance(f - f_GSL): 6.0810091607155313e-35
45// stddev(f - f_GSL): 7.7980825596524246e-18
2be75957
ESR
46const testcase_sph_bessel<double>
47data001[21] =
48{
b4688136
ESR
49 { 1.0000000000000000, 0, 0.0000000000000000, 0.0 },
50 { 0.98961583701809175, 0, 0.25000000000000000, 0.0 },
51 { 0.95885107720840601, 0, 0.50000000000000000, 0.0 },
52 { 0.90885168003111227, 0, 0.75000000000000000, 0.0 },
53 { 0.84147098480789650, 0, 1.0000000000000000, 0.0 },
54 { 0.75918769548446896, 0, 1.2500000000000000, 0.0 },
55 { 0.66499665773603633, 0, 1.5000000000000000, 0.0 },
56 { 0.56227768392796396, 0, 1.7500000000000000, 0.0 },
57 { 0.45464871341284080, 0, 2.0000000000000000, 0.0 },
58 { 0.34581030972796500, 0, 2.2500000000000000, 0.0 },
59 { 0.23938885764158258, 0, 2.5000000000000000, 0.0 },
60 { 0.13878581529175696, 0, 2.7500000000000000, 0.0 },
61 { 0.047040002686622402, 0, 3.0000000000000000, 0.0 },
62 { -0.033290810624648733, 0, 3.2500000000000000, 0.0 },
63 { -0.10022377933989138, 0, 3.5000000000000000, 0.0 },
64 { -0.15241635166462503, 0, 3.7500000000000000, 0.0 },
65 { -0.18920062382698205, 0, 4.0000000000000000, 0.0 },
66 { -0.21058573134790204, 0, 4.2500000000000000, 0.0 },
67 { -0.21722891503668823, 0, 4.5000000000000000, 0.0 },
68 { -0.21037742925797431, 0, 4.7500000000000000, 0.0 },
69 { -0.19178485493262770, 0, 5.0000000000000000, 0.0 },
2be75957
ESR
70};
71const double toler001 = 2.5000000000000020e-13;
72
73// Test data for n=1.
b4688136
ESR
74// max(|f - f_GSL|): 3.1918911957973251e-16 at index 1
75// max(|f - f_GSL| / |f_GSL|): 2.8667725070943857e-14
76// mean(f - f_GSL): -1.3578341493508937e-17
77// variance(f - f_GSL): 1.0552183286053657e-35
78// stddev(f - f_GSL): 3.2484124254862801e-18
2be75957
ESR
79const testcase_sph_bessel<double>
80data002[21] =
81{
b4688136
ESR
82 { 0.0000000000000000, 1, 0.0000000000000000, 0.0 },
83 { 0.082813661229788060, 1, 0.25000000000000000, 0.0 },
84 { 0.16253703063606650, 1, 0.50000000000000000, 0.0 },
85 { 0.23621708154305501, 1, 0.75000000000000000, 0.0 },
86 { 0.30116867893975674, 1, 1.0000000000000000, 0.0 },
87 { 0.35509226647136022, 1, 1.2500000000000000, 0.0 },
88 { 0.39617297071222229, 1, 1.5000000000000000, 0.0 },
89 { 0.42315642261568914, 1, 1.7500000000000000, 0.0 },
90 { 0.43539777497999166, 1, 2.0000000000000000, 0.0 },
91 { 0.43288174775586852, 1, 2.2500000000000000, 0.0 },
92 { 0.41621298927540656, 1, 2.5000000000000000, 0.0 },
93 { 0.38657752506335291, 1, 2.7500000000000000, 0.0 },
94 { 0.34567749976235596, 1, 3.0000000000000000, 0.0 },
95 { 0.29564272783258383, 1, 3.2500000000000000, 0.0 },
96 { 0.23892368798597285, 1, 3.5000000000000000, 0.0 },
97 { 0.17817146817998289, 1, 3.7500000000000000, 0.0 },
98 { 0.11611074925915747, 1, 4.0000000000000000, 0.0 },
99 { 0.055412178486091958, 1, 4.2500000000000000, 0.0 },
100 { -0.0014295812457574522, 1, 4.5000000000000000, 0.0 },
101 { -0.052206227820200179, 1, 4.7500000000000000, 0.0 },
102 { -0.095089408079170795, 1, 5.0000000000000000, 0.0 },
2be75957
ESR
103};
104const double toler002 = 2.5000000000000015e-12;
105
106// Test data for n=2.
b4688136 107// max(|f - f_GSL|): 1.6653345369377348e-16 at index 11
2be75957 108// max(|f - f_GSL| / |f_GSL|): 6.5384527054443100e-16
b4688136
ESR
109// mean(f - f_GSL): -5.3693821875472602e-18
110// variance(f - f_GSL): 1.3199534264872259e-34
111// stddev(f - f_GSL): 1.1488922606089858e-17
2be75957
ESR
112const testcase_sph_bessel<double>
113data003[21] =
114{
b4688136
ESR
115 { 0.0000000000000000, 2, 0.0000000000000000, 0.0 },
116 { 0.0041480977393611252, 2, 0.25000000000000000, 0.0 },
117 { 0.016371106607993412, 2, 0.50000000000000000, 0.0 },
118 { 0.036016646141108236, 2, 0.75000000000000000, 0.0 },
119 { 0.062035052011373860, 2, 1.0000000000000000, 0.0 },
120 { 0.093033744046795624, 2, 1.2500000000000000, 0.0 },
121 { 0.12734928368840817, 2, 1.5000000000000000, 0.0 },
122 { 0.16313332627036031, 2, 1.7500000000000000, 0.0 },
123 { 0.19844794905714661, 2, 2.0000000000000000, 0.0 },
124 { 0.23136535394652627, 2, 2.2500000000000000, 0.0 },
125 { 0.26006672948890525, 2, 2.5000000000000000, 0.0 },
126 { 0.28293512114099162, 2, 2.7500000000000000, 0.0 },
127 { 0.29863749707573356, 2, 3.0000000000000000, 0.0 },
128 { 0.30619179016241843, 2, 3.2500000000000000, 0.0 },
129 { 0.30501551189929671, 2, 3.5000000000000000, 0.0 },
130 { 0.29495352620861132, 2, 3.7500000000000000, 0.0 },
131 { 0.27628368577135015, 2, 4.0000000000000000, 0.0 },
132 { 0.24970021027926106, 2, 4.2500000000000000, 0.0 },
133 { 0.21627586087284995, 2, 4.5000000000000000, 0.0 },
134 { 0.17740507484521628, 2, 4.7500000000000000, 0.0 },
135 { 0.13473121008512520, 2, 5.0000000000000000, 0.0 },
2be75957
ESR
136};
137const double toler003 = 2.5000000000000020e-13;
138
139// Test data for n=5.
b4688136 140// max(|f - f_GSL|): 8.3266726846886741e-17 at index 18
2be75957 141// max(|f - f_GSL| / |f_GSL|): 2.7459190669103549e-15
b4688136
ESR
142// mean(f - f_GSL): 2.3688486417034017e-18
143// variance(f - f_GSL): 2.9460080408325262e-37
144// stddev(f - f_GSL): 5.4277141052495815e-19
2be75957
ESR
145const testcase_sph_bessel<double>
146data004[21] =
147{
b4688136
ESR
148 { 0.0000000000000000, 5, 0.0000000000000000, 0.0 },
149 { 9.3719811237268233e-08, 5, 0.25000000000000000, 0.0 },
150 { 2.9774668754574457e-06, 5, 0.50000000000000000, 0.0 },
151 { 2.2339447678335765e-05, 5, 0.75000000000000000, 0.0 },
152 { 9.2561158611258158e-05, 5, 1.0000000000000000, 0.0 },
153 { 0.00027638888920123806, 5, 1.2500000000000000, 0.0 },
154 { 0.00066962059628932467, 5, 1.5000000000000000, 0.0 },
155 { 0.0014021729022572801, 5, 1.7500000000000000, 0.0 },
156 { 0.0026351697702441173, 5, 2.0000000000000000, 0.0 },
157 { 0.0045540034750567553, 5, 2.2500000000000000, 0.0 },
158 { 0.0073576387377689376, 5, 2.5000000000000000, 0.0 },
159 { 0.011244740276407147, 5, 2.7500000000000000, 0.0 },
160 { 0.016397480955999109, 5, 3.0000000000000000, 0.0 },
161 { 0.022964112474845508, 5, 3.2500000000000000, 0.0 },
162 { 0.031041536537391189, 5, 3.5000000000000000, 0.0 },
163 { 0.040659189440948949, 5, 3.7500000000000000, 0.0 },
164 { 0.051765539757363470, 5, 4.0000000000000000, 0.0 },
165 { 0.064218395773425627, 5, 4.2500000000000000, 0.0 },
166 { 0.077780030832892866, 5, 4.5000000000000000, 0.0 },
167 { 0.092117870593729223, 5, 4.7500000000000000, 0.0 },
168 { 0.10681116145650453, 5, 5.0000000000000000, 0.0 },
2be75957
ESR
169};
170const double toler004 = 2.5000000000000020e-13;
171
172// Test data for n=10.
b4688136 173// max(|f - f_GSL|): 8.4025668367626594e-19 at index 18
2be75957 174// max(|f - f_GSL| / |f_GSL|): 6.7232224139500876e-15
b4688136
ESR
175// mean(f - f_GSL): 3.5485202136403188e-20
176// variance(f - f_GSL): 3.7809684768411230e-38
177// stddev(f - f_GSL): 1.9444712589393351e-19
2be75957
ESR
178const testcase_sph_bessel<double>
179data005[21] =
180{
b4688136
ESR
181 { 0.0000000000000000, 10, 0.0000000000000000, 0.0 },
182 { 6.9267427453708468e-17, 10, 0.25000000000000000, 0.0 },
183 { 7.0641239636618740e-14, 10, 0.50000000000000000, 0.0 },
184 { 4.0459307474109287e-12, 10, 0.75000000000000000, 0.0 },
185 { 7.1165526400473096e-11, 10, 1.0000000000000000, 0.0 },
186 { 6.5470739530199939e-10, 10, 1.2500000000000000, 0.0 },
187 { 3.9934406994836296e-09, 10, 1.5000000000000000, 0.0 },
188 { 1.8327719460735247e-08, 10, 1.7500000000000000, 0.0 },
189 { 6.8253008649747220e-08, 10, 2.0000000000000000, 0.0 },
190 { 2.1653870546846626e-07, 10, 2.2500000000000000, 0.0 },
191 { 6.0504362296385381e-07, 10, 2.5000000000000000, 0.0 },
192 { 1.5246485352158441e-06, 10, 2.7500000000000000, 0.0 },
193 { 3.5260038931752543e-06, 10, 3.0000000000000000, 0.0 },
194 { 7.5839040020531456e-06, 10, 3.2500000000000000, 0.0 },
195 { 1.5327786999397103e-05, 10, 3.5000000000000000, 0.0 },
196 { 2.9348811002317664e-05, 10, 3.7500000000000000, 0.0 },
197 { 5.3589865768632612e-05, 10, 4.0000000000000000, 0.0 },
198 { 9.3818602410477989e-05, 10, 4.2500000000000000, 0.0 },
199 { 0.00015817516371455801, 10, 4.5000000000000000, 0.0 },
200 { 0.00025777607369970674, 10, 4.7500000000000000, 0.0 },
201 { 0.00040734424424946052, 10, 5.0000000000000000, 0.0 },
2be75957
ESR
202};
203const double toler005 = 5.0000000000000039e-13;
204
205// Test data for n=20.
b4688136
ESR
206// max(|f - f_GSL|): 4.9275407583725281e-26 at index 20
207// max(|f - f_GSL| / |f_GSL|): 2.3196047253257129e-14
208// mean(f - f_GSL): 6.3234533203992742e-28
209// variance(f - f_GSL): 1.2422274402412017e-52
210// stddev(f - f_GSL): 1.1145525740139860e-26
2be75957
ESR
211const testcase_sph_bessel<double>
212data006[21] =
213{
b4688136
ESR
214 { 0.0000000000000000, 20, 0.0000000000000000, 0.0 },
215 { 6.9307487073399339e-38, 20, 0.25000000000000000, 0.0 },
216 { 7.2515880810153944e-32, 20, 0.50000000000000000, 0.0 },
217 { 2.4025911398834722e-28, 20, 0.75000000000000000, 0.0 },
218 { 7.5377957222368705e-26, 20, 1.0000000000000000, 0.0 },
219 { 6.4953439243593413e-24, 20, 1.2500000000000000, 0.0 },
220 { 2.4703120390884050e-22, 20, 1.5000000000000000, 0.0 },
221 { 5.3404627138297197e-21, 20, 1.7500000000000000, 0.0 },
222 { 7.6326411008876072e-20, 20, 2.0000000000000000, 0.0 },
223 { 7.9496335952781085e-19, 20, 2.2500000000000000, 0.0 },
224 { 6.4488532759578977e-18, 20, 2.5000000000000000, 0.0 },
225 { 4.2725223040880135e-17, 20, 2.7500000000000000, 0.0 },
226 { 2.3942249272752627e-16, 20, 3.0000000000000000, 0.0 },
227 { 1.1654033741499860e-15, 20, 3.2500000000000000, 0.0 },
228 { 5.0303402625237494e-15, 20, 3.5000000000000000, 0.0 },
229 { 1.9572475798118565e-14, 20, 3.7500000000000000, 0.0 },
230 { 6.9559880644906101e-14, 20, 4.0000000000000000, 0.0 },
231 { 2.2825949745670935e-13, 20, 4.2500000000000000, 0.0 },
232 { 6.9781823021792824e-13, 20, 4.5000000000000000, 0.0 },
233 { 2.0024157388665022e-12, 20, 4.7500000000000000, 0.0 },
234 { 5.4277267607932098e-12, 20, 5.0000000000000000, 0.0 },
2be75957
ESR
235};
236const double toler006 = 2.5000000000000015e-12;
237// sph_bessel
238
239// Test data for n=0.
b4688136
ESR
240// max(|f - f_GSL|): 1.0703243846776900e-15 at index 15
241// max(|f - f_GSL| / |f_GSL|): 3.7516988430587603e-13
242// mean(f - f_GSL): -2.6681699178119462e-17
243// variance(f - f_GSL): 1.2529792126711598e-32
244// stddev(f - f_GSL): 1.1193655402374864e-16
2be75957
ESR
245const testcase_sph_bessel<double>
246data007[21] =
247{
b4688136
ESR
248 { 1.0000000000000000, 0, 0.0000000000000000, 0.0 },
249 { -0.19178485493262770, 0, 5.0000000000000000, 0.0 },
250 { -0.054402111088936986, 0, 10.000000000000000, 0.0 },
251 { 0.043352522677141132, 0, 15.000000000000000, 0.0 },
252 { 0.045647262536381385, 0, 20.000000000000000, 0.0 },
253 { -0.0052940700039109216, 0, 25.000000000000000, 0.0 },
254 { -0.032934387469762058, 0, 30.000000000000000, 0.0 },
255 { -0.012233790557032886, 0, 35.000000000000000, 0.0 },
256 { 0.018627829011983722, 0, 40.000000000000000, 0.0 },
257 { 0.018908967211869295, 0, 45.000000000000000, 0.0 },
258 { -0.0052474970740785751, 0, 50.000000000000000, 0.0 },
259 { -0.018177366788338544, 0, 55.000000000000000, 0.0 },
260 { -0.0050801770183702783, 0, 60.000000000000000, 0.0 },
261 { 0.012720441222924667, 0, 65.000000000000000, 0.0 },
262 { 0.011055581165112701, 0, 70.000000000000000, 0.0 },
263 { -0.0051704218054590724, 0, 75.000000000000000, 0.0 },
264 { -0.012423608174042190, 0, 80.000000000000000, 0.0 },
265 { -0.0020714778817480834, 0, 85.000000000000000, 0.0 },
266 { 0.0099332962622284224, 0, 90.000000000000000, 0.0 },
267 { 0.0071922285761696946, 0, 95.000000000000000, 0.0 },
268 { -0.0050636564110975880, 0, 100.00000000000000, 0.0 },
2be75957
ESR
269};
270const double toler007 = 2.5000000000000014e-11;
271
272// Test data for n=1.
b4688136 273// max(|f - f_GSL|): 1.0061396160665481e-15 at index 13
2be75957 274// max(|f - f_GSL| / |f_GSL|): 6.5465850130521528e-13
b4688136
ESR
275// mean(f - f_GSL): 5.2800645800044066e-17
276// variance(f - f_GSL): 2.8606709739566642e-33
277// stddev(f - f_GSL): 5.3485240711402470e-17
2be75957
ESR
278const testcase_sph_bessel<double>
279data008[21] =
280{
b4688136
ESR
281 { 0.0000000000000000, 1, 0.0000000000000000, 0.0 },
282 { -0.095089408079170795, 1, 5.0000000000000000, 0.0 },
283 { 0.078466941798751549, 1, 10.000000000000000, 0.0 },
284 { 0.053536029035730827, 1, 15.000000000000000, 0.0 },
285 { -0.018121739963850528, 1, 20.000000000000000, 0.0 },
286 { -0.039859875274695380, 1, 25.000000000000000, 0.0 },
287 { -0.0062395279119115375, 1, 30.000000000000000, 0.0 },
288 { 0.025470240415270681, 1, 35.000000000000000, 0.0 },
289 { 0.017139147266606140, 1, 40.000000000000000, 0.0 },
290 { -0.011253622702352454, 1, 45.000000000000000, 0.0 },
291 { -0.019404270511323839, 1, 50.000000000000000, 0.0 },
292 { -0.00073280223727807778, 1, 55.000000000000000, 0.0 },
293 { 0.015788880056613101, 1, 60.000000000000000, 0.0 },
294 { 0.0088488352686322581, 1, 65.000000000000000, 0.0 },
295 { -0.0088894803131598157, 1, 70.000000000000000, 0.0 },
296 { -0.012358955887069445, 1, 75.000000000000000, 0.0 },
297 { 0.0012245454458125673, 1, 80.000000000000000, 0.0 },
298 { 0.011556531358968161, 1, 85.000000000000000, 0.0 },
299 { 0.0050889656932377614, 1, 90.000000000000000, 0.0 },
300 { -0.0076103298149331573, 1, 95.000000000000000, 0.0 },
301 { -0.0086738252869878150, 1, 100.00000000000000, 0.0 },
2be75957
ESR
302};
303const double toler008 = 5.0000000000000028e-11;
304
305// Test data for n=2.
b4688136 306// max(|f - f_GSL|): 1.0772632785815972e-15 at index 15
2be75957 307// max(|f - f_GSL| / |f_GSL|): 3.4761702917932150e-13
b4688136
ESR
308// mean(f - f_GSL): 2.9356064536917039e-17
309// variance(f - f_GSL): 1.2041524334573537e-32
310// stddev(f - f_GSL): 1.0973387961141963e-16
2be75957
ESR
311const testcase_sph_bessel<double>
312data009[21] =
313{
b4688136
ESR
314 { 0.0000000000000000, 2, 0.0000000000000000, 0.0 },
315 { 0.13473121008512520, 2, 5.0000000000000000, 0.0 },
316 { 0.077942193628562445, 2, 10.000000000000000, 0.0 },
317 { -0.032645316869994966, 2, 15.000000000000000, 0.0 },
318 { -0.048365523530958965, 2, 20.000000000000000, 0.0 },
319 { 0.00051088497094747614, 2, 25.000000000000000, 0.0 },
320 { 0.032310434678570907, 2, 30.000000000000000, 0.0 },
321 { 0.014416954021198941, 2, 35.000000000000000, 0.0 },
322 { -0.017342392966988262, 2, 40.000000000000000, 0.0 },
323 { -0.019659208725359461, 2, 45.000000000000000, 0.0 },
324 { 0.0040832408433991458, 2, 50.000000000000000, 0.0 },
325 { 0.018137395757214285, 2, 55.000000000000000, 0.0 },
326 { 0.0058696210212009327, 2, 60.000000000000000, 0.0 },
327 { -0.012312033441295490, 2, 65.000000000000000, 0.0 },
328 { -0.011436558892819550, 2, 70.000000000000000, 0.0 },
329 { 0.0046760635699762939, 2, 75.000000000000000, 0.0 },
330 { 0.012469528628260161, 2, 80.000000000000000, 0.0 },
331 { 0.0024793554591234306, 2, 85.000000000000000, 0.0 },
332 { -0.0097636640724538277, 2, 90.000000000000000, 0.0 },
333 { -0.0074325547808517939, 2, 95.000000000000000, 0.0 },
334 { 0.0048034416524879537, 2, 100.00000000000000, 0.0 },
2be75957
ESR
335};
336const double toler009 = 2.5000000000000014e-11;
337
338// Test data for n=5.
b4688136
ESR
339// max(|f - f_GSL|): 9.4629165614534827e-16 at index 14
340// max(|f - f_GSL| / |f_GSL|): 8.4323936619049507e-13
341// mean(f - f_GSL): 4.3853396443294642e-17
342// variance(f - f_GSL): 1.4779322601100139e-33
343// stddev(f - f_GSL): 3.8443884560616579e-17
2be75957
ESR
344const testcase_sph_bessel<double>
345data010[21] =
346{
b4688136
ESR
347 { 0.0000000000000000, 5, 0.0000000000000000, 0.0 },
348 { 0.10681116145650453, 5, 5.0000000000000000, 0.0 },
349 { -0.055534511621452155, 5, 10.000000000000000, 0.0 },
350 { 0.065968007076521951, 5, 15.000000000000000, 0.0 },
351 { 0.016683908063095682, 5, 20.000000000000000, 0.0 },
352 { -0.036117795989722382, 5, 25.000000000000000, 0.0 },
353 { -0.020504008736827489, 5, 30.000000000000000, 0.0 },
354 { 0.018499481206814560, 5, 35.000000000000000, 0.0 },
355 { 0.022448773791044995, 5, 40.000000000000000, 0.0 },
356 { -0.0048552694845020129, 5, 45.000000000000000, 0.0 },
357 { -0.020048300563664877, 5, 50.000000000000000, 0.0 },
358 { -0.0052999924455565742, 5, 55.000000000000000, 0.0 },
359 { 0.014151556281331407, 5, 60.000000000000000, 0.0 },
360 { 0.011354588594416778, 5, 65.000000000000000, 0.0 },
361 { -0.0064983781785323573, 5, 70.000000000000000, 0.0 },
362 { -0.013089909320064257, 5, 75.000000000000000, 0.0 },
363 { -0.00096200450071302446, 5, 80.000000000000000, 0.0 },
364 { 0.011048668899130202, 5, 85.000000000000000, 0.0 },
365 { 0.0065639581708136045, 5, 90.000000000000000, 0.0 },
366 { -0.0064646119368202771, 5, 95.000000000000000, 0.0 },
367 { -0.0092901489349075713, 5, 100.00000000000000, 0.0 },
2be75957
ESR
368};
369const double toler010 = 5.0000000000000028e-11;
370
371// Test data for n=10.
b4688136 372// max(|f - f_GSL|): 1.1999949645069563e-15 at index 13
2be75957 373// max(|f - f_GSL| / |f_GSL|): 2.9533832871668437e-12
b4688136
ESR
374// mean(f - f_GSL): 4.3565566580837178e-17
375// variance(f - f_GSL): 1.4986791255793479e-32
376// stddev(f - f_GSL): 1.2242055079027163e-16
2be75957
ESR
377const testcase_sph_bessel<double>
378data011[21] =
379{
b4688136
ESR
380 { 0.0000000000000000, 10, 0.0000000000000000, 0.0 },
381 { 0.00040734424424946052, 10, 5.0000000000000000, 0.0 },
382 { 0.064605154492564265, 10, 10.000000000000000, 0.0 },
383 { 0.0018969790010883577, 10, 15.000000000000000, 0.0 },
384 { 0.039686698644626366, 10, 20.000000000000000, 0.0 },
385 { -0.036253285601128581, 10, 25.000000000000000, 0.0 },
386 { -0.014529646403897799, 10, 30.000000000000000, 0.0 },
387 { 0.026281264603993857, 10, 35.000000000000000, 0.0 },
388 { 0.013124803182748323, 10, 40.000000000000000, 0.0 },
389 { -0.017600831383728980, 10, 45.000000000000000, 0.0 },
390 { -0.015039221463465955, 10, 50.000000000000000, 0.0 },
391 { 0.0095256289349167390, 10, 55.000000000000000, 0.0 },
392 { 0.015822719394008339, 10, 60.000000000000000, 0.0 },
393 { -0.0019391391708249754, 10, 65.000000000000000, 0.0 },
394 { -0.014293389028395012, 10, 70.000000000000000, 0.0 },
395 { -0.0044210285031696227, 10, 75.000000000000000, 0.0 },
396 { 0.010516146958338813, 10, 80.000000000000000, 0.0 },
397 { 0.0086736275131325726, 10, 85.000000000000000, 0.0 },
398 { -0.0052905066357239331, 10, 90.000000000000000, 0.0 },
399 { -0.010258326955210768, 10, 95.000000000000000, 0.0 },
400 { -0.00019565785971342414, 10, 100.00000000000000, 0.0 },
2be75957
ESR
401};
402const double toler011 = 2.5000000000000017e-10;
403
404// Test data for n=20.
b4688136
ESR
405// max(|f - f_GSL|): 8.5435131191857749e-16 at index 17
406// max(|f - f_GSL| / |f_GSL|): 2.3195586735048320e-13
407// mean(f - f_GSL): 8.6950352153253420e-18
408// variance(f - f_GSL): 1.4336055666601385e-36
409// stddev(f - f_GSL): 1.1973326883786889e-18
2be75957
ESR
410const testcase_sph_bessel<double>
411data012[21] =
412{
b4688136
ESR
413 { 0.0000000000000000, 20, 0.0000000000000000, 0.0 },
414 { 5.4277267607932098e-12, 20, 5.0000000000000000, 0.0 },
415 { 2.3083719613194670e-06, 20, 10.000000000000000, 0.0 },
416 { 0.0015467058510412498, 20, 15.000000000000000, 0.0 },
417 { 0.038324851639805160, 20, 20.000000000000000, 0.0 },
418 { 0.028500071484154645, 20, 25.000000000000000, 0.0 },
419 { -0.014711593353429081, 20, 30.000000000000000, 0.0 },
420 { -0.010797653070264229, 20, 35.000000000000000, 0.0 },
421 { 0.026535391837540293, 20, 40.000000000000000, 0.0 },
422 { -0.011582959134716391, 20, 45.000000000000000, 0.0 },
423 { -0.015785029898269291, 20, 50.000000000000000, 0.0 },
424 { 0.013885519185862741, 20, 55.000000000000000, 0.0 },
425 { 0.011112458964023273, 20, 60.000000000000000, 0.0 },
426 { -0.011938384963927568, 20, 65.000000000000000, 0.0 },
427 { -0.010117695207156904, 20, 70.000000000000000, 0.0 },
428 { 0.0089871214102383232, 20, 75.000000000000000, 0.0 },
429 { 0.010400578884991936, 20, 80.000000000000000, 0.0 },
430 { -0.0055359020656326700, 20, 85.000000000000000, 0.0 },
431 { -0.010639343320787522, 20, 90.000000000000000, 0.0 },
432 { 0.0018051661455979529, 20, 95.000000000000000, 0.0 },
433 { 0.010107671283873054, 20, 100.00000000000000, 0.0 },
2be75957
ESR
434};
435const double toler012 = 2.5000000000000014e-11;
436
437// Test data for n=50.
b4688136
ESR
438// max(|f - f_GSL|): 9.7366776100060726e-16 at index 17
439// max(|f - f_GSL| / |f_GSL|): 2.0733433901400738e-12
440// mean(f - f_GSL): 7.9976407365692512e-18
441// variance(f - f_GSL): 4.9608706858434859e-33
442// stddev(f - f_GSL): 7.0433448629493399e-17
2be75957
ESR
443const testcase_sph_bessel<double>
444data013[21] =
445{
b4688136
ESR
446 { 0.0000000000000000, 50, 0.0000000000000000, 0.0 },
447 { 2.8574793504401518e-46, 50, 5.0000000000000000, 0.0 },
448 { 2.2306960232186480e-31, 50, 10.000000000000000, 0.0 },
449 { 7.6804716640080804e-23, 50, 15.000000000000000, 0.0 },
450 { 5.6500807918725220e-17, 50, 20.000000000000000, 0.0 },
451 { 1.2540416973758975e-12, 50, 25.000000000000000, 0.0 },
452 { 2.6901637185735326e-09, 50, 30.000000000000000, 0.0 },
453 { 1.0167148174422245e-06, 50, 35.000000000000000, 0.0 },
454 { 9.3949174038179069e-05, 50, 40.000000000000000, 0.0 },
455 { 0.0024888927213794557, 50, 45.000000000000000, 0.0 },
456 { 0.018829107369282647, 50, 50.000000000000000, 0.0 },
457 { 0.026373198438145489, 50, 55.000000000000000, 0.0 },
458 { -0.021230978268739001, 50, 60.000000000000000, 0.0 },
459 { 0.016539881802291313, 50, 65.000000000000000, 0.0 },
460 { -0.015985416061436664, 50, 70.000000000000000, 0.0 },
461 { 0.015462548984405590, 50, 75.000000000000000, 0.0 },
462 { -0.010638570118081819, 50, 80.000000000000000, 0.0 },
463 { 0.00046961239784540793, 50, 85.000000000000000, 0.0 },
464 { 0.0096065882189920251, 50, 90.000000000000000, 0.0 },
465 { -0.010613873910261154, 50, 95.000000000000000, 0.0 },
466 { 0.00057971408822774927, 50, 100.00000000000000, 0.0 },
2be75957
ESR
467};
468const double toler013 = 2.5000000000000017e-10;
469
470// Test data for n=100.
b4688136 471// max(|f - f_GSL|): 3.2959746043559335e-17 at index 20
2be75957 472// max(|f - f_GSL| / |f_GSL|): 8.7701893132122237e-14
b4688136
ESR
473// mean(f - f_GSL): -1.3192742355211203e-18
474// variance(f - f_GSL): 5.2558771452351202e-35
475// stddev(f - f_GSL): 7.2497428542225690e-18
2be75957
ESR
476const testcase_sph_bessel<double>
477data014[21] =
478{
b4688136
ESR
479 { 0.0000000000000000, 100, 0.0000000000000000, 0.0 },
480 { 5.5356503033889931e-120, 100, 5.0000000000000000, 0.0 },
481 { 5.8320401820058771e-90, 100, 10.000000000000000, 0.0 },
482 { 1.7406387750766626e-72, 100, 15.000000000000000, 0.0 },
483 { 3.5152711125317012e-60, 100, 20.000000000000000, 0.0 },
484 { 9.8455459353815965e-51, 100, 25.000000000000000, 0.0 },
485 { 4.0888596744301583e-43, 100, 30.000000000000000, 0.0 },
486 { 8.8975854911133939e-37, 100, 35.000000000000000, 0.0 },
487 { 2.1513492547733828e-31, 100, 40.000000000000000, 0.0 },
488 { 9.3673586994539094e-27, 100, 45.000000000000000, 0.0 },
489 { 1.0190122629310471e-22, 100, 50.000000000000000, 0.0 },
490 { 3.4887804977690388e-19, 100, 55.000000000000000, 0.0 },
491 { 4.4442883425555593e-16, 100, 60.000000000000000, 0.0 },
492 { 2.3832619568710723e-13, 100, 65.000000000000000, 0.0 },
493 { 5.8948384175607987e-11, 100, 70.000000000000000, 0.0 },
494 { 7.1884446357022277e-09, 100, 75.000000000000000, 0.0 },
495 { 4.5247964400095002e-07, 100, 80.000000000000000, 0.0 },
496 { 1.5096093228779032e-05, 100, 85.000000000000000, 0.0 },
497 { 0.00026825172647807513, 100, 90.000000000000000, 0.0 },
498 { 0.0024744308520581117, 100, 95.000000000000000, 0.0 },
499 { 0.010880477011438350, 100, 100.00000000000000, 0.0 },
2be75957
ESR
500};
501const double toler014 = 5.0000000000000029e-12;
502
b4688136 503template<typename Ret, unsigned int Num>
2be75957 504 void
b4688136 505 test(const testcase_sph_bessel<Ret> (&data)[Num], Ret toler)
2be75957 506 {
b4688136
ESR
507 bool test __attribute__((unused)) = true;
508 const Ret eps = std::numeric_limits<Ret>::epsilon();
509 Ret max_abs_diff = -Ret(1);
510 Ret max_abs_frac = -Ret(1);
2be75957
ESR
511 unsigned int num_datum = Num;
512 for (unsigned int i = 0; i < num_datum; ++i)
513 {
b4688136
ESR
514 const Ret f = std::sph_bessel(data[i].n, data[i].x);
515 const Ret f0 = data[i].f0;
516 const Ret diff = f - f0;
2be75957
ESR
517 if (std::abs(diff) > max_abs_diff)
518 max_abs_diff = std::abs(diff);
b4688136
ESR
519 if (std::abs(f0) > Ret(10) * eps
520 && std::abs(f) > Ret(10) * eps)
2be75957 521 {
b4688136 522 const Ret frac = diff / f0;
2be75957
ESR
523 if (std::abs(frac) > max_abs_frac)
524 max_abs_frac = std::abs(frac);
525 }
526 }
527 VERIFY(max_abs_frac < toler);
528 }
529
530int
531main()
532{
533 test(data001, toler001);
534 test(data002, toler002);
535 test(data003, toler003);
536 test(data004, toler004);
537 test(data005, toler005);
538 test(data006, toler006);
539 test(data007, toler007);
540 test(data008, toler008);
541 test(data009, toler009);
542 test(data010, toler010);
543 test(data011, toler011);
544 test(data012, toler012);
545 test(data013, toler013);
546 test(data014, toler014);
547 return 0;
548}