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 |
|
|
// riemann_zeta
|
21 |
|
|
|
22 |
565 |
jeremybenn |
// This can take long on simulators, timing out the test. Also change on
|
23 |
|
|
// OpenRISC linux, since this may be a remotely simulated target.
|
24 |
424 |
jeremybenn |
// { dg-options "-DMAX_ITERATIONS=5" { target simulator } }
|
25 |
565 |
jeremybenn |
// { dg-options "-DMAX_ITERATIONS=5" { target or32-*-linux } }
|
26 |
424 |
jeremybenn |
|
27 |
|
|
#ifndef MAX_ITERATIONS
|
28 |
|
|
#define MAX_ITERATIONS (sizeof(data001) / sizeof(testcase_riemann_zeta<double>))
|
29 |
|
|
#endif
|
30 |
|
|
|
31 |
|
|
// Compare against values generated by the GNU Scientific Library.
|
32 |
|
|
// The GSL can be found on the web: http://www.gnu.org/software/gsl/
|
33 |
|
|
|
34 |
|
|
#include <tr1/cmath>
|
35 |
|
|
#if defined(__TEST_DEBUG)
|
36 |
|
|
#include <iostream>
|
37 |
|
|
#define VERIFY(A) \
|
38 |
|
|
if (!(A)) \
|
39 |
|
|
{ \
|
40 |
|
|
std::cout << "line " << __LINE__ \
|
41 |
|
|
<< " max_abs_frac = " << max_abs_frac \
|
42 |
|
|
<< std::endl; \
|
43 |
|
|
}
|
44 |
|
|
#else
|
45 |
|
|
#include <testsuite_hooks.h>
|
46 |
|
|
#endif
|
47 |
|
|
#include "../testcase.h"
|
48 |
|
|
|
49 |
|
|
|
50 |
|
|
// Test data.
|
51 |
|
|
testcase_riemann_zeta<double> data001[] = {
|
52 |
|
|
{ 0.0000000000000000, -10.000000000000000 },
|
53 |
|
|
{ -0.0033669820451019579, -9.8000000000000007 },
|
54 |
|
|
{ -0.0058129517767319039, -9.5999999999999996 },
|
55 |
|
|
{ -0.0072908732290557004, -9.4000000000000004 },
|
56 |
|
|
{ -0.0078420910654484442, -9.1999999999999993 },
|
57 |
|
|
{ -0.0075757575757575803, -9.0000000000000000 },
|
58 |
|
|
{ -0.0066476555677551898, -8.8000000000000007 },
|
59 |
|
|
{ -0.0052400095350859429, -8.5999999999999996 },
|
60 |
|
|
{ -0.0035434308017674959, -8.4000000000000004 },
|
61 |
|
|
{ -0.0017417330388368585, -8.1999999999999993 },
|
62 |
|
|
{ 0.0000000000000000, -8.0000000000000000 },
|
63 |
|
|
{ 0.0015440036789213965, -7.7999999999999998 },
|
64 |
|
|
{ 0.0027852131086497423, -7.5999999999999996 },
|
65 |
|
|
{ 0.0036537321227995880, -7.4000000000000004 },
|
66 |
|
|
{ 0.0041147930817053468, -7.2000000000000002 },
|
67 |
|
|
{ 0.0041666666666666683, -7.0000000000000000 },
|
68 |
|
|
{ 0.0038369975032738366, -6.7999999999999998 },
|
69 |
|
|
{ 0.0031780270571782981, -6.5999999999999996 },
|
70 |
|
|
{ 0.0022611282027338573, -6.4000000000000004 },
|
71 |
|
|
{ 0.0011710237049390511, -6.2000000000000002 },
|
72 |
|
|
{ 0.0000000000000000, -6.0000000000000000 },
|
73 |
|
|
{ -0.0011576366649881879, -5.7999999999999998 },
|
74 |
|
|
{ -0.0022106784318564345, -5.5999999999999996 },
|
75 |
|
|
{ -0.0030755853460586891, -5.4000000000000004 },
|
76 |
|
|
{ -0.0036804380477934787, -5.2000000000000002 },
|
77 |
|
|
{ -0.0039682539682539698, -5.0000000000000000 },
|
78 |
|
|
{ -0.0038996891301999797, -4.7999999999999998 },
|
79 |
|
|
{ -0.0034551830834302711, -4.5999999999999996 },
|
80 |
|
|
{ -0.0026366345018725115, -4.4000000000000004 },
|
81 |
|
|
{ -0.0014687209305056974, -4.2000000000000002 },
|
82 |
|
|
{ 0.0000000000000000, -4.0000000000000000 },
|
83 |
|
|
{ 0.0016960463875825209, -3.7999999999999998 },
|
84 |
|
|
{ 0.0035198355903356747, -3.5999999999999996 },
|
85 |
|
|
{ 0.0053441503206513421, -3.4000000000000004 },
|
86 |
|
|
{ 0.0070119720770910540, -3.2000000000000002 },
|
87 |
|
|
{ 0.0083333333333333350, -3.0000000000000000 },
|
88 |
|
|
{ 0.0090807294856852811, -2.7999999999999998 },
|
89 |
|
|
{ 0.0089824623788396681, -2.5999999999999996 },
|
90 |
|
|
{ 0.0077130239874243630, -2.4000000000000004 },
|
91 |
|
|
{ 0.0048792123593036068, -2.2000000000000002 },
|
92 |
|
|
{ 0.0000000000000000, -2.0000000000000000 },
|
93 |
|
|
{ -0.0075229347765968010, -1.8000000000000007 },
|
94 |
|
|
{ -0.018448986678963775, -1.5999999999999996 },
|
95 |
|
|
{ -0.033764987694047593, -1.4000000000000004 },
|
96 |
|
|
{ -0.054788441243880631, -1.1999999999999993 },
|
97 |
|
|
{ -0.083333333333333398, -1.0000000000000000 },
|
98 |
|
|
{ -0.12198707766977103, -0.80000000000000071 },
|
99 |
|
|
{ -0.17459571193801401, -0.59999999999999964 },
|
100 |
|
|
{ -0.24716546083171492, -0.40000000000000036 },
|
101 |
|
|
{ -0.34966628059831484, -0.19999999999999929 },
|
102 |
|
|
{ -0.49999999999999994, 0.0000000000000000 },
|
103 |
|
|
{ -0.73392092489633953, 0.19999999999999929 },
|
104 |
|
|
{ -1.1347977838669825, 0.40000000000000036 },
|
105 |
|
|
{ -1.9526614482239983, 0.59999999999999964 },
|
106 |
|
|
{ -4.4375384158955677, 0.80000000000000071 },
|
107 |
|
|
};
|
108 |
|
|
|
109 |
|
|
// Test function.
|
110 |
|
|
template <typename Tp>
|
111 |
|
|
void test001()
|
112 |
|
|
{
|
113 |
|
|
const Tp eps = std::numeric_limits<Tp>::epsilon();
|
114 |
|
|
Tp max_abs_diff = -Tp(1);
|
115 |
|
|
Tp max_abs_frac = -Tp(1);
|
116 |
|
|
unsigned int num_datum = MAX_ITERATIONS;
|
117 |
|
|
for (unsigned int i = 0; i < num_datum; ++i)
|
118 |
|
|
{
|
119 |
|
|
const Tp f = std::tr1::riemann_zeta(Tp(data001[i].x));
|
120 |
|
|
const Tp f0 = data001[i].f0;
|
121 |
|
|
const Tp diff = f - f0;
|
122 |
|
|
if (std::abs(diff) > max_abs_diff)
|
123 |
|
|
max_abs_diff = std::abs(diff);
|
124 |
|
|
if (std::abs(f0) > Tp(10) * eps
|
125 |
|
|
&& std::abs(f) > Tp(10) * eps)
|
126 |
|
|
{
|
127 |
|
|
const Tp frac = diff / f0;
|
128 |
|
|
if (std::abs(frac) > max_abs_frac)
|
129 |
|
|
max_abs_frac = std::abs(frac);
|
130 |
|
|
}
|
131 |
|
|
}
|
132 |
|
|
VERIFY(max_abs_frac < Tp(5.0000000000000039e-13));
|
133 |
|
|
}
|
134 |
|
|
|
135 |
|
|
int main(int, char**)
|
136 |
|
|
{
|
137 |
|
|
test001<double>();
|
138 |
|
|
return 0;
|
139 |
|
|
}
|