1 // 2007-02-04 Edward Smith-Rowland <3dw4rd@verizon.net>
3 // Copyright (C) 2007 Free Software Foundation, Inc.
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 2, or (at your option)
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.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
24 // Compare against values generated by the GNU Scientific Library.
25 // The GSL can be found on the web: http://www.gnu.org/software/gsl/
28 #if defined(__TEST_DEBUG)
33 std::cout << "line " << __LINE__ \
34 << " max_abs_frac = " << max_abs_frac \
38 #include <testsuite_hooks.h>
40 #include "../testcase.h"
44 testcase_riemann_zeta<double> data001[] = {
45 { 0.0000000000000000, -10.000000000000000 },
46 { -0.0033669820451019579, -9.8000000000000007 },
47 { -0.0058129517767319039, -9.5999999999999996 },
48 { -0.0072908732290557004, -9.4000000000000004 },
49 { -0.0078420910654484442, -9.1999999999999993 },
50 { -0.0075757575757575803, -9.0000000000000000 },
51 { -0.0066476555677551898, -8.8000000000000007 },
52 { -0.0052400095350859429, -8.5999999999999996 },
53 { -0.0035434308017674959, -8.4000000000000004 },
54 { -0.0017417330388368585, -8.1999999999999993 },
55 { 0.0000000000000000, -8.0000000000000000 },
56 { 0.0015440036789213965, -7.7999999999999998 },
57 { 0.0027852131086497423, -7.5999999999999996 },
58 { 0.0036537321227995880, -7.4000000000000004 },
59 { 0.0041147930817053468, -7.2000000000000002 },
60 { 0.0041666666666666683, -7.0000000000000000 },
61 { 0.0038369975032738366, -6.7999999999999998 },
62 { 0.0031780270571782981, -6.5999999999999996 },
63 { 0.0022611282027338573, -6.4000000000000004 },
64 { 0.0011710237049390511, -6.2000000000000002 },
65 { 0.0000000000000000, -6.0000000000000000 },
66 { -0.0011576366649881879, -5.7999999999999998 },
67 { -0.0022106784318564345, -5.5999999999999996 },
68 { -0.0030755853460586891, -5.4000000000000004 },
69 { -0.0036804380477934787, -5.2000000000000002 },
70 { -0.0039682539682539698, -5.0000000000000000 },
71 { -0.0038996891301999797, -4.7999999999999998 },
72 { -0.0034551830834302711, -4.5999999999999996 },
73 { -0.0026366345018725115, -4.4000000000000004 },
74 { -0.0014687209305056974, -4.2000000000000002 },
75 { 0.0000000000000000, -4.0000000000000000 },
76 { 0.0016960463875825209, -3.7999999999999998 },
77 { 0.0035198355903356747, -3.5999999999999996 },
78 { 0.0053441503206513421, -3.4000000000000004 },
79 { 0.0070119720770910540, -3.2000000000000002 },
80 { 0.0083333333333333350, -3.0000000000000000 },
81 { 0.0090807294856852811, -2.7999999999999998 },
82 { 0.0089824623788396681, -2.5999999999999996 },
83 { 0.0077130239874243630, -2.4000000000000004 },
84 { 0.0048792123593036068, -2.2000000000000002 },
85 { 0.0000000000000000, -2.0000000000000000 },
86 { -0.0075229347765968010, -1.8000000000000007 },
87 { -0.018448986678963775, -1.5999999999999996 },
88 { -0.033764987694047593, -1.4000000000000004 },
89 { -0.054788441243880631, -1.1999999999999993 },
90 { -0.083333333333333398, -1.0000000000000000 },
91 { -0.12198707766977103, -0.80000000000000071 },
92 { -0.17459571193801401, -0.59999999999999964 },
93 { -0.24716546083171492, -0.40000000000000036 },
94 { -0.34966628059831484, -0.19999999999999929 },
95 { -0.49999999999999994, 0.0000000000000000 },
96 { -0.73392092489633953, 0.19999999999999929 },
97 { -1.1347977838669825, 0.40000000000000036 },
98 { -1.9526614482239983, 0.59999999999999964 },
99 { -4.4375384158955677, 0.80000000000000071 },
103 template <typename Tp>
106 const Tp eps = std::numeric_limits<Tp>::epsilon();
107 Tp max_abs_diff = -Tp(1);
108 Tp max_abs_frac = -Tp(1);
109 unsigned int num_datum = sizeof(data001)
110 / sizeof(testcase_riemann_zeta<double>);
111 for (unsigned int i = 0; i < num_datum; ++i)
113 const Tp f = std::tr1::riemann_zeta(Tp(data001[i].x));
114 const Tp f0 = data001[i].f0;
115 const Tp diff = f - f0;
116 if (std::abs(diff) > max_abs_diff)
117 max_abs_diff = std::abs(diff);
118 if (std::abs(f0) > Tp(10) * eps
119 && std::abs(f) > Tp(10) * eps)
121 const Tp frac = diff / f0;
122 if (std::abs(frac) > max_abs_frac)
123 max_abs_frac = std::abs(frac);
126 VERIFY(max_abs_frac < Tp(5.0000000000000039e-13));
129 int main(int, char**)