]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/ext/special_functions/airy_bi/check_value.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / ext / special_functions / airy_bi / check_value.cc
CommitLineData
a7a389d6
ESR
1// { dg-do run { target c++11 } }
2// { dg-options "-D__STDCPP_WANT_MATH_SPEC_FUNCS__" }
e7f2d0bd 3// { dg-skip-if "no extensions in strict dialects" { *-*-* } { "-std=c++*" } }
a7a389d6 4//
7adcbafe 5// Copyright (C) 2016-2022 Free Software Foundation, Inc.
a7a389d6
ESR
6//
7// This file is part of the GNU ISO C++ Library. This library is free
8// software; you can redistribute it and/or modify it under the
9// terms of the GNU General Public License as published by the
10// Free Software Foundation; either version 3, or (at your option)
11// any later version.
12//
13// This library is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17//
18// You should have received a copy of the GNU General Public License along
19// with this library; see the file COPYING3. If not see
20// <http://www.gnu.org/licenses/>.
21
22// airy_bi
23
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/
26#include <limits>
27#include <cmath>
28#if defined(__TEST_DEBUG)
29# include <iostream>
30# define VERIFY(A) \
31 if (!(A)) \
32 { \
33 std::cout << "line " << __LINE__ \
34 << " max_abs_frac = " << max_abs_frac \
35 << std::endl; \
36 }
37#else
38# include <testsuite_hooks.h>
39#endif
40#include <specfun_testcase.h>
41
42// Test data.
43// max(|f - f_GSL|): 3.2782554626464844e-06 at index 40
44// max(|f - f_GSL| / |f_GSL|): 1.3623770134694109e-13
45// mean(f - f_GSL): -8.0102555317125191e-08
46// variance(f - f_GSL): 2.6209716422814286e-13
47// stddev(f - f_GSL): 5.1195425989842373e-07
48const testcase_airy_bi<double>
49data001[41] =
50{
51 { -0.31467982964383845, -10.000000000000000, 0.0 },
52 { 0.037785432489467467, -9.5000000000000000, 0.0 },
53 { 0.32494732345524480, -9.0000000000000000, 0.0 },
54 { 0.0077544364476580746, -8.5000000000000000, 0.0 },
55 { -0.33125158075113792, -8.0000000000000000, 0.0 },
56 { -0.11246348507649087, -7.5000000000000000, 0.0 },
57 { 0.29376207185441372, -7.0000000000000000, 0.0 },
58 { 0.26101265763648318, -6.5000000000000000, 0.0 },
59 { -0.14669837667055663, -6.0000000000000000, 0.0 },
60 { -0.36781345391571185, -5.5000000000000000, 0.0 },
61 { -0.13836913490160088, -5.0000000000000000, 0.0 },
62 { 0.25387265769693296, -4.5000000000000000, 0.0 },
63 { 0.39223470570699931, -4.0000000000000000, 0.0 },
64 { 0.16893983748105870, -3.5000000000000000, 0.0 },
65 { -0.19828962637492650, -3.0000000000000000, 0.0 },
66 { -0.43242247184070520, -2.5000000000000000, 0.0 },
67 { -0.41230258795639835, -2.0000000000000000, 0.0 },
68 { -0.19178486115704119, -1.5000000000000000, 0.0 },
69 { 0.10399738949694459, -1.0000000000000000, 0.0 },
70 { 0.38035265975105381, -0.50000000000000000, 0.0 },
71 { 0.61492662744600068, 0.0000000000000000, 0.0 },
72 { 0.85427704310315555, 0.50000000000000000, 0.0 },
73 { 1.2074235949528713, 1.0000000000000000, 0.0 },
74 { 1.8789415037478949, 1.5000000000000000, 0.0 },
75 { 3.2980949999782148, 2.0000000000000000, 0.0 },
76 { 6.4816607384605804, 2.5000000000000000, 0.0 },
77 { 14.037328963730236, 3.0000000000000000, 0.0 },
78 { 33.055506754611478, 3.5000000000000000, 0.0 },
79 { 83.847071408468111, 4.0000000000000000, 0.0 },
80 { 227.58808183559950, 4.5000000000000000, 0.0 },
81 { 657.79204417117160, 5.0000000000000000, 0.0 },
82 { 2016.5800386595315, 5.5000000000000000, 0.0 },
83 { 6536.4461048098583, 6.0000000000000000, 0.0 },
84 { 22340.607718396990, 6.5000000000000000, 0.0 },
85 { 80327.790709430337, 7.0000000000000000, 0.0 },
86 { 303229.61511253362, 7.5000000000000000, 0.0 },
87 { 1199586.0041244617, 8.0000000000000000, 0.0 },
88 { 4965319.5414712988, 8.5000000000000000, 0.0 },
89 { 21472868.891435351, 9.0000000000000000, 0.0 },
90 { 96892265.580451161, 9.5000000000000000, 0.0 },
91 { 455641153.54822654, 10.000000000000000, 0.0 },
92};
93const double toler001 = 1.0000000000000006e-11;
94
95template<typename Ret, unsigned int Num>
96 void
97 test(const testcase_airy_bi<Ret> (&data)[Num], Ret toler)
98 {
99 bool test __attribute__((unused)) = true;
100 const Ret eps = std::numeric_limits<Ret>::epsilon();
101 Ret max_abs_diff = -Ret(1);
102 Ret max_abs_frac = -Ret(1);
103 unsigned int num_datum = Num;
104 for (unsigned int i = 0; i < num_datum; ++i)
105 {
106 const Ret f = __gnu_cxx::airy_bi(data[i].x);
107 const Ret f0 = data[i].f0;
108 const Ret diff = f - f0;
109 if (std::abs(diff) > max_abs_diff)
110 max_abs_diff = std::abs(diff);
111 if (std::abs(f0) > Ret(10) * eps
112 && std::abs(f) > Ret(10) * eps)
113 {
114 const Ret frac = diff / f0;
115 if (std::abs(frac) > max_abs_frac)
116 max_abs_frac = std::abs(frac);
117 }
118 }
119 VERIFY(max_abs_frac < toler);
120 }
121
122int
123main()
124{
125 test(data001, toler001);
126 return 0;
127}