aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Smith-Rowland <3dw4rd@verizon.net>2017-04-20 15:41:59 +0000
committerEdward Smith-Rowland <3dw4rd@verizon.net>2017-04-20 15:41:59 +0000
commitef406f703bfff4473d4f7854fb132783b5f21e83 (patch)
tree2ce615d6767af9d638b710fbd175adef0707963d
parent41ca86ba83b498d01731ad18edf94537c890707a (diff)
2017-04-20 Edward Smith-Rowland <3dw4rd@verizon.net>
PR libstdc++/68397 std::tr1::expint fails ... long double arguments. * include/tr1/exp_integral.tcc: Increase iteration limits. * testsuite/tr1/5_numerical_facilities/special_functions/15_expint/ pr68397.cc: New test. * testsuite/special_functions/14_expint/pr68397.cc: New test. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@247027 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libstdc++-v3/ChangeLog8
-rw-r--r--libstdc++-v3/include/tr1/exp_integral.tcc6
-rw-r--r--libstdc++-v3/testsuite/special_functions/14_expint/pr68397.cc47
-rw-r--r--libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/15_expint/pr68397.cc46
4 files changed, 104 insertions, 3 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index fa79d16c73f..7fb199875f2 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,11 @@
+2017-04-20 Edward Smith-Rowland <3dw4rd@verizon.net>
+
+ PR libstdc++/68397 std::tr1::expint fails ... long double arguments.
+ * include/tr1/exp_integral.tcc: Increase iteration limits.
+ * testsuite/tr1/5_numerical_facilities/special_functions/15_expint/
+ pr68397.cc: New test.
+ * testsuite/special_functions/14_expint/pr68397.cc: New test.
+
2017-04-20 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/79862
diff --git a/libstdc++-v3/include/tr1/exp_integral.tcc b/libstdc++-v3/include/tr1/exp_integral.tcc
index f33f234e6f6..8e6f55178e7 100644
--- a/libstdc++-v3/include/tr1/exp_integral.tcc
+++ b/libstdc++-v3/include/tr1/exp_integral.tcc
@@ -86,7 +86,7 @@ namespace tr1
_Tp __term = _Tp(1);
_Tp __esum = _Tp(0);
_Tp __osum = _Tp(0);
- const unsigned int __max_iter = 100;
+ const unsigned int __max_iter = 1000;
for (unsigned int __i = 1; __i < __max_iter; ++__i)
{
__term *= - __x / __i;
@@ -156,7 +156,7 @@ namespace tr1
_Tp
__expint_En_series(unsigned int __n, _Tp __x)
{
- const unsigned int __max_iter = 100;
+ const unsigned int __max_iter = 1000;
const _Tp __eps = std::numeric_limits<_Tp>::epsilon();
const int __nm1 = __n - 1;
_Tp __ans = (__nm1 != 0
@@ -202,7 +202,7 @@ namespace tr1
_Tp
__expint_En_cont_frac(unsigned int __n, _Tp __x)
{
- const unsigned int __max_iter = 100;
+ const unsigned int __max_iter = 1000;
const _Tp __eps = std::numeric_limits<_Tp>::epsilon();
const _Tp __fp_min = std::numeric_limits<_Tp>::min();
const int __nm1 = __n - 1;
diff --git a/libstdc++-v3/testsuite/special_functions/14_expint/pr68397.cc b/libstdc++-v3/testsuite/special_functions/14_expint/pr68397.cc
new file mode 100644
index 00000000000..8da16d1fc69
--- /dev/null
+++ b/libstdc++-v3/testsuite/special_functions/14_expint/pr68397.cc
@@ -0,0 +1,47 @@
+// { dg-do run { target c++11 } }
+// { dg-options "-D__STDCPP_WANT_MATH_SPEC_FUNCS__" }
+// Copyright (C) 2017 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/>.
+
+// PR libstdc++/68397 - std::tr1::expint fails in __expint_En_cont_frac
+// for some long double arguments due to low __max_iter value
+
+#include <cmath>
+#include <testsuite_hooks.h>
+
+int
+test01()
+{
+ // Answers from Wolfram Alpha.
+ long double ans_ok = -0.10001943365331651406888645149537315243646135979573L;
+ long double ans_bomb = -0.10777727809650077516264612749163100483995270163783L;
+
+ auto Ei_ok = std::expint(-1.500001L);
+ auto diff_ok = Ei_ok - ans_ok;
+ VERIFY(std::abs(diff_ok) < 1.0e-15);
+
+ auto Ei_bomb = std::expint(-1.450001L);
+ auto diff_bomb = Ei_bomb - ans_bomb;
+ VERIFY(std::abs(diff_bomb) < 1.0e-15);
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/15_expint/pr68397.cc b/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/15_expint/pr68397.cc
new file mode 100644
index 00000000000..60d0b68bad6
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/15_expint/pr68397.cc
@@ -0,0 +1,46 @@
+// Copyright (C) 2017 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/>.
+
+// PR libstdc++/68397 - std::tr1::expint fails in __expint_En_cont_frac
+// for some long double arguments due to low __max_iter value
+
+#include <tr1/cmath>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ // Answers from Wolfram Alpha.
+ long double ans_ok = -0.10001943365331651406888645149537315243646135979573L;
+ long double ans_bomb = -0.10777727809650077516264612749163100483995270163783L;
+
+ long double Ei_ok = std::tr1::expint(-1.500001L);
+ long double diff_ok = std::abs(Ei_ok - ans_ok);
+ VERIFY(diff_ok < 1.0e-15L);
+
+ long double Ei_bomb = std::tr1::expint(-1.450001L);
+ long double diff_bomb = std::abs(Ei_bomb - ans_bomb);
+ VERIFY(diff_bomb < 1.0e-15L);
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
+