1 |
424 |
jeremybenn |
// 2007-02-04 Edward Smith-Rowland <3dw4rd@verizon.net>
|
2 |
|
|
//
|
3 |
|
|
// Copyright (C) 2007, 2009 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.
|
10 |
|
|
//
|
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.
|
15 |
|
|
//
|
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/>.
|
19 |
|
|
|
20 |
|
|
// cyl_bessel_j
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
// Compare against values generated by the GNU Scientific Library.
|
24 |
|
|
// The GSL can be found on the web: http://www.gnu.org/software/gsl/
|
25 |
|
|
|
26 |
|
|
#include <tr1/cmath>
|
27 |
|
|
#if defined(__TEST_DEBUG)
|
28 |
|
|
#include <iostream>
|
29 |
|
|
#define VERIFY(A) \
|
30 |
|
|
if (!(A)) \
|
31 |
|
|
{ \
|
32 |
|
|
std::cout << "line " << __LINE__ \
|
33 |
|
|
<< " max_abs_frac = " << max_abs_frac \
|
34 |
|
|
<< std::endl; \
|
35 |
|
|
}
|
36 |
|
|
#else
|
37 |
|
|
#include <testsuite_hooks.h>
|
38 |
|
|
#endif
|
39 |
|
|
#include "../testcase.h"
|
40 |
|
|
|
41 |
|
|
|
42 |
|
|
// Test data for nu=0.0000000000000000.
|
43 |
|
|
testcase_cyl_bessel_j<double> data001[] = {
|
44 |
|
|
{ 1.0000000000000000, 0.0000000000000000, 0.0000000000000000 },
|
45 |
|
|
{ -0.17759677131433835, 0.0000000000000000, 5.0000000000000000 },
|
46 |
|
|
{ -0.24593576445134832, 0.0000000000000000, 10.000000000000000 },
|
47 |
|
|
{ -0.014224472826780788, 0.0000000000000000, 15.000000000000000 },
|
48 |
|
|
{ 0.16702466434058319, 0.0000000000000000, 20.000000000000000 },
|
49 |
|
|
{ 0.096266783275958140, 0.0000000000000000, 25.000000000000000 },
|
50 |
|
|
{ -0.086367983581040184, 0.0000000000000000, 30.000000000000000 },
|
51 |
|
|
{ -0.12684568275631256, 0.0000000000000000, 35.000000000000000 },
|
52 |
|
|
{ 0.0073668905842372914, 0.0000000000000000, 40.000000000000000 },
|
53 |
|
|
{ 0.11581867067325630, 0.0000000000000000, 45.000000000000000 },
|
54 |
|
|
{ 0.055812327669251746, 0.0000000000000000, 50.000000000000000 },
|
55 |
|
|
{ -0.074548302648236808, 0.0000000000000000, 55.000000000000000 },
|
56 |
|
|
{ -0.091471804089061873, 0.0000000000000000, 60.000000000000000 },
|
57 |
|
|
{ 0.018687343227677920, 0.0000000000000000, 65.000000000000000 },
|
58 |
|
|
{ 0.094908726483013517, 0.0000000000000000, 70.000000000000000 },
|
59 |
|
|
{ 0.034643913805097029, 0.0000000000000000, 75.000000000000000 },
|
60 |
|
|
{ -0.069742165512210061, 0.0000000000000000, 80.000000000000000 },
|
61 |
|
|
{ -0.070940394796273301, 0.0000000000000000, 85.000000000000000 },
|
62 |
|
|
{ 0.026630016699969568, 0.0000000000000000, 90.000000000000000 },
|
63 |
|
|
{ 0.081811967783384149, 0.0000000000000000, 95.000000000000000 },
|
64 |
|
|
{ 0.019985850304223264, 0.0000000000000000, 100.00000000000000 },
|
65 |
|
|
};
|
66 |
|
|
|
67 |
|
|
// Test function for nu=0.0000000000000000.
|
68 |
|
|
template <typename Tp>
|
69 |
|
|
void test001()
|
70 |
|
|
{
|
71 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
72 |
|
|
Tp max_abs_diff = -Tp(1);
|
73 |
|
|
Tp max_abs_frac = -Tp(1);
|
74 |
|
|
unsigned int num_datum = sizeof(data001)
|
75 |
|
|
/ sizeof(testcase_cyl_bessel_j<double>);
|
76 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
77 |
|
|
{
|
78 |
|
|
const Tp f = std::tr1::cyl_bessel_j(Tp(data001[i].nu), Tp(data001[i].x));
|
79 |
|
|
const Tp f0 = data001[i].f0;
|
80 |
|
|
const Tp diff = f - f0;
|
81 |
|
|
if (std::abs(diff) > max_abs_diff)
|
82 |
|
|
max_abs_diff = std::abs(diff);
|
83 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
84 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
85 |
|
|
{
|
86 |
|
|
const Tp frac = diff / f0;
|
87 |
|
|
if (std::abs(frac) > max_abs_frac)
|
88 |
|
|
max_abs_frac = std::abs(frac);
|
89 |
|
|
}
|
90 |
|
|
}
|
91 |
|
|
VERIFY(max_abs_frac < Tp(2.5000000000000014e-11));
|
92 |
|
|
}
|
93 |
|
|
|
94 |
|
|
// Test data for nu=0.33333333333333331.
|
95 |
|
|
testcase_cyl_bessel_j<double> data002[] = {
|
96 |
|
|
{ 0.0000000000000000, 0.33333333333333331, 0.0000000000000000 },
|
97 |
|
|
{ -0.30642046380026405, 0.33333333333333331, 5.0000000000000000 },
|
98 |
|
|
{ -0.18614516704869569, 0.33333333333333331, 10.000000000000000 },
|
99 |
|
|
{ 0.089740004221152581, 0.33333333333333331, 15.000000000000000 },
|
100 |
|
|
{ 0.17606058001293898, 0.33333333333333331, 20.000000000000000 },
|
101 |
|
|
{ 0.020097162141383202, 0.33333333333333331, 25.000000000000000 },
|
102 |
|
|
{ -0.13334053387426156, 0.33333333333333331, 30.000000000000000 },
|
103 |
|
|
{ -0.087118009397765442, 0.33333333333333331, 35.000000000000000 },
|
104 |
|
|
{ 0.069202942818858165, 0.33333333333333331, 40.000000000000000 },
|
105 |
|
|
{ 0.11387616964518317, 0.33333333333333331, 45.000000000000000 },
|
106 |
|
|
{ -0.00057226680771807741, 0.33333333333333331, 50.000000000000000 },
|
107 |
|
|
{ -0.10331600929280821, 0.33333333333333331, 55.000000000000000 },
|
108 |
|
|
{ -0.055618147270528023, 0.33333333333333331, 60.000000000000000 },
|
109 |
|
|
{ 0.064711954014113920, 0.33333333333333331, 65.000000000000000 },
|
110 |
|
|
{ 0.086879926462481619, 0.33333333333333331, 70.000000000000000 },
|
111 |
|
|
{ -0.012614484229891070, 0.33333333333333331, 75.000000000000000 },
|
112 |
|
|
{ -0.088199784400034537, 0.33333333333333331, 80.000000000000000 },
|
113 |
|
|
{ -0.036703611076564557, 0.33333333333333331, 85.000000000000000 },
|
114 |
|
|
{ 0.062916286828779533, 0.33333333333333331, 90.000000000000000 },
|
115 |
|
|
{ 0.069465244416806071, 0.33333333333333331, 95.000000000000000 },
|
116 |
|
|
{ -0.021271244853702295, 0.33333333333333331, 100.00000000000000 },
|
117 |
|
|
};
|
118 |
|
|
|
119 |
|
|
// Test function for nu=0.33333333333333331.
|
120 |
|
|
template <typename Tp>
|
121 |
|
|
void test002()
|
122 |
|
|
{
|
123 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
124 |
|
|
Tp max_abs_diff = -Tp(1);
|
125 |
|
|
Tp max_abs_frac = -Tp(1);
|
126 |
|
|
unsigned int num_datum = sizeof(data002)
|
127 |
|
|
/ sizeof(testcase_cyl_bessel_j<double>);
|
128 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
129 |
|
|
{
|
130 |
|
|
const Tp f = std::tr1::cyl_bessel_j(Tp(data002[i].nu), Tp(data002[i].x));
|
131 |
|
|
const Tp f0 = data002[i].f0;
|
132 |
|
|
const Tp diff = f - f0;
|
133 |
|
|
if (std::abs(diff) > max_abs_diff)
|
134 |
|
|
max_abs_diff = std::abs(diff);
|
135 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
136 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
137 |
|
|
{
|
138 |
|
|
const Tp frac = diff / f0;
|
139 |
|
|
if (std::abs(frac) > max_abs_frac)
|
140 |
|
|
max_abs_frac = std::abs(frac);
|
141 |
|
|
}
|
142 |
|
|
}
|
143 |
|
|
VERIFY(max_abs_frac < Tp(2.5000000000000017e-10));
|
144 |
|
|
}
|
145 |
|
|
|
146 |
|
|
// Test data for nu=0.50000000000000000.
|
147 |
|
|
testcase_cyl_bessel_j<double> data003[] = {
|
148 |
|
|
{ 0.0000000000000000, 0.50000000000000000, 0.0000000000000000 },
|
149 |
|
|
{ -0.34216798479816180, 0.50000000000000000, 5.0000000000000000 },
|
150 |
|
|
{ -0.13726373575505049, 0.50000000000000000, 10.000000000000000 },
|
151 |
|
|
{ 0.13396768882243942, 0.50000000000000000, 15.000000000000000 },
|
152 |
|
|
{ 0.16288076385502981, 0.50000000000000000, 20.000000000000000 },
|
153 |
|
|
{ -0.021120283599650416, 0.50000000000000000, 25.000000000000000 },
|
154 |
|
|
{ -0.14392965337039987, 0.50000000000000000, 30.000000000000000 },
|
155 |
|
|
{ -0.057747757589458860, 0.50000000000000000, 35.000000000000000 },
|
156 |
|
|
{ 0.094000962389533579, 0.50000000000000000, 40.000000000000000 },
|
157 |
|
|
{ 0.10120783324271412, 0.50000000000000000, 45.000000000000000 },
|
158 |
|
|
{ -0.029605831888924662, 0.50000000000000000, 50.000000000000000 },
|
159 |
|
|
{ -0.10756039213265806, 0.50000000000000000, 55.000000000000000 },
|
160 |
|
|
{ -0.031397461182520445, 0.50000000000000000, 60.000000000000000 },
|
161 |
|
|
{ 0.081827430775628568, 0.50000000000000000, 65.000000000000000 },
|
162 |
|
|
{ 0.073802429539054637, 0.50000000000000000, 70.000000000000000 },
|
163 |
|
|
{ -0.035727009681702594, 0.50000000000000000, 75.000000000000000 },
|
164 |
|
|
{ -0.088661035811765446, 0.50000000000000000, 80.000000000000000 },
|
165 |
|
|
{ -0.015238065106312407, 0.50000000000000000, 85.000000000000000 },
|
166 |
|
|
{ 0.075189068550269425, 0.50000000000000000, 90.000000000000000 },
|
167 |
|
|
{ 0.055932643481494140, 0.50000000000000000, 95.000000000000000 },
|
168 |
|
|
{ -0.040402132716252113, 0.50000000000000000, 100.00000000000000 },
|
169 |
|
|
};
|
170 |
|
|
|
171 |
|
|
// Test function for nu=0.50000000000000000.
|
172 |
|
|
template <typename Tp>
|
173 |
|
|
void test003()
|
174 |
|
|
{
|
175 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
176 |
|
|
Tp max_abs_diff = -Tp(1);
|
177 |
|
|
Tp max_abs_frac = -Tp(1);
|
178 |
|
|
unsigned int num_datum = sizeof(data003)
|
179 |
|
|
/ sizeof(testcase_cyl_bessel_j<double>);
|
180 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
181 |
|
|
{
|
182 |
|
|
const Tp f = std::tr1::cyl_bessel_j(Tp(data003[i].nu), Tp(data003[i].x));
|
183 |
|
|
const Tp f0 = data003[i].f0;
|
184 |
|
|
const Tp diff = f - f0;
|
185 |
|
|
if (std::abs(diff) > max_abs_diff)
|
186 |
|
|
max_abs_diff = std::abs(diff);
|
187 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
188 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
189 |
|
|
{
|
190 |
|
|
const Tp frac = diff / f0;
|
191 |
|
|
if (std::abs(frac) > max_abs_frac)
|
192 |
|
|
max_abs_frac = std::abs(frac);
|
193 |
|
|
}
|
194 |
|
|
}
|
195 |
|
|
VERIFY(max_abs_frac < Tp(2.5000000000000014e-11));
|
196 |
|
|
}
|
197 |
|
|
|
198 |
|
|
// Test data for nu=0.66666666666666663.
|
199 |
|
|
testcase_cyl_bessel_j<double> data004[] = {
|
200 |
|
|
{ 0.0000000000000000, 0.66666666666666663, 0.0000000000000000 },
|
201 |
|
|
{ -0.35712533549168879, 0.66666666666666663, 5.0000000000000000 },
|
202 |
|
|
{ -0.080149603304315822, 0.66666666666666663, 10.000000000000000 },
|
203 |
|
|
{ 0.16918875175798076, 0.66666666666666663, 15.000000000000000 },
|
204 |
|
|
{ 0.13904826122116526, 0.66666666666666663, 20.000000000000000 },
|
205 |
|
|
{ -0.060770629698497579, 0.66666666666666663, 25.000000000000000 },
|
206 |
|
|
{ -0.14489851974205059, 0.66666666666666663, 30.000000000000000 },
|
207 |
|
|
{ -0.024604880159644467, 0.66666666666666663, 35.000000000000000 },
|
208 |
|
|
{ 0.11243936464912015, 0.66666666666666663, 40.000000000000000 },
|
209 |
|
|
{ 0.081776275512525379, 0.66666666666666663, 45.000000000000000 },
|
210 |
|
|
{ -0.056589908749367770, 0.66666666666666663, 50.000000000000000 },
|
211 |
|
|
{ -0.10455814523765933, 0.66666666666666663, 55.000000000000000 },
|
212 |
|
|
{ -0.0051030148548608109, 0.66666666666666663, 60.000000000000000 },
|
213 |
|
|
{ 0.093398227061639250, 0.66666666666666663, 65.000000000000000 },
|
214 |
|
|
{ 0.055763883611864899, 0.66666666666666663, 70.000000000000000 },
|
215 |
|
|
{ -0.056395322915757343, 0.66666666666666663, 75.000000000000000 },
|
216 |
|
|
{ -0.083131347805783087, 0.66666666666666663, 80.000000000000000 },
|
217 |
|
|
{ 0.0072315397874096309, 0.66666666666666663, 85.000000000000000 },
|
218 |
|
|
{ 0.082362798520905264, 0.66666666666666663, 90.000000000000000 },
|
219 |
|
|
{ 0.038630504403446168, 0.66666666666666663, 95.000000000000000 },
|
220 |
|
|
{ -0.056778819380529706, 0.66666666666666663, 100.00000000000000 },
|
221 |
|
|
};
|
222 |
|
|
|
223 |
|
|
// Test function for nu=0.66666666666666663.
|
224 |
|
|
template <typename Tp>
|
225 |
|
|
void test004()
|
226 |
|
|
{
|
227 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
228 |
|
|
Tp max_abs_diff = -Tp(1);
|
229 |
|
|
Tp max_abs_frac = -Tp(1);
|
230 |
|
|
unsigned int num_datum = sizeof(data004)
|
231 |
|
|
/ sizeof(testcase_cyl_bessel_j<double>);
|
232 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
233 |
|
|
{
|
234 |
|
|
const Tp f = std::tr1::cyl_bessel_j(Tp(data004[i].nu), Tp(data004[i].x));
|
235 |
|
|
const Tp f0 = data004[i].f0;
|
236 |
|
|
const Tp diff = f - f0;
|
237 |
|
|
if (std::abs(diff) > max_abs_diff)
|
238 |
|
|
max_abs_diff = std::abs(diff);
|
239 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
240 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
241 |
|
|
{
|
242 |
|
|
const Tp frac = diff / f0;
|
243 |
|
|
if (std::abs(frac) > max_abs_frac)
|
244 |
|
|
max_abs_frac = std::abs(frac);
|
245 |
|
|
}
|
246 |
|
|
}
|
247 |
|
|
VERIFY(max_abs_frac < Tp(1.0000000000000006e-10));
|
248 |
|
|
}
|
249 |
|
|
|
250 |
|
|
// Test data for nu=1.0000000000000000.
|
251 |
|
|
testcase_cyl_bessel_j<double> data005[] = {
|
252 |
|
|
{ 0.0000000000000000, 1.0000000000000000, 0.0000000000000000 },
|
253 |
|
|
{ -0.32757913759146523, 1.0000000000000000, 5.0000000000000000 },
|
254 |
|
|
{ 0.043472746168861369, 1.0000000000000000, 10.000000000000000 },
|
255 |
|
|
{ 0.20510403861352278, 1.0000000000000000, 15.000000000000000 },
|
256 |
|
|
{ 0.066833124175850092, 1.0000000000000000, 20.000000000000000 },
|
257 |
|
|
{ -0.12535024958028987, 1.0000000000000000, 25.000000000000000 },
|
258 |
|
|
{ -0.11875106261662292, 1.0000000000000000, 30.000000000000000 },
|
259 |
|
|
{ 0.043990942179625556, 1.0000000000000000, 35.000000000000000 },
|
260 |
|
|
{ 0.12603831803758497, 1.0000000000000000, 40.000000000000000 },
|
261 |
|
|
{ 0.028348854376424548, 1.0000000000000000, 45.000000000000000 },
|
262 |
|
|
{ -0.097511828125175157, 1.0000000000000000, 50.000000000000000 },
|
263 |
|
|
{ -0.078250038308684655, 1.0000000000000000, 55.000000000000000 },
|
264 |
|
|
{ 0.046598383758166398, 1.0000000000000000, 60.000000000000000 },
|
265 |
|
|
{ 0.097330172226126929, 1.0000000000000000, 65.000000000000000 },
|
266 |
|
|
{ 0.0099877887848384625, 1.0000000000000000, 70.000000000000000 },
|
267 |
|
|
{ -0.085139995044829109, 1.0000000000000000, 75.000000000000000 },
|
268 |
|
|
{ -0.056057296675712610, 1.0000000000000000, 80.000000000000000 },
|
269 |
|
|
{ 0.049151460334891116, 1.0000000000000000, 85.000000000000000 },
|
270 |
|
|
{ 0.079925646708868064, 1.0000000000000000, 90.000000000000000 },
|
271 |
|
|
{ -0.0023925612997268684, 1.0000000000000000, 95.000000000000000 },
|
272 |
|
|
{ -0.077145352014112142, 1.0000000000000000, 100.00000000000000 },
|
273 |
|
|
};
|
274 |
|
|
|
275 |
|
|
// Test function for nu=1.0000000000000000.
|
276 |
|
|
template <typename Tp>
|
277 |
|
|
void test005()
|
278 |
|
|
{
|
279 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
280 |
|
|
Tp max_abs_diff = -Tp(1);
|
281 |
|
|
Tp max_abs_frac = -Tp(1);
|
282 |
|
|
unsigned int num_datum = sizeof(data005)
|
283 |
|
|
/ sizeof(testcase_cyl_bessel_j<double>);
|
284 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
285 |
|
|
{
|
286 |
|
|
const Tp f = std::tr1::cyl_bessel_j(Tp(data005[i].nu), Tp(data005[i].x));
|
287 |
|
|
const Tp f0 = data005[i].f0;
|
288 |
|
|
const Tp diff = f - f0;
|
289 |
|
|
if (std::abs(diff) > max_abs_diff)
|
290 |
|
|
max_abs_diff = std::abs(diff);
|
291 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
292 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
293 |
|
|
{
|
294 |
|
|
const Tp frac = diff / f0;
|
295 |
|
|
if (std::abs(frac) > max_abs_frac)
|
296 |
|
|
max_abs_frac = std::abs(frac);
|
297 |
|
|
}
|
298 |
|
|
}
|
299 |
|
|
VERIFY(max_abs_frac < Tp(1.0000000000000006e-10));
|
300 |
|
|
}
|
301 |
|
|
|
302 |
|
|
// Test data for nu=2.0000000000000000.
|
303 |
|
|
testcase_cyl_bessel_j<double> data006[] = {
|
304 |
|
|
{ 0.0000000000000000, 2.0000000000000000, 0.0000000000000000 },
|
305 |
|
|
{ 0.046565116277751971, 2.0000000000000000, 5.0000000000000000 },
|
306 |
|
|
{ 0.25463031368512062, 2.0000000000000000, 10.000000000000000 },
|
307 |
|
|
{ 0.041571677975250479, 2.0000000000000000, 15.000000000000000 },
|
308 |
|
|
{ -0.16034135192299817, 2.0000000000000000, 20.000000000000000 },
|
309 |
|
|
{ -0.10629480324238134, 2.0000000000000000, 25.000000000000000 },
|
310 |
|
|
{ 0.078451246073265340, 2.0000000000000000, 30.000000000000000 },
|
311 |
|
|
{ 0.12935945088086262, 2.0000000000000000, 35.000000000000000 },
|
312 |
|
|
{ -0.0010649746823580893, 2.0000000000000000, 40.000000000000000 },
|
313 |
|
|
{ -0.11455872158985966, 2.0000000000000000, 45.000000000000000 },
|
314 |
|
|
{ -0.059712800794258801, 2.0000000000000000, 50.000000000000000 },
|
315 |
|
|
{ 0.071702846709739212, 2.0000000000000000, 55.000000000000000 },
|
316 |
|
|
{ 0.093025083547667448, 2.0000000000000000, 60.000000000000000 },
|
317 |
|
|
{ -0.015692568697643280, 2.0000000000000000, 65.000000000000000 },
|
318 |
|
|
{ -0.094623361089160987, 2.0000000000000000, 70.000000000000000 },
|
319 |
|
|
{ -0.036914313672959186, 2.0000000000000000, 75.000000000000000 },
|
320 |
|
|
{ 0.068340733095317227, 2.0000000000000000, 80.000000000000000 },
|
321 |
|
|
{ 0.072096899745329499, 2.0000000000000000, 85.000000000000000 },
|
322 |
|
|
{ -0.024853891217550262, 2.0000000000000000, 90.000000000000000 },
|
323 |
|
|
{ -0.081862337494957346, 2.0000000000000000, 95.000000000000000 },
|
324 |
|
|
{ -0.021528757344505392, 2.0000000000000000, 100.00000000000000 },
|
325 |
|
|
};
|
326 |
|
|
|
327 |
|
|
// Test function for nu=2.0000000000000000.
|
328 |
|
|
template <typename Tp>
|
329 |
|
|
void test006()
|
330 |
|
|
{
|
331 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
332 |
|
|
Tp max_abs_diff = -Tp(1);
|
333 |
|
|
Tp max_abs_frac = -Tp(1);
|
334 |
|
|
unsigned int num_datum = sizeof(data006)
|
335 |
|
|
/ sizeof(testcase_cyl_bessel_j<double>);
|
336 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
337 |
|
|
{
|
338 |
|
|
const Tp f = std::tr1::cyl_bessel_j(Tp(data006[i].nu), Tp(data006[i].x));
|
339 |
|
|
const Tp f0 = data006[i].f0;
|
340 |
|
|
const Tp diff = f - f0;
|
341 |
|
|
if (std::abs(diff) > max_abs_diff)
|
342 |
|
|
max_abs_diff = std::abs(diff);
|
343 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
344 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
345 |
|
|
{
|
346 |
|
|
const Tp frac = diff / f0;
|
347 |
|
|
if (std::abs(frac) > max_abs_frac)
|
348 |
|
|
max_abs_frac = std::abs(frac);
|
349 |
|
|
}
|
350 |
|
|
}
|
351 |
|
|
VERIFY(max_abs_frac < Tp(1.0000000000000006e-10));
|
352 |
|
|
}
|
353 |
|
|
|
354 |
|
|
// Test data for nu=5.0000000000000000.
|
355 |
|
|
testcase_cyl_bessel_j<double> data007[] = {
|
356 |
|
|
{ 0.0000000000000000, 5.0000000000000000, 0.0000000000000000 },
|
357 |
|
|
{ 0.26114054612017007, 5.0000000000000000, 5.0000000000000000 },
|
358 |
|
|
{ -0.23406152818679365, 5.0000000000000000, 10.000000000000000 },
|
359 |
|
|
{ 0.13045613456502966, 5.0000000000000000, 15.000000000000000 },
|
360 |
|
|
{ 0.15116976798239504, 5.0000000000000000, 20.000000000000000 },
|
361 |
|
|
{ -0.066007995398423044, 5.0000000000000000, 25.000000000000000 },
|
362 |
|
|
{ -0.14324029551207709, 5.0000000000000000, 30.000000000000000 },
|
363 |
|
|
{ -0.0015053072953907080, 5.0000000000000000, 35.000000000000000 },
|
364 |
|
|
{ 0.12257346597711774, 5.0000000000000000, 40.000000000000000 },
|
365 |
|
|
{ 0.057984499200954144, 5.0000000000000000, 45.000000000000000 },
|
366 |
|
|
{ -0.081400247696569658, 5.0000000000000000, 50.000000000000000 },
|
367 |
|
|
{ -0.092569895786432710, 5.0000000000000000, 55.000000000000000 },
|
368 |
|
|
{ 0.027454744228344184, 5.0000000000000000, 60.000000000000000 },
|
369 |
|
|
{ 0.099110527701539039, 5.0000000000000000, 65.000000000000000 },
|
370 |
|
|
{ 0.026058129823895274, 5.0000000000000000, 70.000000000000000 },
|
371 |
|
|
{ -0.078523977013751398, 5.0000000000000000, 75.000000000000000 },
|
372 |
|
|
{ -0.065862349140031654, 5.0000000000000000, 80.000000000000000 },
|
373 |
|
|
{ 0.038669072284680923, 5.0000000000000000, 85.000000000000000 },
|
374 |
|
|
{ 0.082759319528415129, 5.0000000000000000, 90.000000000000000 },
|
375 |
|
|
{ 0.0079423372702472905, 5.0000000000000000, 95.000000000000000 },
|
376 |
|
|
{ -0.074195736964513911, 5.0000000000000000, 100.00000000000000 },
|
377 |
|
|
};
|
378 |
|
|
|
379 |
|
|
// Test function for nu=5.0000000000000000.
|
380 |
|
|
template <typename Tp>
|
381 |
|
|
void test007()
|
382 |
|
|
{
|
383 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
384 |
|
|
Tp max_abs_diff = -Tp(1);
|
385 |
|
|
Tp max_abs_frac = -Tp(1);
|
386 |
|
|
unsigned int num_datum = sizeof(data007)
|
387 |
|
|
/ sizeof(testcase_cyl_bessel_j<double>);
|
388 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
389 |
|
|
{
|
390 |
|
|
const Tp f = std::tr1::cyl_bessel_j(Tp(data007[i].nu), Tp(data007[i].x));
|
391 |
|
|
const Tp f0 = data007[i].f0;
|
392 |
|
|
const Tp diff = f - f0;
|
393 |
|
|
if (std::abs(diff) > max_abs_diff)
|
394 |
|
|
max_abs_diff = std::abs(diff);
|
395 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
396 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
397 |
|
|
{
|
398 |
|
|
const Tp frac = diff / f0;
|
399 |
|
|
if (std::abs(frac) > max_abs_frac)
|
400 |
|
|
max_abs_frac = std::abs(frac);
|
401 |
|
|
}
|
402 |
|
|
}
|
403 |
|
|
VERIFY(max_abs_frac < Tp(5.0000000000000028e-11));
|
404 |
|
|
}
|
405 |
|
|
|
406 |
|
|
// Test data for nu=10.000000000000000.
|
407 |
|
|
testcase_cyl_bessel_j<double> data008[] = {
|
408 |
|
|
{ 0.0000000000000000, 10.000000000000000, 0.0000000000000000 },
|
409 |
|
|
{ 0.0014678026473104744, 10.000000000000000, 5.0000000000000000 },
|
410 |
|
|
{ 0.20748610663335865, 10.000000000000000, 10.000000000000000 },
|
411 |
|
|
{ -0.090071811047659045, 10.000000000000000, 15.000000000000000 },
|
412 |
|
|
{ 0.18648255802394512, 10.000000000000000, 20.000000000000000 },
|
413 |
|
|
{ -0.075179843948523270, 10.000000000000000, 25.000000000000000 },
|
414 |
|
|
{ -0.12987689399858882, 10.000000000000000, 30.000000000000000 },
|
415 |
|
|
{ 0.063546391343962852, 10.000000000000000, 35.000000000000000 },
|
416 |
|
|
{ 0.11938336278226093, 10.000000000000000, 40.000000000000000 },
|
417 |
|
|
{ -0.026971402475010734, 10.000000000000000, 45.000000000000000 },
|
418 |
|
|
{ -0.11384784914946940, 10.000000000000000, 50.000000000000000 },
|
419 |
|
|
{ -0.015773790303746010, 10.000000000000000, 55.000000000000000 },
|
420 |
|
|
{ 0.097177143328071106, 10.000000000000000, 60.000000000000000 },
|
421 |
|
|
{ 0.054617389951112157, 10.000000000000000, 65.000000000000000 },
|
422 |
|
|
{ -0.065870338561951874, 10.000000000000000, 70.000000000000000 },
|
423 |
|
|
{ -0.080417867891894437, 10.000000000000000, 75.000000000000000 },
|
424 |
|
|
{ 0.024043850978184754, 10.000000000000000, 80.000000000000000 },
|
425 |
|
|
{ 0.086824832700067869, 10.000000000000000, 85.000000000000000 },
|
426 |
|
|
{ 0.019554748856312278, 10.000000000000000, 90.000000000000000 },
|
427 |
|
|
{ -0.072341598669443757, 10.000000000000000, 95.000000000000000 },
|
428 |
|
|
{ -0.054732176935472103, 10.000000000000000, 100.00000000000000 },
|
429 |
|
|
};
|
430 |
|
|
|
431 |
|
|
// Test function for nu=10.000000000000000.
|
432 |
|
|
template <typename Tp>
|
433 |
|
|
void test008()
|
434 |
|
|
{
|
435 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
436 |
|
|
Tp max_abs_diff = -Tp(1);
|
437 |
|
|
Tp max_abs_frac = -Tp(1);
|
438 |
|
|
unsigned int num_datum = sizeof(data008)
|
439 |
|
|
/ sizeof(testcase_cyl_bessel_j<double>);
|
440 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
441 |
|
|
{
|
442 |
|
|
const Tp f = std::tr1::cyl_bessel_j(Tp(data008[i].nu), Tp(data008[i].x));
|
443 |
|
|
const Tp f0 = data008[i].f0;
|
444 |
|
|
const Tp diff = f - f0;
|
445 |
|
|
if (std::abs(diff) > max_abs_diff)
|
446 |
|
|
max_abs_diff = std::abs(diff);
|
447 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
448 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
449 |
|
|
{
|
450 |
|
|
const Tp frac = diff / f0;
|
451 |
|
|
if (std::abs(frac) > max_abs_frac)
|
452 |
|
|
max_abs_frac = std::abs(frac);
|
453 |
|
|
}
|
454 |
|
|
}
|
455 |
|
|
VERIFY(max_abs_frac < Tp(2.5000000000000014e-11));
|
456 |
|
|
}
|
457 |
|
|
|
458 |
|
|
// Test data for nu=20.000000000000000.
|
459 |
|
|
testcase_cyl_bessel_j<double> data009[] = {
|
460 |
|
|
{ 0.0000000000000000, 20.000000000000000, 0.0000000000000000 },
|
461 |
|
|
{ 2.7703300521289426e-11, 20.000000000000000, 5.0000000000000000 },
|
462 |
|
|
{ 1.1513369247813403e-05, 20.000000000000000, 10.000000000000000 },
|
463 |
|
|
{ 0.0073602340792234882, 20.000000000000000, 15.000000000000000 },
|
464 |
|
|
{ 0.16474777377532657, 20.000000000000000, 20.000000000000000 },
|
465 |
|
|
{ 0.051994049228303287, 20.000000000000000, 25.000000000000000 },
|
466 |
|
|
{ 0.0048310199934041105, 20.000000000000000, 30.000000000000000 },
|
467 |
|
|
{ -0.10927417397178038, 20.000000000000000, 35.000000000000000 },
|
468 |
|
|
{ 0.12779393355084886, 20.000000000000000, 40.000000000000000 },
|
469 |
|
|
{ 0.0047633437900312841, 20.000000000000000, 45.000000000000000 },
|
470 |
|
|
{ -0.11670435275957974, 20.000000000000000, 50.000000000000000 },
|
471 |
|
|
{ 0.025389204574566695, 20.000000000000000, 55.000000000000000 },
|
472 |
|
|
{ 0.10266020557876331, 20.000000000000000, 60.000000000000000 },
|
473 |
|
|
{ -0.023138582263434168, 20.000000000000000, 65.000000000000000 },
|
474 |
|
|
{ -0.096058573489952323, 20.000000000000000, 70.000000000000000 },
|
475 |
|
|
{ 0.0068961047221522270, 20.000000000000000, 75.000000000000000 },
|
476 |
|
|
{ 0.090565405489918357, 20.000000000000000, 80.000000000000000 },
|
477 |
|
|
{ 0.015985497599497155, 20.000000000000000, 85.000000000000000 },
|
478 |
|
|
{ -0.080345344044422506, 20.000000000000000, 90.000000000000000 },
|
479 |
|
|
{ -0.040253075701614051, 20.000000000000000, 95.000000000000000 },
|
480 |
|
|
{ 0.062217458498338679, 20.000000000000000, 100.00000000000000 },
|
481 |
|
|
};
|
482 |
|
|
|
483 |
|
|
// Test function for nu=20.000000000000000.
|
484 |
|
|
template <typename Tp>
|
485 |
|
|
void test009()
|
486 |
|
|
{
|
487 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
488 |
|
|
Tp max_abs_diff = -Tp(1);
|
489 |
|
|
Tp max_abs_frac = -Tp(1);
|
490 |
|
|
unsigned int num_datum = sizeof(data009)
|
491 |
|
|
/ sizeof(testcase_cyl_bessel_j<double>);
|
492 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
493 |
|
|
{
|
494 |
|
|
const Tp f = std::tr1::cyl_bessel_j(Tp(data009[i].nu), Tp(data009[i].x));
|
495 |
|
|
const Tp f0 = data009[i].f0;
|
496 |
|
|
const Tp diff = f - f0;
|
497 |
|
|
if (std::abs(diff) > max_abs_diff)
|
498 |
|
|
max_abs_diff = std::abs(diff);
|
499 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
500 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
501 |
|
|
{
|
502 |
|
|
const Tp frac = diff / f0;
|
503 |
|
|
if (std::abs(frac) > max_abs_frac)
|
504 |
|
|
max_abs_frac = std::abs(frac);
|
505 |
|
|
}
|
506 |
|
|
}
|
507 |
|
|
VERIFY(max_abs_frac < Tp(1.0000000000000006e-10));
|
508 |
|
|
}
|
509 |
|
|
|
510 |
|
|
// Test data for nu=50.000000000000000.
|
511 |
|
|
testcase_cyl_bessel_j<double> data010[] = {
|
512 |
|
|
{ 0.0000000000000000, 50.000000000000000, 0.0000000000000000 },
|
513 |
|
|
{ 2.2942476159525415e-45, 50.000000000000000, 5.0000000000000000 },
|
514 |
|
|
{ 1.7845136078715964e-30, 50.000000000000000, 10.000000000000000 },
|
515 |
|
|
{ 6.1060519495338733e-22, 50.000000000000000, 15.000000000000000 },
|
516 |
|
|
{ 4.4510392847006872e-16, 50.000000000000000, 20.000000000000000 },
|
517 |
|
|
{ 9.7561594280229727e-12, 50.000000000000000, 25.000000000000000 },
|
518 |
|
|
{ 2.0581656631564181e-08, 50.000000000000000, 30.000000000000000 },
|
519 |
|
|
{ 7.6069951699272926e-06, 50.000000000000000, 35.000000000000000 },
|
520 |
|
|
{ 0.00068185243531768255, 50.000000000000000, 40.000000000000000 },
|
521 |
|
|
{ 0.017284343240791228, 50.000000000000000, 45.000000000000000 },
|
522 |
|
|
{ 0.12140902189761522, 50.000000000000000, 50.000000000000000 },
|
523 |
|
|
{ 0.13594720957176004, 50.000000000000000, 55.000000000000000 },
|
524 |
|
|
{ -0.13798273148535209, 50.000000000000000, 60.000000000000000 },
|
525 |
|
|
{ 0.12116217746619408, 50.000000000000000, 65.000000000000000 },
|
526 |
|
|
{ -0.11394866738787141, 50.000000000000000, 70.000000000000000 },
|
527 |
|
|
{ 0.094076799581573417, 50.000000000000000, 75.000000000000000 },
|
528 |
|
|
{ -0.039457764590251236, 50.000000000000000, 80.000000000000000 },
|
529 |
|
|
{ -0.040412060734136369, 50.000000000000000, 85.000000000000000 },
|
530 |
|
|
{ 0.090802099838032252, 50.000000000000000, 90.000000000000000 },
|
531 |
|
|
{ -0.055979156267280269, 50.000000000000000, 95.000000000000000 },
|
532 |
|
|
{ -0.038698339728525460, 50.000000000000000, 100.00000000000000 },
|
533 |
|
|
};
|
534 |
|
|
|
535 |
|
|
// Test function for nu=50.000000000000000.
|
536 |
|
|
template <typename Tp>
|
537 |
|
|
void test010()
|
538 |
|
|
{
|
539 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
540 |
|
|
Tp max_abs_diff = -Tp(1);
|
541 |
|
|
Tp max_abs_frac = -Tp(1);
|
542 |
|
|
unsigned int num_datum = sizeof(data010)
|
543 |
|
|
/ sizeof(testcase_cyl_bessel_j<double>);
|
544 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
545 |
|
|
{
|
546 |
|
|
const Tp f = std::tr1::cyl_bessel_j(Tp(data010[i].nu), Tp(data010[i].x));
|
547 |
|
|
const Tp f0 = data010[i].f0;
|
548 |
|
|
const Tp diff = f - f0;
|
549 |
|
|
if (std::abs(diff) > max_abs_diff)
|
550 |
|
|
max_abs_diff = std::abs(diff);
|
551 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
552 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
553 |
|
|
{
|
554 |
|
|
const Tp frac = diff / f0;
|
555 |
|
|
if (std::abs(frac) > max_abs_frac)
|
556 |
|
|
max_abs_frac = std::abs(frac);
|
557 |
|
|
}
|
558 |
|
|
}
|
559 |
|
|
VERIFY(max_abs_frac < Tp(1.0000000000000006e-11));
|
560 |
|
|
}
|
561 |
|
|
|
562 |
|
|
// Test data for nu=100.00000000000000.
|
563 |
|
|
testcase_cyl_bessel_j<double> data011[] = {
|
564 |
|
|
{ 0.0000000000000000, 100.00000000000000, 0.0000000000000000 },
|
565 |
|
|
{ 6.2677893955418763e-119, 100.00000000000000, 5.0000000000000000 },
|
566 |
|
|
{ 6.5973160641553816e-89, 100.00000000000000, 10.000000000000000 },
|
567 |
|
|
{ 1.9660095611249536e-71, 100.00000000000000, 15.000000000000000 },
|
568 |
|
|
{ 3.9617550943362524e-59, 100.00000000000000, 20.000000000000000 },
|
569 |
|
|
{ 1.1064482655301687e-49, 100.00000000000000, 25.000000000000000 },
|
570 |
|
|
{ 4.5788015281752354e-42, 100.00000000000000, 30.000000000000000 },
|
571 |
|
|
{ 9.9210206714732606e-36, 100.00000000000000, 35.000000000000000 },
|
572 |
|
|
{ 2.3866062996027414e-30, 100.00000000000000, 40.000000000000000 },
|
573 |
|
|
{ 1.0329791804565538e-25, 100.00000000000000, 45.000000000000000 },
|
574 |
|
|
{ 1.1159273690838340e-21, 100.00000000000000, 50.000000000000000 },
|
575 |
|
|
{ 3.7899753451900682e-18, 100.00000000000000, 55.000000000000000 },
|
576 |
|
|
{ 4.7832744078781205e-15, 100.00000000000000, 60.000000000000000 },
|
577 |
|
|
{ 2.5375564579490517e-12, 100.00000000000000, 65.000000000000000 },
|
578 |
|
|
{ 6.1982452141641260e-10, 100.00000000000000, 70.000000000000000 },
|
579 |
|
|
{ 7.4479005905904457e-08, 100.00000000000000, 75.000000000000000 },
|
580 |
|
|
{ 4.6065530648234948e-06, 100.00000000000000, 80.000000000000000 },
|
581 |
|
|
{ 0.00015043869999501605, 100.00000000000000, 85.000000000000000 },
|
582 |
|
|
{ 0.0026021305819963472, 100.00000000000000, 90.000000000000000 },
|
583 |
|
|
{ 0.023150768009428162, 100.00000000000000, 95.000000000000000 },
|
584 |
|
|
{ 0.096366673295861571, 100.00000000000000, 100.00000000000000 },
|
585 |
|
|
};
|
586 |
|
|
|
587 |
|
|
// Test function for nu=100.00000000000000.
|
588 |
|
|
template <typename Tp>
|
589 |
|
|
void test011()
|
590 |
|
|
{
|
591 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
592 |
|
|
Tp max_abs_diff = -Tp(1);
|
593 |
|
|
Tp max_abs_frac = -Tp(1);
|
594 |
|
|
unsigned int num_datum = sizeof(data011)
|
595 |
|
|
/ sizeof(testcase_cyl_bessel_j<double>);
|
596 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
597 |
|
|
{
|
598 |
|
|
const Tp f = std::tr1::cyl_bessel_j(Tp(data011[i].nu), Tp(data011[i].x));
|
599 |
|
|
const Tp f0 = data011[i].f0;
|
600 |
|
|
const Tp diff = f - f0;
|
601 |
|
|
if (std::abs(diff) > max_abs_diff)
|
602 |
|
|
max_abs_diff = std::abs(diff);
|
603 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
604 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
605 |
|
|
{
|
606 |
|
|
const Tp frac = diff / f0;
|
607 |
|
|
if (std::abs(frac) > max_abs_frac)
|
608 |
|
|
max_abs_frac = std::abs(frac);
|
609 |
|
|
}
|
610 |
|
|
}
|
611 |
|
|
VERIFY(max_abs_frac < Tp(1.0000000000000006e-11));
|
612 |
|
|
}
|
613 |
|
|
|
614 |
|
|
int main(int, char**)
|
615 |
|
|
{
|
616 |
|
|
test001<double>();
|
617 |
|
|
test002<double>();
|
618 |
|
|
test003<double>();
|
619 |
|
|
test004<double>();
|
620 |
|
|
test005<double>();
|
621 |
|
|
test006<double>();
|
622 |
|
|
test007<double>();
|
623 |
|
|
test008<double>();
|
624 |
|
|
test009<double>();
|
625 |
|
|
test010<double>();
|
626 |
|
|
test011<double>();
|
627 |
|
|
return 0;
|
628 |
|
|
}
|