]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/ext/special_functions/airy_bi/check_value.cc
specfun.h: Expose airy_ai and airy_bi.
[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__" }
3//
4// Copyright (C) 2016-2017 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.
11//
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.
16//
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/>.
20
21// airy_bi
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#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; \
35 }
36#else
37# include <testsuite_hooks.h>
38#endif
39#include <specfun_testcase.h>
40
41// Test data.
42// max(|f - f_GSL|): 3.2782554626464844e-06 at index 40
43// max(|f - f_GSL| / |f_GSL|): 1.3623770134694109e-13
44// mean(f - f_GSL): -8.0102555317125191e-08
45// variance(f - f_GSL): 2.6209716422814286e-13
46// stddev(f - f_GSL): 5.1195425989842373e-07
47const testcase_airy_bi<double>
48data001[41] =
49{
50 { -0.31467982964383845, -10.000000000000000, 0.0 },
51 { 0.037785432489467467, -9.5000000000000000, 0.0 },
52 { 0.32494732345524480, -9.0000000000000000, 0.0 },
53 { 0.0077544364476580746, -8.5000000000000000, 0.0 },
54 { -0.33125158075113792, -8.0000000000000000, 0.0 },
55 { -0.11246348507649087, -7.5000000000000000, 0.0 },
56 { 0.29376207185441372, -7.0000000000000000, 0.0 },
57 { 0.26101265763648318, -6.5000000000000000, 0.0 },
58 { -0.14669837667055663, -6.0000000000000000, 0.0 },
59 { -0.36781345391571185, -5.5000000000000000, 0.0 },
60 { -0.13836913490160088, -5.0000000000000000, 0.0 },
61 { 0.25387265769693296, -4.5000000000000000, 0.0 },
62 { 0.39223470570699931, -4.0000000000000000, 0.0 },
63 { 0.16893983748105870, -3.5000000000000000, 0.0 },
64 { -0.19828962637492650, -3.0000000000000000, 0.0 },
65 { -0.43242247184070520, -2.5000000000000000, 0.0 },
66 { -0.41230258795639835, -2.0000000000000000, 0.0 },
67 { -0.19178486115704119, -1.5000000000000000, 0.0 },
68 { 0.10399738949694459, -1.0000000000000000, 0.0 },
69 { 0.38035265975105381, -0.50000000000000000, 0.0 },
70 { 0.61492662744600068, 0.0000000000000000, 0.0 },
71 { 0.85427704310315555, 0.50000000000000000, 0.0 },
72 { 1.2074235949528713, 1.0000000000000000, 0.0 },
73 { 1.8789415037478949, 1.5000000000000000, 0.0 },
74 { 3.2980949999782148, 2.0000000000000000, 0.0 },
75 { 6.4816607384605804, 2.5000000000000000, 0.0 },
76 { 14.037328963730236, 3.0000000000000000, 0.0 },
77 { 33.055506754611478, 3.5000000000000000, 0.0 },
78 { 83.847071408468111, 4.0000000000000000, 0.0 },
79 { 227.58808183559950, 4.5000000000000000, 0.0 },
80 { 657.79204417117160, 5.0000000000000000, 0.0 },
81 { 2016.5800386595315, 5.5000000000000000, 0.0 },
82 { 6536.4461048098583, 6.0000000000000000, 0.0 },
83 { 22340.607718396990, 6.5000000000000000, 0.0 },
84 { 80327.790709430337, 7.0000000000000000, 0.0 },
85 { 303229.61511253362, 7.5000000000000000, 0.0 },
86 { 1199586.0041244617, 8.0000000000000000, 0.0 },
87 { 4965319.5414712988, 8.5000000000000000, 0.0 },
88 { 21472868.891435351, 9.0000000000000000, 0.0 },
89 { 96892265.580451161, 9.5000000000000000, 0.0 },
90 { 455641153.54822654, 10.000000000000000, 0.0 },
91};
92const double toler001 = 1.0000000000000006e-11;
93
94template<typename Ret, unsigned int Num>
95 void
96 test(const testcase_airy_bi<Ret> (&data)[Num], Ret toler)
97 {
98 bool test __attribute__((unused)) = true;
99 const Ret eps = std::numeric_limits<Ret>::epsilon();
100 Ret max_abs_diff = -Ret(1);
101 Ret max_abs_frac = -Ret(1);
102 unsigned int num_datum = Num;
103 for (unsigned int i = 0; i < num_datum; ++i)
104 {
105 const Ret f = __gnu_cxx::airy_bi(data[i].x);
106 const Ret f0 = data[i].f0;
107 const Ret diff = f - f0;
108 if (std::abs(diff) > max_abs_diff)
109 max_abs_diff = std::abs(diff);
110 if (std::abs(f0) > Ret(10) * eps
111 && std::abs(f) > Ret(10) * eps)
112 {
113 const Ret frac = diff / f0;
114 if (std::abs(frac) > max_abs_frac)
115 max_abs_frac = std::abs(frac);
116 }
117 }
118 VERIFY(max_abs_frac < toler);
119 }
120
121int
122main()
123{
124 test(data001, toler001);
125 return 0;
126}