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