container_access.cc: Remove 'test' variables.
[official-gcc.git] / libstdc++-v3 / testsuite / special_functions / 04_comp_ellint_1 / check_value.cc
blob06de6fc1307496d2f05340e837ed69b4a44d349c
1 // { dg-do run { target c++11 } }
2 // { dg-options "-D__STDCPP_WANT_MATH_SPEC_FUNCS__" }
3 //
4 // Copyright (C) 2016 Free Software Foundation, Inc.
5 //
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
10 // any later version.
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING3. If not see
19 // <http://www.gnu.org/licenses/>.
21 // comp_ellint_1
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 #include <limits>
26 #include <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; \
36 #else
37 # include <testsuite_hooks.h>
38 #endif
39 #include <specfun_testcase.h>
41 // Test data.
42 // max(|f - f_GSL|): 6.6613381477509392e-16
43 // max(|f - f_GSL| / |f_GSL|): 4.0617918857203532e-16
44 const testcase_comp_ellint_1<double>
45 data001[19] =
47 { 2.2805491384227703, -0.90000000000000002 },
48 { 1.9953027776647296, -0.80000000000000004 },
49 { 1.8456939983747236, -0.69999999999999996 },
50 { 1.7507538029157526, -0.59999999999999998 },
51 { 1.6857503548125963, -0.50000000000000000 },
52 { 1.6399998658645112, -0.40000000000000002 },
53 { 1.6080486199305128, -0.30000000000000004 },
54 { 1.5868678474541660, -0.19999999999999996 },
55 { 1.5747455615173562, -0.099999999999999978 },
56 { 1.5707963267948966, 0.0000000000000000 },
57 { 1.5747455615173562, 0.10000000000000009 },
58 { 1.5868678474541660, 0.19999999999999996 },
59 { 1.6080486199305128, 0.30000000000000004 },
60 { 1.6399998658645112, 0.39999999999999991 },
61 { 1.6857503548125963, 0.50000000000000000 },
62 { 1.7507538029157526, 0.60000000000000009 },
63 { 1.8456939983747236, 0.69999999999999996 },
64 { 1.9953027776647296, 0.80000000000000004 },
65 { 2.2805491384227703, 0.89999999999999991 },
67 const double toler001 = 2.5000000000000020e-13;
69 template<typename Tp, unsigned int Num>
70 void
71 test(const testcase_comp_ellint_1<Tp> (&data)[Num], Tp toler)
73 const Tp eps = std::numeric_limits<Tp>::epsilon();
74 Tp max_abs_diff = -Tp(1);
75 Tp max_abs_frac = -Tp(1);
76 unsigned int num_datum = Num;
77 for (unsigned int i = 0; i < num_datum; ++i)
79 const Tp f = std::comp_ellint_1(data[i].k);
80 const Tp f0 = data[i].f0;
81 const Tp diff = f - f0;
82 if (std::abs(diff) > max_abs_diff)
83 max_abs_diff = std::abs(diff);
84 if (std::abs(f0) > Tp(10) * eps
85 && std::abs(f) > Tp(10) * eps)
87 const Tp frac = diff / f0;
88 if (std::abs(frac) > max_abs_frac)
89 max_abs_frac = std::abs(frac);
92 VERIFY(max_abs_frac < toler);
95 int
96 main()
98 test(data001, toler001);
99 return 0;