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