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 |
|
|
// ellint_1
|
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 k=-0.90000000000000002.
|
43 |
|
|
testcase_ellint_1<double> data001[] = {
|
44 |
|
|
{ -0.0000000000000000, -0.90000000000000002, 0.0000000000000000 },
|
45 |
|
|
{ 0.17525427376115027, -0.90000000000000002, 0.17453292519943295 },
|
46 |
|
|
{ 0.35492464591297446, -0.90000000000000002, 0.34906585039886590 },
|
47 |
|
|
{ 0.54388221416157134, -0.90000000000000002, 0.52359877559829882 },
|
48 |
|
|
{ 0.74797400423532523, -0.90000000000000002, 0.69813170079773179 },
|
49 |
|
|
{ 0.97463898451966458, -0.90000000000000002, 0.87266462599716477 },
|
50 |
|
|
{ 1.2334463254523440, -0.90000000000000002, 1.0471975511965976 },
|
51 |
|
|
{ 1.5355247765594910, -0.90000000000000002, 1.2217304763960306 },
|
52 |
|
|
{ 1.8882928567775124, -0.90000000000000002, 1.3962634015954636 },
|
53 |
|
|
{ 2.2805491384227703, -0.90000000000000002, 1.5707963267948966 },
|
54 |
|
|
};
|
55 |
|
|
|
56 |
|
|
// Test function for k=-0.90000000000000002.
|
57 |
|
|
template <typename Tp>
|
58 |
|
|
void test001()
|
59 |
|
|
{
|
60 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
61 |
|
|
Tp max_abs_diff = -Tp(1);
|
62 |
|
|
Tp max_abs_frac = -Tp(1);
|
63 |
|
|
unsigned int num_datum = sizeof(data001)
|
64 |
|
|
/ sizeof(testcase_ellint_1<double>);
|
65 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
66 |
|
|
{
|
67 |
|
|
const Tp f = std::tr1::ellint_1(Tp(data001[i].k), Tp(data001[i].phi));
|
68 |
|
|
const Tp f0 = data001[i].f0;
|
69 |
|
|
const Tp diff = f - f0;
|
70 |
|
|
if (std::abs(diff) > max_abs_diff)
|
71 |
|
|
max_abs_diff = std::abs(diff);
|
72 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
73 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
74 |
|
|
{
|
75 |
|
|
const Tp frac = diff / f0;
|
76 |
|
|
if (std::abs(frac) > max_abs_frac)
|
77 |
|
|
max_abs_frac = std::abs(frac);
|
78 |
|
|
}
|
79 |
|
|
}
|
80 |
|
|
VERIFY(max_abs_frac < Tp(2.5000000000000020e-13));
|
81 |
|
|
}
|
82 |
|
|
|
83 |
|
|
// Test data for k=-0.80000000000000004.
|
84 |
|
|
testcase_ellint_1<double> data002[] = {
|
85 |
|
|
{ -0.0000000000000000, -0.80000000000000004, 0.0000000000000000 },
|
86 |
|
|
{ 0.17510154241338902, -0.80000000000000004, 0.17453292519943295 },
|
87 |
|
|
{ 0.35365068839779390, -0.80000000000000004, 0.34906585039886590 },
|
88 |
|
|
{ 0.53926804409084561, -0.80000000000000004, 0.52359877559829882 },
|
89 |
|
|
{ 0.73587926028070383, -0.80000000000000004, 0.69813170079773179 },
|
90 |
|
|
{ 0.94770942970071170, -0.80000000000000004, 0.87266462599716477 },
|
91 |
|
|
{ 1.1789022995388239, -0.80000000000000004, 1.0471975511965976 },
|
92 |
|
|
{ 1.4323027881876009, -0.80000000000000004, 1.2217304763960306 },
|
93 |
|
|
{ 1.7069629739121674, -0.80000000000000004, 1.3962634015954636 },
|
94 |
|
|
{ 1.9953027776647296, -0.80000000000000004, 1.5707963267948966 },
|
95 |
|
|
};
|
96 |
|
|
|
97 |
|
|
// Test function for k=-0.80000000000000004.
|
98 |
|
|
template <typename Tp>
|
99 |
|
|
void test002()
|
100 |
|
|
{
|
101 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
102 |
|
|
Tp max_abs_diff = -Tp(1);
|
103 |
|
|
Tp max_abs_frac = -Tp(1);
|
104 |
|
|
unsigned int num_datum = sizeof(data002)
|
105 |
|
|
/ sizeof(testcase_ellint_1<double>);
|
106 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
107 |
|
|
{
|
108 |
|
|
const Tp f = std::tr1::ellint_1(Tp(data002[i].k), Tp(data002[i].phi));
|
109 |
|
|
const Tp f0 = data002[i].f0;
|
110 |
|
|
const Tp diff = f - f0;
|
111 |
|
|
if (std::abs(diff) > max_abs_diff)
|
112 |
|
|
max_abs_diff = std::abs(diff);
|
113 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
114 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
115 |
|
|
{
|
116 |
|
|
const Tp frac = diff / f0;
|
117 |
|
|
if (std::abs(frac) > max_abs_frac)
|
118 |
|
|
max_abs_frac = std::abs(frac);
|
119 |
|
|
}
|
120 |
|
|
}
|
121 |
|
|
VERIFY(max_abs_frac < Tp(2.5000000000000020e-13));
|
122 |
|
|
}
|
123 |
|
|
|
124 |
|
|
// Test data for k=-0.69999999999999996.
|
125 |
|
|
testcase_ellint_1<double> data003[] = {
|
126 |
|
|
{ -0.0000000000000000, -0.69999999999999996, 0.0000000000000000 },
|
127 |
|
|
{ 0.17496737466916720, -0.69999999999999996, 0.17453292519943295 },
|
128 |
|
|
{ 0.35254687535677925, -0.69999999999999996, 0.34906585039886590 },
|
129 |
|
|
{ 0.53536740275997130, -0.69999999999999996, 0.52359877559829882 },
|
130 |
|
|
{ 0.72603797651684465, -0.69999999999999996, 0.69813170079773179 },
|
131 |
|
|
{ 0.92698296348313458, -0.69999999999999996, 0.87266462599716477 },
|
132 |
|
|
{ 1.1400447527693316, -0.69999999999999996, 1.0471975511965976 },
|
133 |
|
|
{ 1.3657668117194071, -0.69999999999999996, 1.2217304763960306 },
|
134 |
|
|
{ 1.6024686895959159, -0.69999999999999996, 1.3962634015954636 },
|
135 |
|
|
{ 1.8456939983747236, -0.69999999999999996, 1.5707963267948966 },
|
136 |
|
|
};
|
137 |
|
|
|
138 |
|
|
// Test function for k=-0.69999999999999996.
|
139 |
|
|
template <typename Tp>
|
140 |
|
|
void test003()
|
141 |
|
|
{
|
142 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
143 |
|
|
Tp max_abs_diff = -Tp(1);
|
144 |
|
|
Tp max_abs_frac = -Tp(1);
|
145 |
|
|
unsigned int num_datum = sizeof(data003)
|
146 |
|
|
/ sizeof(testcase_ellint_1<double>);
|
147 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
148 |
|
|
{
|
149 |
|
|
const Tp f = std::tr1::ellint_1(Tp(data003[i].k), Tp(data003[i].phi));
|
150 |
|
|
const Tp f0 = data003[i].f0;
|
151 |
|
|
const Tp diff = f - f0;
|
152 |
|
|
if (std::abs(diff) > max_abs_diff)
|
153 |
|
|
max_abs_diff = std::abs(diff);
|
154 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
155 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
156 |
|
|
{
|
157 |
|
|
const Tp frac = diff / f0;
|
158 |
|
|
if (std::abs(frac) > max_abs_frac)
|
159 |
|
|
max_abs_frac = std::abs(frac);
|
160 |
|
|
}
|
161 |
|
|
}
|
162 |
|
|
VERIFY(max_abs_frac < Tp(2.5000000000000020e-13));
|
163 |
|
|
}
|
164 |
|
|
|
165 |
|
|
// Test data for k=-0.59999999999999998.
|
166 |
|
|
testcase_ellint_1<double> data004[] = {
|
167 |
|
|
{ -0.0000000000000000, -0.59999999999999998, 0.0000000000000000 },
|
168 |
|
|
{ 0.17485154362988362, -0.59999999999999998, 0.17453292519943295 },
|
169 |
|
|
{ 0.35160509865544326, -0.59999999999999998, 0.34906585039886590 },
|
170 |
|
|
{ 0.53210652578446160, -0.59999999999999998, 0.52359877559829882 },
|
171 |
|
|
{ 0.71805304664485670, -0.59999999999999998, 0.69813170079773179 },
|
172 |
|
|
{ 0.91082759030195970, -0.59999999999999998, 0.87266462599716477 },
|
173 |
|
|
{ 1.1112333229323361, -0.59999999999999998, 1.0471975511965976 },
|
174 |
|
|
{ 1.3191461190365270, -0.59999999999999998, 1.2217304763960306 },
|
175 |
|
|
{ 1.5332022105084773, -0.59999999999999998, 1.3962634015954636 },
|
176 |
|
|
{ 1.7507538029157526, -0.59999999999999998, 1.5707963267948966 },
|
177 |
|
|
};
|
178 |
|
|
|
179 |
|
|
// Test function for k=-0.59999999999999998.
|
180 |
|
|
template <typename Tp>
|
181 |
|
|
void test004()
|
182 |
|
|
{
|
183 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
184 |
|
|
Tp max_abs_diff = -Tp(1);
|
185 |
|
|
Tp max_abs_frac = -Tp(1);
|
186 |
|
|
unsigned int num_datum = sizeof(data004)
|
187 |
|
|
/ sizeof(testcase_ellint_1<double>);
|
188 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
189 |
|
|
{
|
190 |
|
|
const Tp f = std::tr1::ellint_1(Tp(data004[i].k), Tp(data004[i].phi));
|
191 |
|
|
const Tp f0 = data004[i].f0;
|
192 |
|
|
const Tp diff = f - f0;
|
193 |
|
|
if (std::abs(diff) > max_abs_diff)
|
194 |
|
|
max_abs_diff = std::abs(diff);
|
195 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
196 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
197 |
|
|
{
|
198 |
|
|
const Tp frac = diff / f0;
|
199 |
|
|
if (std::abs(frac) > max_abs_frac)
|
200 |
|
|
max_abs_frac = std::abs(frac);
|
201 |
|
|
}
|
202 |
|
|
}
|
203 |
|
|
VERIFY(max_abs_frac < Tp(2.5000000000000020e-13));
|
204 |
|
|
}
|
205 |
|
|
|
206 |
|
|
// Test data for k=-0.50000000000000000.
|
207 |
|
|
testcase_ellint_1<double> data005[] = {
|
208 |
|
|
{ -0.0000000000000000, -0.50000000000000000, 0.0000000000000000 },
|
209 |
|
|
{ 0.17475385514035785, -0.50000000000000000, 0.17453292519943295 },
|
210 |
|
|
{ 0.35081868470101585, -0.50000000000000000, 0.34906585039886590 },
|
211 |
|
|
{ 0.52942862705190585, -0.50000000000000000, 0.52359877559829882 },
|
212 |
|
|
{ 0.71164727562630326, -0.50000000000000000, 0.69813170079773179 },
|
213 |
|
|
{ 0.89824523594227768, -0.50000000000000000, 0.87266462599716477 },
|
214 |
|
|
{ 1.0895506700518851, -0.50000000000000000, 1.0471975511965976 },
|
215 |
|
|
{ 1.2853005857432933, -0.50000000000000000, 1.2217304763960306 },
|
216 |
|
|
{ 1.4845545520549484, -0.50000000000000000, 1.3962634015954636 },
|
217 |
|
|
{ 1.6857503548125963, -0.50000000000000000, 1.5707963267948966 },
|
218 |
|
|
};
|
219 |
|
|
|
220 |
|
|
// Test function for k=-0.50000000000000000.
|
221 |
|
|
template <typename Tp>
|
222 |
|
|
void test005()
|
223 |
|
|
{
|
224 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
225 |
|
|
Tp max_abs_diff = -Tp(1);
|
226 |
|
|
Tp max_abs_frac = -Tp(1);
|
227 |
|
|
unsigned int num_datum = sizeof(data005)
|
228 |
|
|
/ sizeof(testcase_ellint_1<double>);
|
229 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
230 |
|
|
{
|
231 |
|
|
const Tp f = std::tr1::ellint_1(Tp(data005[i].k), Tp(data005[i].phi));
|
232 |
|
|
const Tp f0 = data005[i].f0;
|
233 |
|
|
const Tp diff = f - f0;
|
234 |
|
|
if (std::abs(diff) > max_abs_diff)
|
235 |
|
|
max_abs_diff = std::abs(diff);
|
236 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
237 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
238 |
|
|
{
|
239 |
|
|
const Tp frac = diff / f0;
|
240 |
|
|
if (std::abs(frac) > max_abs_frac)
|
241 |
|
|
max_abs_frac = std::abs(frac);
|
242 |
|
|
}
|
243 |
|
|
}
|
244 |
|
|
VERIFY(max_abs_frac < Tp(2.5000000000000020e-13));
|
245 |
|
|
}
|
246 |
|
|
|
247 |
|
|
// Test data for k=-0.40000000000000002.
|
248 |
|
|
testcase_ellint_1<double> data006[] = {
|
249 |
|
|
{ -0.0000000000000000, -0.40000000000000002, 0.0000000000000000 },
|
250 |
|
|
{ 0.17467414669441531, -0.40000000000000002, 0.17453292519943295 },
|
251 |
|
|
{ 0.35018222772483443, -0.40000000000000002, 0.34906585039886590 },
|
252 |
|
|
{ 0.52729015917508748, -0.40000000000000002, 0.52359877559829882 },
|
253 |
|
|
{ 0.70662374407341255, -0.40000000000000002, 0.69813170079773179 },
|
254 |
|
|
{ 0.88859210497602170, -0.40000000000000002, 0.87266462599716477 },
|
255 |
|
|
{ 1.0733136290471379, -0.40000000000000002, 1.0471975511965976 },
|
256 |
|
|
{ 1.2605612170157061, -0.40000000000000002, 1.2217304763960306 },
|
257 |
|
|
{ 1.4497513956433437, -0.40000000000000002, 1.3962634015954636 },
|
258 |
|
|
{ 1.6399998658645112, -0.40000000000000002, 1.5707963267948966 },
|
259 |
|
|
};
|
260 |
|
|
|
261 |
|
|
// Test function for k=-0.40000000000000002.
|
262 |
|
|
template <typename Tp>
|
263 |
|
|
void test006()
|
264 |
|
|
{
|
265 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
266 |
|
|
Tp max_abs_diff = -Tp(1);
|
267 |
|
|
Tp max_abs_frac = -Tp(1);
|
268 |
|
|
unsigned int num_datum = sizeof(data006)
|
269 |
|
|
/ sizeof(testcase_ellint_1<double>);
|
270 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
271 |
|
|
{
|
272 |
|
|
const Tp f = std::tr1::ellint_1(Tp(data006[i].k), Tp(data006[i].phi));
|
273 |
|
|
const Tp f0 = data006[i].f0;
|
274 |
|
|
const Tp diff = f - f0;
|
275 |
|
|
if (std::abs(diff) > max_abs_diff)
|
276 |
|
|
max_abs_diff = std::abs(diff);
|
277 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
278 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
279 |
|
|
{
|
280 |
|
|
const Tp frac = diff / f0;
|
281 |
|
|
if (std::abs(frac) > max_abs_frac)
|
282 |
|
|
max_abs_frac = std::abs(frac);
|
283 |
|
|
}
|
284 |
|
|
}
|
285 |
|
|
VERIFY(max_abs_frac < Tp(2.5000000000000020e-13));
|
286 |
|
|
}
|
287 |
|
|
|
288 |
|
|
// Test data for k=-0.30000000000000004.
|
289 |
|
|
testcase_ellint_1<double> data007[] = {
|
290 |
|
|
{ -0.0000000000000000, -0.30000000000000004, 0.0000000000000000 },
|
291 |
|
|
{ 0.17461228653000102, -0.30000000000000004, 0.17453292519943295 },
|
292 |
|
|
{ 0.34969146102798415, -0.30000000000000004, 0.34906585039886590 },
|
293 |
|
|
{ 0.52565822873726320, -0.30000000000000004, 0.52359877559829882 },
|
294 |
|
|
{ 0.70284226512408532, -0.30000000000000004, 0.69813170079773179 },
|
295 |
|
|
{ 0.88144139195111182, -0.30000000000000004, 0.87266462599716477 },
|
296 |
|
|
{ 1.0614897067260523, -0.30000000000000004, 1.0471975511965976 },
|
297 |
|
|
{ 1.2428416824174218, -0.30000000000000004, 1.2217304763960306 },
|
298 |
|
|
{ 1.4251795877015925, -0.30000000000000004, 1.3962634015954636 },
|
299 |
|
|
{ 1.6080486199305126, -0.30000000000000004, 1.5707963267948966 },
|
300 |
|
|
};
|
301 |
|
|
|
302 |
|
|
// Test function for k=-0.30000000000000004.
|
303 |
|
|
template <typename Tp>
|
304 |
|
|
void test007()
|
305 |
|
|
{
|
306 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
307 |
|
|
Tp max_abs_diff = -Tp(1);
|
308 |
|
|
Tp max_abs_frac = -Tp(1);
|
309 |
|
|
unsigned int num_datum = sizeof(data007)
|
310 |
|
|
/ sizeof(testcase_ellint_1<double>);
|
311 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
312 |
|
|
{
|
313 |
|
|
const Tp f = std::tr1::ellint_1(Tp(data007[i].k), Tp(data007[i].phi));
|
314 |
|
|
const Tp f0 = data007[i].f0;
|
315 |
|
|
const Tp diff = f - f0;
|
316 |
|
|
if (std::abs(diff) > max_abs_diff)
|
317 |
|
|
max_abs_diff = std::abs(diff);
|
318 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
319 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
320 |
|
|
{
|
321 |
|
|
const Tp frac = diff / f0;
|
322 |
|
|
if (std::abs(frac) > max_abs_frac)
|
323 |
|
|
max_abs_frac = std::abs(frac);
|
324 |
|
|
}
|
325 |
|
|
}
|
326 |
|
|
VERIFY(max_abs_frac < Tp(2.5000000000000020e-13));
|
327 |
|
|
}
|
328 |
|
|
|
329 |
|
|
// Test data for k=-0.19999999999999996.
|
330 |
|
|
testcase_ellint_1<double> data008[] = {
|
331 |
|
|
{ -0.0000000000000000, -0.19999999999999996, 0.0000000000000000 },
|
332 |
|
|
{ 0.17456817290292811, -0.19999999999999996, 0.17453292519943295 },
|
333 |
|
|
{ 0.34934315932086801, -0.19999999999999996, 0.34906585039886590 },
|
334 |
|
|
{ 0.52450880529443988, -0.19999999999999996, 0.52359877559829882 },
|
335 |
|
|
{ 0.70020491009844910, -0.19999999999999996, 0.69813170079773179 },
|
336 |
|
|
{ 0.87651006649967955, -0.19999999999999996, 0.87266462599716477 },
|
337 |
|
|
{ 1.0534305870298994, -0.19999999999999996, 1.0471975511965976 },
|
338 |
|
|
{ 1.2308975521670784, -0.19999999999999996, 1.2217304763960306 },
|
339 |
|
|
{ 1.4087733584990738, -0.19999999999999996, 1.3962634015954636 },
|
340 |
|
|
{ 1.5868678474541664, -0.19999999999999996, 1.5707963267948966 },
|
341 |
|
|
};
|
342 |
|
|
|
343 |
|
|
// Test function for k=-0.19999999999999996.
|
344 |
|
|
template <typename Tp>
|
345 |
|
|
void test008()
|
346 |
|
|
{
|
347 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
348 |
|
|
Tp max_abs_diff = -Tp(1);
|
349 |
|
|
Tp max_abs_frac = -Tp(1);
|
350 |
|
|
unsigned int num_datum = sizeof(data008)
|
351 |
|
|
/ sizeof(testcase_ellint_1<double>);
|
352 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
353 |
|
|
{
|
354 |
|
|
const Tp f = std::tr1::ellint_1(Tp(data008[i].k), Tp(data008[i].phi));
|
355 |
|
|
const Tp f0 = data008[i].f0;
|
356 |
|
|
const Tp diff = f - f0;
|
357 |
|
|
if (std::abs(diff) > max_abs_diff)
|
358 |
|
|
max_abs_diff = std::abs(diff);
|
359 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
360 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
361 |
|
|
{
|
362 |
|
|
const Tp frac = diff / f0;
|
363 |
|
|
if (std::abs(frac) > max_abs_frac)
|
364 |
|
|
max_abs_frac = std::abs(frac);
|
365 |
|
|
}
|
366 |
|
|
}
|
367 |
|
|
VERIFY(max_abs_frac < Tp(2.5000000000000020e-13));
|
368 |
|
|
}
|
369 |
|
|
|
370 |
|
|
// Test data for k=-0.099999999999999978.
|
371 |
|
|
testcase_ellint_1<double> data009[] = {
|
372 |
|
|
{ -0.0000000000000000, -0.099999999999999978, 0.0000000000000000 },
|
373 |
|
|
{ 0.17454173353063665, -0.099999999999999978, 0.17453292519943295 },
|
374 |
|
|
{ 0.34913506721468085, -0.099999999999999978, 0.34906585039886590 },
|
375 |
|
|
{ 0.52382550016538953, -0.099999999999999978, 0.52359877559829882 },
|
376 |
|
|
{ 0.69864700854177031, -0.099999999999999978, 0.69813170079773179 },
|
377 |
|
|
{ 0.87361792586964870, -0.099999999999999978, 0.87266462599716477 },
|
378 |
|
|
{ 1.0487386319621685, -0.099999999999999978, 1.0471975511965976 },
|
379 |
|
|
{ 1.2239913752078757, -0.099999999999999978, 1.2217304763960306 },
|
380 |
|
|
{ 1.3993423113684049, -0.099999999999999978, 1.3962634015954636 },
|
381 |
|
|
{ 1.5747455615173562, -0.099999999999999978, 1.5707963267948966 },
|
382 |
|
|
};
|
383 |
|
|
|
384 |
|
|
// Test function for k=-0.099999999999999978.
|
385 |
|
|
template <typename Tp>
|
386 |
|
|
void test009()
|
387 |
|
|
{
|
388 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
389 |
|
|
Tp max_abs_diff = -Tp(1);
|
390 |
|
|
Tp max_abs_frac = -Tp(1);
|
391 |
|
|
unsigned int num_datum = sizeof(data009)
|
392 |
|
|
/ sizeof(testcase_ellint_1<double>);
|
393 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
394 |
|
|
{
|
395 |
|
|
const Tp f = std::tr1::ellint_1(Tp(data009[i].k), Tp(data009[i].phi));
|
396 |
|
|
const Tp f0 = data009[i].f0;
|
397 |
|
|
const Tp diff = f - f0;
|
398 |
|
|
if (std::abs(diff) > max_abs_diff)
|
399 |
|
|
max_abs_diff = std::abs(diff);
|
400 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
401 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
402 |
|
|
{
|
403 |
|
|
const Tp frac = diff / f0;
|
404 |
|
|
if (std::abs(frac) > max_abs_frac)
|
405 |
|
|
max_abs_frac = std::abs(frac);
|
406 |
|
|
}
|
407 |
|
|
}
|
408 |
|
|
VERIFY(max_abs_frac < Tp(2.5000000000000020e-13));
|
409 |
|
|
}
|
410 |
|
|
|
411 |
|
|
// Test data for k=0.0000000000000000.
|
412 |
|
|
testcase_ellint_1<double> data010[] = {
|
413 |
|
|
{ -0.0000000000000000, 0.0000000000000000, 0.0000000000000000 },
|
414 |
|
|
{ 0.17453292519943295, 0.0000000000000000, 0.17453292519943295 },
|
415 |
|
|
{ 0.34906585039886584, 0.0000000000000000, 0.34906585039886590 },
|
416 |
|
|
{ 0.52359877559829882, 0.0000000000000000, 0.52359877559829882 },
|
417 |
|
|
{ 0.69813170079773179, 0.0000000000000000, 0.69813170079773179 },
|
418 |
|
|
{ 0.87266462599716477, 0.0000000000000000, 0.87266462599716477 },
|
419 |
|
|
{ 1.0471975511965976, 0.0000000000000000, 1.0471975511965976 },
|
420 |
|
|
{ 1.2217304763960304, 0.0000000000000000, 1.2217304763960306 },
|
421 |
|
|
{ 1.3962634015954631, 0.0000000000000000, 1.3962634015954636 },
|
422 |
|
|
{ 1.5707963267948966, 0.0000000000000000, 1.5707963267948966 },
|
423 |
|
|
};
|
424 |
|
|
|
425 |
|
|
// Test function for k=0.0000000000000000.
|
426 |
|
|
template <typename Tp>
|
427 |
|
|
void test010()
|
428 |
|
|
{
|
429 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
430 |
|
|
Tp max_abs_diff = -Tp(1);
|
431 |
|
|
Tp max_abs_frac = -Tp(1);
|
432 |
|
|
unsigned int num_datum = sizeof(data010)
|
433 |
|
|
/ sizeof(testcase_ellint_1<double>);
|
434 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
435 |
|
|
{
|
436 |
|
|
const Tp f = std::tr1::ellint_1(Tp(data010[i].k), Tp(data010[i].phi));
|
437 |
|
|
const Tp f0 = data010[i].f0;
|
438 |
|
|
const Tp diff = f - f0;
|
439 |
|
|
if (std::abs(diff) > max_abs_diff)
|
440 |
|
|
max_abs_diff = std::abs(diff);
|
441 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
442 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
443 |
|
|
{
|
444 |
|
|
const Tp frac = diff / f0;
|
445 |
|
|
if (std::abs(frac) > max_abs_frac)
|
446 |
|
|
max_abs_frac = std::abs(frac);
|
447 |
|
|
}
|
448 |
|
|
}
|
449 |
|
|
VERIFY(max_abs_frac < Tp(2.5000000000000020e-13));
|
450 |
|
|
}
|
451 |
|
|
|
452 |
|
|
// Test data for k=0.10000000000000009.
|
453 |
|
|
testcase_ellint_1<double> data011[] = {
|
454 |
|
|
{ -0.0000000000000000, 0.10000000000000009, 0.0000000000000000 },
|
455 |
|
|
{ 0.17454173353063665, 0.10000000000000009, 0.17453292519943295 },
|
456 |
|
|
{ 0.34913506721468085, 0.10000000000000009, 0.34906585039886590 },
|
457 |
|
|
{ 0.52382550016538953, 0.10000000000000009, 0.52359877559829882 },
|
458 |
|
|
{ 0.69864700854177031, 0.10000000000000009, 0.69813170079773179 },
|
459 |
|
|
{ 0.87361792586964870, 0.10000000000000009, 0.87266462599716477 },
|
460 |
|
|
{ 1.0487386319621685, 0.10000000000000009, 1.0471975511965976 },
|
461 |
|
|
{ 1.2239913752078757, 0.10000000000000009, 1.2217304763960306 },
|
462 |
|
|
{ 1.3993423113684049, 0.10000000000000009, 1.3962634015954636 },
|
463 |
|
|
{ 1.5747455615173562, 0.10000000000000009, 1.5707963267948966 },
|
464 |
|
|
};
|
465 |
|
|
|
466 |
|
|
// Test function for k=0.10000000000000009.
|
467 |
|
|
template <typename Tp>
|
468 |
|
|
void test011()
|
469 |
|
|
{
|
470 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
471 |
|
|
Tp max_abs_diff = -Tp(1);
|
472 |
|
|
Tp max_abs_frac = -Tp(1);
|
473 |
|
|
unsigned int num_datum = sizeof(data011)
|
474 |
|
|
/ sizeof(testcase_ellint_1<double>);
|
475 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
476 |
|
|
{
|
477 |
|
|
const Tp f = std::tr1::ellint_1(Tp(data011[i].k), Tp(data011[i].phi));
|
478 |
|
|
const Tp f0 = data011[i].f0;
|
479 |
|
|
const Tp diff = f - f0;
|
480 |
|
|
if (std::abs(diff) > max_abs_diff)
|
481 |
|
|
max_abs_diff = std::abs(diff);
|
482 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
483 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
484 |
|
|
{
|
485 |
|
|
const Tp frac = diff / f0;
|
486 |
|
|
if (std::abs(frac) > max_abs_frac)
|
487 |
|
|
max_abs_frac = std::abs(frac);
|
488 |
|
|
}
|
489 |
|
|
}
|
490 |
|
|
VERIFY(max_abs_frac < Tp(2.5000000000000020e-13));
|
491 |
|
|
}
|
492 |
|
|
|
493 |
|
|
// Test data for k=0.19999999999999996.
|
494 |
|
|
testcase_ellint_1<double> data012[] = {
|
495 |
|
|
{ -0.0000000000000000, 0.19999999999999996, 0.0000000000000000 },
|
496 |
|
|
{ 0.17456817290292811, 0.19999999999999996, 0.17453292519943295 },
|
497 |
|
|
{ 0.34934315932086801, 0.19999999999999996, 0.34906585039886590 },
|
498 |
|
|
{ 0.52450880529443988, 0.19999999999999996, 0.52359877559829882 },
|
499 |
|
|
{ 0.70020491009844910, 0.19999999999999996, 0.69813170079773179 },
|
500 |
|
|
{ 0.87651006649967955, 0.19999999999999996, 0.87266462599716477 },
|
501 |
|
|
{ 1.0534305870298994, 0.19999999999999996, 1.0471975511965976 },
|
502 |
|
|
{ 1.2308975521670784, 0.19999999999999996, 1.2217304763960306 },
|
503 |
|
|
{ 1.4087733584990738, 0.19999999999999996, 1.3962634015954636 },
|
504 |
|
|
{ 1.5868678474541664, 0.19999999999999996, 1.5707963267948966 },
|
505 |
|
|
};
|
506 |
|
|
|
507 |
|
|
// Test function for k=0.19999999999999996.
|
508 |
|
|
template <typename Tp>
|
509 |
|
|
void test012()
|
510 |
|
|
{
|
511 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
512 |
|
|
Tp max_abs_diff = -Tp(1);
|
513 |
|
|
Tp max_abs_frac = -Tp(1);
|
514 |
|
|
unsigned int num_datum = sizeof(data012)
|
515 |
|
|
/ sizeof(testcase_ellint_1<double>);
|
516 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
517 |
|
|
{
|
518 |
|
|
const Tp f = std::tr1::ellint_1(Tp(data012[i].k), Tp(data012[i].phi));
|
519 |
|
|
const Tp f0 = data012[i].f0;
|
520 |
|
|
const Tp diff = f - f0;
|
521 |
|
|
if (std::abs(diff) > max_abs_diff)
|
522 |
|
|
max_abs_diff = std::abs(diff);
|
523 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
524 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
525 |
|
|
{
|
526 |
|
|
const Tp frac = diff / f0;
|
527 |
|
|
if (std::abs(frac) > max_abs_frac)
|
528 |
|
|
max_abs_frac = std::abs(frac);
|
529 |
|
|
}
|
530 |
|
|
}
|
531 |
|
|
VERIFY(max_abs_frac < Tp(2.5000000000000020e-13));
|
532 |
|
|
}
|
533 |
|
|
|
534 |
|
|
// Test data for k=0.30000000000000004.
|
535 |
|
|
testcase_ellint_1<double> data013[] = {
|
536 |
|
|
{ -0.0000000000000000, 0.30000000000000004, 0.0000000000000000 },
|
537 |
|
|
{ 0.17461228653000102, 0.30000000000000004, 0.17453292519943295 },
|
538 |
|
|
{ 0.34969146102798415, 0.30000000000000004, 0.34906585039886590 },
|
539 |
|
|
{ 0.52565822873726320, 0.30000000000000004, 0.52359877559829882 },
|
540 |
|
|
{ 0.70284226512408532, 0.30000000000000004, 0.69813170079773179 },
|
541 |
|
|
{ 0.88144139195111182, 0.30000000000000004, 0.87266462599716477 },
|
542 |
|
|
{ 1.0614897067260523, 0.30000000000000004, 1.0471975511965976 },
|
543 |
|
|
{ 1.2428416824174218, 0.30000000000000004, 1.2217304763960306 },
|
544 |
|
|
{ 1.4251795877015925, 0.30000000000000004, 1.3962634015954636 },
|
545 |
|
|
{ 1.6080486199305126, 0.30000000000000004, 1.5707963267948966 },
|
546 |
|
|
};
|
547 |
|
|
|
548 |
|
|
// Test function for k=0.30000000000000004.
|
549 |
|
|
template <typename Tp>
|
550 |
|
|
void test013()
|
551 |
|
|
{
|
552 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
553 |
|
|
Tp max_abs_diff = -Tp(1);
|
554 |
|
|
Tp max_abs_frac = -Tp(1);
|
555 |
|
|
unsigned int num_datum = sizeof(data013)
|
556 |
|
|
/ sizeof(testcase_ellint_1<double>);
|
557 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
558 |
|
|
{
|
559 |
|
|
const Tp f = std::tr1::ellint_1(Tp(data013[i].k), Tp(data013[i].phi));
|
560 |
|
|
const Tp f0 = data013[i].f0;
|
561 |
|
|
const Tp diff = f - f0;
|
562 |
|
|
if (std::abs(diff) > max_abs_diff)
|
563 |
|
|
max_abs_diff = std::abs(diff);
|
564 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
565 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
566 |
|
|
{
|
567 |
|
|
const Tp frac = diff / f0;
|
568 |
|
|
if (std::abs(frac) > max_abs_frac)
|
569 |
|
|
max_abs_frac = std::abs(frac);
|
570 |
|
|
}
|
571 |
|
|
}
|
572 |
|
|
VERIFY(max_abs_frac < Tp(2.5000000000000020e-13));
|
573 |
|
|
}
|
574 |
|
|
|
575 |
|
|
// Test data for k=0.39999999999999991.
|
576 |
|
|
testcase_ellint_1<double> data014[] = {
|
577 |
|
|
{ -0.0000000000000000, 0.39999999999999991, 0.0000000000000000 },
|
578 |
|
|
{ 0.17467414669441531, 0.39999999999999991, 0.17453292519943295 },
|
579 |
|
|
{ 0.35018222772483443, 0.39999999999999991, 0.34906585039886590 },
|
580 |
|
|
{ 0.52729015917508748, 0.39999999999999991, 0.52359877559829882 },
|
581 |
|
|
{ 0.70662374407341255, 0.39999999999999991, 0.69813170079773179 },
|
582 |
|
|
{ 0.88859210497602170, 0.39999999999999991, 0.87266462599716477 },
|
583 |
|
|
{ 1.0733136290471379, 0.39999999999999991, 1.0471975511965976 },
|
584 |
|
|
{ 1.2605612170157061, 0.39999999999999991, 1.2217304763960306 },
|
585 |
|
|
{ 1.4497513956433437, 0.39999999999999991, 1.3962634015954636 },
|
586 |
|
|
{ 1.6399998658645112, 0.39999999999999991, 1.5707963267948966 },
|
587 |
|
|
};
|
588 |
|
|
|
589 |
|
|
// Test function for k=0.39999999999999991.
|
590 |
|
|
template <typename Tp>
|
591 |
|
|
void test014()
|
592 |
|
|
{
|
593 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
594 |
|
|
Tp max_abs_diff = -Tp(1);
|
595 |
|
|
Tp max_abs_frac = -Tp(1);
|
596 |
|
|
unsigned int num_datum = sizeof(data014)
|
597 |
|
|
/ sizeof(testcase_ellint_1<double>);
|
598 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
599 |
|
|
{
|
600 |
|
|
const Tp f = std::tr1::ellint_1(Tp(data014[i].k), Tp(data014[i].phi));
|
601 |
|
|
const Tp f0 = data014[i].f0;
|
602 |
|
|
const Tp diff = f - f0;
|
603 |
|
|
if (std::abs(diff) > max_abs_diff)
|
604 |
|
|
max_abs_diff = std::abs(diff);
|
605 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
606 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
607 |
|
|
{
|
608 |
|
|
const Tp frac = diff / f0;
|
609 |
|
|
if (std::abs(frac) > max_abs_frac)
|
610 |
|
|
max_abs_frac = std::abs(frac);
|
611 |
|
|
}
|
612 |
|
|
}
|
613 |
|
|
VERIFY(max_abs_frac < Tp(2.5000000000000020e-13));
|
614 |
|
|
}
|
615 |
|
|
|
616 |
|
|
// Test data for k=0.50000000000000000.
|
617 |
|
|
testcase_ellint_1<double> data015[] = {
|
618 |
|
|
{ -0.0000000000000000, 0.50000000000000000, 0.0000000000000000 },
|
619 |
|
|
{ 0.17475385514035785, 0.50000000000000000, 0.17453292519943295 },
|
620 |
|
|
{ 0.35081868470101585, 0.50000000000000000, 0.34906585039886590 },
|
621 |
|
|
{ 0.52942862705190585, 0.50000000000000000, 0.52359877559829882 },
|
622 |
|
|
{ 0.71164727562630326, 0.50000000000000000, 0.69813170079773179 },
|
623 |
|
|
{ 0.89824523594227768, 0.50000000000000000, 0.87266462599716477 },
|
624 |
|
|
{ 1.0895506700518851, 0.50000000000000000, 1.0471975511965976 },
|
625 |
|
|
{ 1.2853005857432933, 0.50000000000000000, 1.2217304763960306 },
|
626 |
|
|
{ 1.4845545520549484, 0.50000000000000000, 1.3962634015954636 },
|
627 |
|
|
{ 1.6857503548125963, 0.50000000000000000, 1.5707963267948966 },
|
628 |
|
|
};
|
629 |
|
|
|
630 |
|
|
// Test function for k=0.50000000000000000.
|
631 |
|
|
template <typename Tp>
|
632 |
|
|
void test015()
|
633 |
|
|
{
|
634 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
635 |
|
|
Tp max_abs_diff = -Tp(1);
|
636 |
|
|
Tp max_abs_frac = -Tp(1);
|
637 |
|
|
unsigned int num_datum = sizeof(data015)
|
638 |
|
|
/ sizeof(testcase_ellint_1<double>);
|
639 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
640 |
|
|
{
|
641 |
|
|
const Tp f = std::tr1::ellint_1(Tp(data015[i].k), Tp(data015[i].phi));
|
642 |
|
|
const Tp f0 = data015[i].f0;
|
643 |
|
|
const Tp diff = f - f0;
|
644 |
|
|
if (std::abs(diff) > max_abs_diff)
|
645 |
|
|
max_abs_diff = std::abs(diff);
|
646 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
647 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
648 |
|
|
{
|
649 |
|
|
const Tp frac = diff / f0;
|
650 |
|
|
if (std::abs(frac) > max_abs_frac)
|
651 |
|
|
max_abs_frac = std::abs(frac);
|
652 |
|
|
}
|
653 |
|
|
}
|
654 |
|
|
VERIFY(max_abs_frac < Tp(2.5000000000000020e-13));
|
655 |
|
|
}
|
656 |
|
|
|
657 |
|
|
// Test data for k=0.60000000000000009.
|
658 |
|
|
testcase_ellint_1<double> data016[] = {
|
659 |
|
|
{ -0.0000000000000000, 0.60000000000000009, 0.0000000000000000 },
|
660 |
|
|
{ 0.17485154362988362, 0.60000000000000009, 0.17453292519943295 },
|
661 |
|
|
{ 0.35160509865544326, 0.60000000000000009, 0.34906585039886590 },
|
662 |
|
|
{ 0.53210652578446160, 0.60000000000000009, 0.52359877559829882 },
|
663 |
|
|
{ 0.71805304664485670, 0.60000000000000009, 0.69813170079773179 },
|
664 |
|
|
{ 0.91082759030195970, 0.60000000000000009, 0.87266462599716477 },
|
665 |
|
|
{ 1.1112333229323366, 0.60000000000000009, 1.0471975511965976 },
|
666 |
|
|
{ 1.3191461190365270, 0.60000000000000009, 1.2217304763960306 },
|
667 |
|
|
{ 1.5332022105084775, 0.60000000000000009, 1.3962634015954636 },
|
668 |
|
|
{ 1.7507538029157526, 0.60000000000000009, 1.5707963267948966 },
|
669 |
|
|
};
|
670 |
|
|
|
671 |
|
|
// Test function for k=0.60000000000000009.
|
672 |
|
|
template <typename Tp>
|
673 |
|
|
void test016()
|
674 |
|
|
{
|
675 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
676 |
|
|
Tp max_abs_diff = -Tp(1);
|
677 |
|
|
Tp max_abs_frac = -Tp(1);
|
678 |
|
|
unsigned int num_datum = sizeof(data016)
|
679 |
|
|
/ sizeof(testcase_ellint_1<double>);
|
680 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
681 |
|
|
{
|
682 |
|
|
const Tp f = std::tr1::ellint_1(Tp(data016[i].k), Tp(data016[i].phi));
|
683 |
|
|
const Tp f0 = data016[i].f0;
|
684 |
|
|
const Tp diff = f - f0;
|
685 |
|
|
if (std::abs(diff) > max_abs_diff)
|
686 |
|
|
max_abs_diff = std::abs(diff);
|
687 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
688 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
689 |
|
|
{
|
690 |
|
|
const Tp frac = diff / f0;
|
691 |
|
|
if (std::abs(frac) > max_abs_frac)
|
692 |
|
|
max_abs_frac = std::abs(frac);
|
693 |
|
|
}
|
694 |
|
|
}
|
695 |
|
|
VERIFY(max_abs_frac < Tp(2.5000000000000020e-13));
|
696 |
|
|
}
|
697 |
|
|
|
698 |
|
|
// Test data for k=0.69999999999999996.
|
699 |
|
|
testcase_ellint_1<double> data017[] = {
|
700 |
|
|
{ -0.0000000000000000, 0.69999999999999996, 0.0000000000000000 },
|
701 |
|
|
{ 0.17496737466916720, 0.69999999999999996, 0.17453292519943295 },
|
702 |
|
|
{ 0.35254687535677925, 0.69999999999999996, 0.34906585039886590 },
|
703 |
|
|
{ 0.53536740275997130, 0.69999999999999996, 0.52359877559829882 },
|
704 |
|
|
{ 0.72603797651684465, 0.69999999999999996, 0.69813170079773179 },
|
705 |
|
|
{ 0.92698296348313458, 0.69999999999999996, 0.87266462599716477 },
|
706 |
|
|
{ 1.1400447527693316, 0.69999999999999996, 1.0471975511965976 },
|
707 |
|
|
{ 1.3657668117194071, 0.69999999999999996, 1.2217304763960306 },
|
708 |
|
|
{ 1.6024686895959159, 0.69999999999999996, 1.3962634015954636 },
|
709 |
|
|
{ 1.8456939983747236, 0.69999999999999996, 1.5707963267948966 },
|
710 |
|
|
};
|
711 |
|
|
|
712 |
|
|
// Test function for k=0.69999999999999996.
|
713 |
|
|
template <typename Tp>
|
714 |
|
|
void test017()
|
715 |
|
|
{
|
716 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
717 |
|
|
Tp max_abs_diff = -Tp(1);
|
718 |
|
|
Tp max_abs_frac = -Tp(1);
|
719 |
|
|
unsigned int num_datum = sizeof(data017)
|
720 |
|
|
/ sizeof(testcase_ellint_1<double>);
|
721 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
722 |
|
|
{
|
723 |
|
|
const Tp f = std::tr1::ellint_1(Tp(data017[i].k), Tp(data017[i].phi));
|
724 |
|
|
const Tp f0 = data017[i].f0;
|
725 |
|
|
const Tp diff = f - f0;
|
726 |
|
|
if (std::abs(diff) > max_abs_diff)
|
727 |
|
|
max_abs_diff = std::abs(diff);
|
728 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
729 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
730 |
|
|
{
|
731 |
|
|
const Tp frac = diff / f0;
|
732 |
|
|
if (std::abs(frac) > max_abs_frac)
|
733 |
|
|
max_abs_frac = std::abs(frac);
|
734 |
|
|
}
|
735 |
|
|
}
|
736 |
|
|
VERIFY(max_abs_frac < Tp(2.5000000000000020e-13));
|
737 |
|
|
}
|
738 |
|
|
|
739 |
|
|
// Test data for k=0.80000000000000004.
|
740 |
|
|
testcase_ellint_1<double> data018[] = {
|
741 |
|
|
{ -0.0000000000000000, 0.80000000000000004, 0.0000000000000000 },
|
742 |
|
|
{ 0.17510154241338902, 0.80000000000000004, 0.17453292519943295 },
|
743 |
|
|
{ 0.35365068839779390, 0.80000000000000004, 0.34906585039886590 },
|
744 |
|
|
{ 0.53926804409084561, 0.80000000000000004, 0.52359877559829882 },
|
745 |
|
|
{ 0.73587926028070383, 0.80000000000000004, 0.69813170079773179 },
|
746 |
|
|
{ 0.94770942970071170, 0.80000000000000004, 0.87266462599716477 },
|
747 |
|
|
{ 1.1789022995388239, 0.80000000000000004, 1.0471975511965976 },
|
748 |
|
|
{ 1.4323027881876009, 0.80000000000000004, 1.2217304763960306 },
|
749 |
|
|
{ 1.7069629739121674, 0.80000000000000004, 1.3962634015954636 },
|
750 |
|
|
{ 1.9953027776647296, 0.80000000000000004, 1.5707963267948966 },
|
751 |
|
|
};
|
752 |
|
|
|
753 |
|
|
// Test function for k=0.80000000000000004.
|
754 |
|
|
template <typename Tp>
|
755 |
|
|
void test018()
|
756 |
|
|
{
|
757 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
758 |
|
|
Tp max_abs_diff = -Tp(1);
|
759 |
|
|
Tp max_abs_frac = -Tp(1);
|
760 |
|
|
unsigned int num_datum = sizeof(data018)
|
761 |
|
|
/ sizeof(testcase_ellint_1<double>);
|
762 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
763 |
|
|
{
|
764 |
|
|
const Tp f = std::tr1::ellint_1(Tp(data018[i].k), Tp(data018[i].phi));
|
765 |
|
|
const Tp f0 = data018[i].f0;
|
766 |
|
|
const Tp diff = f - f0;
|
767 |
|
|
if (std::abs(diff) > max_abs_diff)
|
768 |
|
|
max_abs_diff = std::abs(diff);
|
769 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
770 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
771 |
|
|
{
|
772 |
|
|
const Tp frac = diff / f0;
|
773 |
|
|
if (std::abs(frac) > max_abs_frac)
|
774 |
|
|
max_abs_frac = std::abs(frac);
|
775 |
|
|
}
|
776 |
|
|
}
|
777 |
|
|
VERIFY(max_abs_frac < Tp(2.5000000000000020e-13));
|
778 |
|
|
}
|
779 |
|
|
|
780 |
|
|
// Test data for k=0.89999999999999991.
|
781 |
|
|
testcase_ellint_1<double> data019[] = {
|
782 |
|
|
{ -0.0000000000000000, 0.89999999999999991, 0.0000000000000000 },
|
783 |
|
|
{ 0.17525427376115027, 0.89999999999999991, 0.17453292519943295 },
|
784 |
|
|
{ 0.35492464591297446, 0.89999999999999991, 0.34906585039886590 },
|
785 |
|
|
{ 0.54388221416157123, 0.89999999999999991, 0.52359877559829882 },
|
786 |
|
|
{ 0.74797400423532501, 0.89999999999999991, 0.69813170079773179 },
|
787 |
|
|
{ 0.97463898451966458, 0.89999999999999991, 0.87266462599716477 },
|
788 |
|
|
{ 1.2334463254523438, 0.89999999999999991, 1.0471975511965976 },
|
789 |
|
|
{ 1.5355247765594910, 0.89999999999999991, 1.2217304763960306 },
|
790 |
|
|
{ 1.8882928567775117, 0.89999999999999991, 1.3962634015954636 },
|
791 |
|
|
{ 2.2805491384227699, 0.89999999999999991, 1.5707963267948966 },
|
792 |
|
|
};
|
793 |
|
|
|
794 |
|
|
// Test function for k=0.89999999999999991.
|
795 |
|
|
template <typename Tp>
|
796 |
|
|
void test019()
|
797 |
|
|
{
|
798 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
799 |
|
|
Tp max_abs_diff = -Tp(1);
|
800 |
|
|
Tp max_abs_frac = -Tp(1);
|
801 |
|
|
unsigned int num_datum = sizeof(data019)
|
802 |
|
|
/ sizeof(testcase_ellint_1<double>);
|
803 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
804 |
|
|
{
|
805 |
|
|
const Tp f = std::tr1::ellint_1(Tp(data019[i].k), Tp(data019[i].phi));
|
806 |
|
|
const Tp f0 = data019[i].f0;
|
807 |
|
|
const Tp diff = f - f0;
|
808 |
|
|
if (std::abs(diff) > max_abs_diff)
|
809 |
|
|
max_abs_diff = std::abs(diff);
|
810 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
811 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
812 |
|
|
{
|
813 |
|
|
const Tp frac = diff / f0;
|
814 |
|
|
if (std::abs(frac) > max_abs_frac)
|
815 |
|
|
max_abs_frac = std::abs(frac);
|
816 |
|
|
}
|
817 |
|
|
}
|
818 |
|
|
VERIFY(max_abs_frac < Tp(2.5000000000000020e-13));
|
819 |
|
|
}
|
820 |
|
|
|
821 |
|
|
int main(int, char**)
|
822 |
|
|
{
|
823 |
|
|
test001<double>();
|
824 |
|
|
test002<double>();
|
825 |
|
|
test003<double>();
|
826 |
|
|
test004<double>();
|
827 |
|
|
test005<double>();
|
828 |
|
|
test006<double>();
|
829 |
|
|
test007<double>();
|
830 |
|
|
test008<double>();
|
831 |
|
|
test009<double>();
|
832 |
|
|
test010<double>();
|
833 |
|
|
test011<double>();
|
834 |
|
|
test012<double>();
|
835 |
|
|
test013<double>();
|
836 |
|
|
test014<double>();
|
837 |
|
|
test015<double>();
|
838 |
|
|
test016<double>();
|
839 |
|
|
test017<double>();
|
840 |
|
|
test018<double>();
|
841 |
|
|
test019<double>();
|
842 |
|
|
return 0;
|
843 |
|
|
}
|