diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/15_expint | |
download | cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2 cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/15_expint')
5 files changed, 393 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/15_expint/check_nan.cc b/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/15_expint/check_nan.cc new file mode 100644 index 000000000..977f3c55e --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/15_expint/check_nan.cc @@ -0,0 +1,57 @@ +// { dg-require-c-std "" } +// { dg-add-options ieee } + +// 2007-01-10 Edward Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2006-2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 5.2.1.15 expint + +#include <tr1/cmath> +#include <testsuite_hooks.h> + +void +test01() +{ + + float xf = std::numeric_limits<float>::quiet_NaN(); + double xd = std::numeric_limits<double>::quiet_NaN(); + long double xl = std::numeric_limits<long double>::quiet_NaN(); + + float a = std::tr1::expint(xf); + float b = std::tr1::expintf(xf); + double c = std::tr1::expint(xd); + long double d = std::tr1::expint(xl); + long double e = std::tr1::expintl(xl); + + VERIFY(std::tr1::isnan<float>(a)); + VERIFY(std::tr1::isnan<float>(b)); + VERIFY(std::tr1::isnan<double>(c)); + VERIFY(std::tr1::isnan<long double>(d)); + VERIFY(std::tr1::isnan<long double>(e)); + + return; +} + +int +main() +{ + test01(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/15_expint/check_value_neg.cc b/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/15_expint/check_value_neg.cc new file mode 100644 index 000000000..acb51a430 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/15_expint/check_value_neg.cc @@ -0,0 +1,127 @@ +// 2007-02-04 Edward Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// expint + + +// Compare against values generated by the GNU Scientific Library. +// The GSL can be found on the web: http://www.gnu.org/software/gsl/ + +#include <tr1/cmath> +#if defined(__TEST_DEBUG) +#include <iostream> +#define VERIFY(A) \ +if (!(A)) \ + { \ + std::cout << "line " << __LINE__ \ + << " max_abs_frac = " << max_abs_frac \ + << std::endl; \ + } +#else +#include <testsuite_hooks.h> +#endif +#include "../testcase.h" + + +// Test data. +testcase_expint<double> data001[] = { + { -3.7832640295504591e-24, -50.000000000000000 }, + { -1.0489811642368024e-23, -49.000000000000000 }, + { -2.9096641904058423e-23, -48.000000000000000 }, + { -8.0741978427258127e-23, -47.000000000000000 }, + { -2.2415317597442998e-22, -46.000000000000000 }, + { -6.2256908094623838e-22, -45.000000000000000 }, + { -1.7299598742816476e-21, -44.000000000000000 }, + { -4.8094965569500181e-21, -43.000000000000000 }, + { -1.3377908810011775e-20, -42.000000000000000 }, + { -3.7231667764599780e-20, -41.000000000000000 }, + { -1.0367732614516570e-19, -40.000000000000000 }, + { -2.8887793015227007e-19, -39.000000000000000 }, + { -8.0541069142907499e-19, -38.000000000000000 }, + { -2.2470206975885714e-18, -37.000000000000000 }, + { -6.2733390097622421e-18, -36.000000000000000 }, + { -1.7527059389947371e-17, -35.000000000000000 }, + { -4.9006761183927874e-17, -34.000000000000000 }, + { -1.3713843484487468e-16, -33.000000000000000 }, + { -3.8409618012250666e-16, -32.000000000000000 }, + { -1.0767670386162383e-15, -31.000000000000000 }, + { -3.0215520106888128e-15, -30.000000000000000 }, + { -8.4877597783535618e-15, -29.000000000000000 }, + { -2.3869415119337330e-14, -28.000000000000000 }, + { -6.7206374352620390e-14, -27.000000000000000 }, + { -1.8946858856749785e-13, -26.000000000000000 }, + { -5.3488997553402167e-13, -25.000000000000000 }, + { -1.5123058939997059e-12, -24.000000000000000 }, + { -4.2826847956656722e-12, -23.000000000000000 }, + { -1.2149378956204371e-11, -22.000000000000000 }, + { -3.4532012671467559e-11, -21.000000000000000 }, + { -9.8355252906498815e-11, -20.000000000000000 }, + { -2.8078290970607954e-10, -19.000000000000000 }, + { -8.0360903448286769e-10, -18.000000000000000 }, + { -2.3064319898216547e-09, -17.000000000000000 }, + { -6.6404872494410427e-09, -16.000000000000000 }, + { -1.9186278921478670e-08, -15.000000000000000 }, + { -5.5656311111451816e-08, -14.000000000000000 }, + { -1.6218662188014328e-07, -13.000000000000000 }, + { -4.7510818246724931e-07, -12.000000000000000 }, + { -1.4003003042474418e-06, -11.000000000000000 }, + { -4.1569689296853246e-06, -10.000000000000000 }, + { -1.2447354178006272e-05, -9.0000000000000000 }, + { -3.7665622843924906e-05, -8.0000000000000000 }, + { -0.00011548173161033820, -7.0000000000000000 }, + { -0.00036008245216265867, -6.0000000000000000 }, + { -0.0011482955912753257, -5.0000000000000000 }, + { -0.0037793524098489058, -4.0000000000000000 }, + { -0.013048381094197037, -3.0000000000000000 }, + { -0.048900510708061125, -2.0000000000000000 }, + { -0.21938393439552029, -1.0000000000000000 }, +}; + +// Test function. +template <typename Tp> +void test001() +{ + const Tp eps = std::numeric_limits<Tp>::epsilon(); + Tp max_abs_diff = -Tp(1); + Tp max_abs_frac = -Tp(1); + unsigned int num_datum = sizeof(data001) + / sizeof(testcase_expint<double>); + for (unsigned int i = 0; i < num_datum; ++i) + { + const Tp f = std::tr1::expint(Tp(data001[i].x)); + const Tp f0 = data001[i].f0; + const Tp diff = f - f0; + if (std::abs(diff) > max_abs_diff) + max_abs_diff = std::abs(diff); + if (std::abs(f0) > Tp(10) * eps + && std::abs(f) > Tp(10) * eps) + { + const Tp frac = diff / f0; + if (std::abs(frac) > max_abs_frac) + max_abs_frac = std::abs(frac); + } + } + VERIFY(max_abs_frac < Tp(2.5000000000000020e-13)); +} + +int main(int, char**) +{ + test001<double>(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/15_expint/check_value_pos.cc b/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/15_expint/check_value_pos.cc new file mode 100644 index 000000000..249a3f092 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/15_expint/check_value_pos.cc @@ -0,0 +1,127 @@ +// 2007-02-04 Edward Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// expint + + +// Compare against values generated by the GNU Scientific Library. +// The GSL can be found on the web: http://www.gnu.org/software/gsl/ + +#include <tr1/cmath> +#if defined(__TEST_DEBUG) +#include <iostream> +#define VERIFY(A) \ +if (!(A)) \ + { \ + std::cout << "line " << __LINE__ \ + << " max_abs_frac = " << max_abs_frac \ + << std::endl; \ + } +#else +#include <testsuite_hooks.h> +#endif +#include "../testcase.h" + + +// Test data. +testcase_expint<double> data001[] = { + { 1.8951178163559366, 1.0000000000000000 }, + { 4.9542343560018907, 2.0000000000000000 }, + { 9.9338325706254160, 3.0000000000000000 }, + { 19.630874470056217, 4.0000000000000000 }, + { 40.185275355803178, 5.0000000000000000 }, + { 85.989762142439204, 6.0000000000000000 }, + { 191.50474333550139, 7.0000000000000000 }, + { 440.37989953483827, 8.0000000000000000 }, + { 1037.8782907170896, 9.0000000000000000 }, + { 2492.2289762418782, 10.000000000000000 }, + { 6071.4063740986112, 11.000000000000000 }, + { 14959.532666397527, 12.000000000000000 }, + { 37197.688490689041, 13.000000000000000 }, + { 93192.513633965369, 14.000000000000000 }, + { 234955.85249076830, 15.000000000000000 }, + { 595560.99867083703, 16.000000000000000 }, + { 1516637.8940425171, 17.000000000000000 }, + { 3877904.3305974435, 18.000000000000000 }, + { 9950907.2510468438, 19.000000000000000 }, + { 25615652.664056588, 20.000000000000000 }, + { 66127186.355484918, 21.000000000000000 }, + { 171144671.30036369, 22.000000000000000 }, + { 443966369.83027118, 23.000000000000000 }, + { 1154115391.8491828, 24.000000000000000 }, + { 3005950906.5255489, 25.000000000000000 }, + { 7842940991.8981876, 26.000000000000000 }, + { 20496497119.880810, 27.000000000000000 }, + { 53645118592.314682, 28.000000000000000 }, + { 140599195758.40689, 29.000000000000000 }, + { 368973209407.27423, 30.000000000000000 }, + { 969455575968.39392, 31.000000000000000 }, + { 2550043566357.7866, 32.000000000000000 }, + { 6714640184076.4980, 33.000000000000000 }, + { 17698037244116.266, 34.000000000000000 }, + { 46690550144661.594, 35.000000000000000 }, + { 123285207991209.75, 36.000000000000000 }, + { 325798899867226.44, 37.000000000000000 }, + { 861638819996578.62, 38.000000000000000 }, + { 2280446200301902.5, 39.000000000000000 }, + { 6039718263611242.0, 40.000000000000000 }, + { 16006649143245042., 41.000000000000000 }, + { 42447960921368504., 42.000000000000000 }, + { 1.1263482901669667e+17, 43.000000000000000 }, + { 2.9904447186323366e+17, 44.000000000000000 }, + { 7.9439160357044531e+17, 45.000000000000000 }, + { 2.1113423886478239e+18, 46.000000000000000 }, + { 5.6143296808103434e+18, 47.000000000000000 }, + { 1.4936302131129930e+19, 48.000000000000000 }, + { 3.9754427479037444e+19, 49.000000000000000 }, + { 1.0585636897131690e+20, 50.000000000000000 }, +}; + +// Test function. +template <typename Tp> +void test001() +{ + const Tp eps = std::numeric_limits<Tp>::epsilon(); + Tp max_abs_diff = -Tp(1); + Tp max_abs_frac = -Tp(1); + unsigned int num_datum = sizeof(data001) + / sizeof(testcase_expint<double>); + for (unsigned int i = 0; i < num_datum; ++i) + { + const Tp f = std::tr1::expint(Tp(data001[i].x)); + const Tp f0 = data001[i].f0; + const Tp diff = f - f0; + if (std::abs(diff) > max_abs_diff) + max_abs_diff = std::abs(diff); + if (std::abs(f0) > Tp(10) * eps + && std::abs(f) > Tp(10) * eps) + { + const Tp frac = diff / f0; + if (std::abs(frac) > max_abs_frac) + max_abs_frac = std::abs(frac); + } + } + VERIFY(max_abs_frac < Tp(2.5000000000000020e-13)); +} + +int main(int, char**) +{ + test001<double>(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/15_expint/compile.cc b/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/15_expint/compile.cc new file mode 100644 index 000000000..c241aca73 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/15_expint/compile.cc @@ -0,0 +1,41 @@ +// { dg-do compile } + +// 2006-02-04 Edward Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2006-2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 5.2.1.15 expint + +#include <tr1/cmath> + +void +test01() +{ + float xf = 0.5F; + double xd = 0.5; + long double xl = 0.5L; + + std::tr1::expint(xf); + std::tr1::expintf(xf); + std::tr1::expint(xd); + std::tr1::expint(xl); + std::tr1::expintl(xl); + + return; +} + diff --git a/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/15_expint/compile_2.cc b/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/15_expint/compile_2.cc new file mode 100644 index 000000000..6a3238d20 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/15_expint/compile_2.cc @@ -0,0 +1,41 @@ +// { dg-do compile } + +// 2006-02-04 Edward Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2006-2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 5.2.1.15 expint + +#include <tr1/math.h> + +void +test01() +{ + float xf = 0.5F; + double xd = 0.5; + long double xl = 0.5L; + + expint(xf); + expintf(xf); + expint(xd); + expint(xl); + expintl(xl); + + return; +} + |