]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/05_comp_ellint_2/check_value.cc
Update copyright years in libstdc++-v3/
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / tr1 / 5_numerical_facilities / special_functions / 05_comp_ellint_2 / check_value.cc
CommitLineData
7c62b943
BK
1// 2007-02-04 Edward Smith-Rowland <3dw4rd@verizon.net>
2//
aa118a03 3// Copyright (C) 2007-2014 Free Software Foundation, Inc.
7c62b943
BK
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
748086b7 8// Free Software Foundation; either version 3, or (at your option)
7c62b943
BK
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
748086b7
JJ
17// with this library; see the file COPYING3. If not see
18// <http://www.gnu.org/licenses/>.
7c62b943
BK
19
20// comp_ellint_2
21
22
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
26#include <tr1/cmath>
27#if defined(__TEST_DEBUG)
28#include <iostream>
29#define VERIFY(A) \
30if (!(A)) \
31 { \
32 std::cout << "line " << __LINE__ \
33 << " max_abs_frac = " << max_abs_frac \
34 << std::endl; \
35 }
36#else
37#include <testsuite_hooks.h>
38#endif
39#include "../testcase.h"
40
41
42// Test data.
43testcase_comp_ellint_2<double> data001[] = {
44 { 1.1716970527816140, -0.90000000000000002 },
45 { 1.2763499431699066, -0.80000000000000004 },
46 { 1.3556611355719557, -0.69999999999999996 },
47 { 1.4180833944487243, -0.59999999999999998 },
48 { 1.4674622093394274, -0.50000000000000000 },
49 { 1.5059416123600402, -0.40000000000000002 },
50 { 1.5348334649232489, -0.30000000000000004 },
51 { 1.5549685462425296, -0.19999999999999996 },
52 { 1.5668619420216685, -0.099999999999999978 },
53 { 1.5707963267948966, 0.0000000000000000 },
54 { 1.5668619420216685, 0.10000000000000009 },
55 { 1.5549685462425296, 0.19999999999999996 },
56 { 1.5348334649232489, 0.30000000000000004 },
57 { 1.5059416123600404, 0.39999999999999991 },
58 { 1.4674622093394274, 0.50000000000000000 },
59 { 1.4180833944487241, 0.60000000000000009 },
60 { 1.3556611355719557, 0.69999999999999996 },
61 { 1.2763499431699066, 0.80000000000000004 },
62 { 1.1716970527816142, 0.89999999999999991 },
63};
64
65// Test function.
66template <typename Tp>
67void test001()
68{
69 const Tp eps = std::numeric_limits<Tp>::epsilon();
70 Tp max_abs_diff = -Tp(1);
71 Tp max_abs_frac = -Tp(1);
72 unsigned int num_datum = sizeof(data001)
73 / sizeof(testcase_comp_ellint_2<double>);
74 for (unsigned int i = 0; i < num_datum; ++i)
75 {
76 const Tp f = std::tr1::comp_ellint_2(Tp(data001[i].k));
77 const Tp f0 = data001[i].f0;
78 const Tp diff = f - f0;
79 if (std::abs(diff) > max_abs_diff)
80 max_abs_diff = std::abs(diff);
81 if (std::abs(f0) > Tp(10) * eps
82 && std::abs(f) > Tp(10) * eps)
83 {
84 const Tp frac = diff / f0;
85 if (std::abs(frac) > max_abs_frac)
86 max_abs_frac = std::abs(frac);
87 }
88 }
89 VERIFY(max_abs_frac < Tp(5.0000000000000039e-13));
90}
91
92int main(int, char**)
93{
94 test001<double>();
95 return 0;
96}