]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/15_expint/check_value_neg.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / tr1 / 5_numerical_facilities / special_functions / 15_expint / check_value_neg.cc
CommitLineData
b34f60ac 1// 2007-02-04 Edward Smith-Rowland <3dw4rd@verizon.net>
2//
f1717362 3// Copyright (C) 2007-2016 Free Software Foundation, Inc.
b34f60ac 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
6bc9506f 8// Free Software Foundation; either version 3, or (at your option)
b34f60ac 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
6bc9506f 17// with this library; see the file COPYING3. If not see
18// <http://www.gnu.org/licenses/>.
b34f60ac 19
20// expint
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_expint<double> data001[] = {
44 { -3.7832640295504591e-24, -50.000000000000000 },
45 { -1.0489811642368024e-23, -49.000000000000000 },
46 { -2.9096641904058423e-23, -48.000000000000000 },
47 { -8.0741978427258127e-23, -47.000000000000000 },
48 { -2.2415317597442998e-22, -46.000000000000000 },
49 { -6.2256908094623838e-22, -45.000000000000000 },
50 { -1.7299598742816476e-21, -44.000000000000000 },
51 { -4.8094965569500181e-21, -43.000000000000000 },
52 { -1.3377908810011775e-20, -42.000000000000000 },
53 { -3.7231667764599780e-20, -41.000000000000000 },
54 { -1.0367732614516570e-19, -40.000000000000000 },
55 { -2.8887793015227007e-19, -39.000000000000000 },
56 { -8.0541069142907499e-19, -38.000000000000000 },
57 { -2.2470206975885714e-18, -37.000000000000000 },
58 { -6.2733390097622421e-18, -36.000000000000000 },
59 { -1.7527059389947371e-17, -35.000000000000000 },
60 { -4.9006761183927874e-17, -34.000000000000000 },
61 { -1.3713843484487468e-16, -33.000000000000000 },
62 { -3.8409618012250666e-16, -32.000000000000000 },
63 { -1.0767670386162383e-15, -31.000000000000000 },
64 { -3.0215520106888128e-15, -30.000000000000000 },
65 { -8.4877597783535618e-15, -29.000000000000000 },
66 { -2.3869415119337330e-14, -28.000000000000000 },
67 { -6.7206374352620390e-14, -27.000000000000000 },
68 { -1.8946858856749785e-13, -26.000000000000000 },
69 { -5.3488997553402167e-13, -25.000000000000000 },
70 { -1.5123058939997059e-12, -24.000000000000000 },
71 { -4.2826847956656722e-12, -23.000000000000000 },
72 { -1.2149378956204371e-11, -22.000000000000000 },
73 { -3.4532012671467559e-11, -21.000000000000000 },
74 { -9.8355252906498815e-11, -20.000000000000000 },
75 { -2.8078290970607954e-10, -19.000000000000000 },
76 { -8.0360903448286769e-10, -18.000000000000000 },
77 { -2.3064319898216547e-09, -17.000000000000000 },
78 { -6.6404872494410427e-09, -16.000000000000000 },
79 { -1.9186278921478670e-08, -15.000000000000000 },
80 { -5.5656311111451816e-08, -14.000000000000000 },
81 { -1.6218662188014328e-07, -13.000000000000000 },
82 { -4.7510818246724931e-07, -12.000000000000000 },
83 { -1.4003003042474418e-06, -11.000000000000000 },
84 { -4.1569689296853246e-06, -10.000000000000000 },
85 { -1.2447354178006272e-05, -9.0000000000000000 },
86 { -3.7665622843924906e-05, -8.0000000000000000 },
87 { -0.00011548173161033820, -7.0000000000000000 },
88 { -0.00036008245216265867, -6.0000000000000000 },
89 { -0.0011482955912753257, -5.0000000000000000 },
90 { -0.0037793524098489058, -4.0000000000000000 },
91 { -0.013048381094197037, -3.0000000000000000 },
92 { -0.048900510708061125, -2.0000000000000000 },
93 { -0.21938393439552029, -1.0000000000000000 },
94};
95
96// Test function.
97template <typename Tp>
98void test001()
99{
100 const Tp eps = std::numeric_limits<Tp>::epsilon();
101 Tp max_abs_diff = -Tp(1);
102 Tp max_abs_frac = -Tp(1);
103 unsigned int num_datum = sizeof(data001)
104 / sizeof(testcase_expint<double>);
105 for (unsigned int i = 0; i < num_datum; ++i)
106 {
107 const Tp f = std::tr1::expint(Tp(data001[i].x));
108 const Tp f0 = data001[i].f0;
109 const Tp diff = f - f0;
110 if (std::abs(diff) > max_abs_diff)
111 max_abs_diff = std::abs(diff);
112 if (std::abs(f0) > Tp(10) * eps
113 && std::abs(f) > Tp(10) * eps)
114 {
115 const Tp frac = diff / f0;
116 if (std::abs(frac) > max_abs_frac)
117 max_abs_frac = std::abs(frac);
118 }
119 }
120 VERIFY(max_abs_frac < Tp(2.5000000000000020e-13));
121}
122
123int main(int, char**)
124{
125 test001<double>();
126 return 0;
127}