[libmath-prime-util-perl] 140/181: Use long double interface for the other three FP functions

Partha P. Mukherjee ppm-guest at moszumanska.debian.org
Thu May 21 18:51:15 UTC 2015


This is an automated email from the git hooks/post-receive script.

ppm-guest pushed a commit to annotated tag v0.36
in repository libmath-prime-util-perl.

commit 641c2470ff185b702ab232a30c7666e1c511e5ae
Author: Dana Jacobsen <dana at acm.org>
Date:   Wed Jan 8 17:19:51 2014 -0800

    Use long double interface for the other three FP functions
---
 XS.xs  |  6 +++---
 util.c | 16 ++++++++--------
 util.h |  6 +++---
 3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/XS.xs b/XS.xs
index 7a95d61..82d9b35 100644
--- a/XS.xs
+++ b/XS.xs
@@ -726,11 +726,11 @@ _XS_ExponentialIntegral(IN SV* x)
     if (ix < 4) {
       NV nv = SvNV(x);
       switch (ix) {
-        case 0: ret = _XS_ExponentialIntegral(nv); break;
-        case 1: ret = _XS_LogarithmicIntegral(nv); break;
+        case 0: ret = (double) _XS_ExponentialIntegral(nv); break;
+        case 1: ret = (double) _XS_LogarithmicIntegral(nv); break;
         case 2: ret = (double) ld_riemann_zeta(nv); break;
         case 3:
-        default:ret = _XS_RiemannR(nv); break;
+        default:ret = (double) _XS_RiemannR(nv); break;
       }
     } else {
       UV uv = SvUV(x);
diff --git a/util.c b/util.c
index 8783c72..fef4157 100644
--- a/util.c
+++ b/util.c
@@ -1152,8 +1152,8 @@ double _XS_chebyshev_psi(UV n)
 static long double const euler_mascheroni = 0.57721566490153286060651209008240243104215933593992L;
 static long double const li2 = 1.045163780117492784844588889194613136522615578151L;
 
-double _XS_ExponentialIntegral(double x) {
-  long double const tol = 1e-16;
+long double _XS_ExponentialIntegral(long double x) {
+  long double const tol = 1e-17;
   long double val, term;
   unsigned int n;
   KAHAN_INIT(sum);
@@ -1220,10 +1220,10 @@ double _XS_ExponentialIntegral(double x) {
       if (term < tol*sum) break;
       if (term < last_term) {
         KAHAN_SUM(sum, term);
-        /* printf("A  after adding %.8lf, sum = %.8lf\n", term, sum); */
+        /* printf("A  after adding %.20llf, sum = %.20llf\n", term, sum); */
       } else {
         KAHAN_SUM(sum, (-last_term/3) );
-        /* printf("A  after adding %.8lf, sum = %.8lf\n", -last_term/3, sum); */
+        /* printf("A  after adding %.20llf, sum = %.20llf\n", -last_term/3, sum); */
         break;
       }
     }
@@ -1234,12 +1234,12 @@ double _XS_ExponentialIntegral(double x) {
   return val;
 }
 
-double _XS_LogarithmicIntegral(double x) {
+long double _XS_LogarithmicIntegral(long double x) {
   if (x == 0) return 0;
   if (x == 1) return -INFINITY;
   if (x == 2) return li2;
   if (x < 0) croak("Invalid input to LogarithmicIntegral:  x must be >= 0");
-  return _XS_ExponentialIntegral(log(x));
+  return _XS_ExponentialIntegral(logl(x));
 }
 
 /* Thanks to Kim Walisch for this idea */
@@ -1431,8 +1431,8 @@ long double ld_riemann_zeta(long double x) {
   }
 }
 
-double _XS_RiemannR(double x) {
-  long double const tol = 1e-16;
+long double _XS_RiemannR(long double x) {
+  long double const tol = 1e-17;
   long double part_term, term, flogx;
   unsigned int k;
   KAHAN_INIT(sum);
diff --git a/util.h b/util.h
index 7c71493..e0e6b8c 100644
--- a/util.h
+++ b/util.h
@@ -21,10 +21,10 @@ extern IV     mertens(UV n);
 extern double _XS_chebyshev_theta(UV n);
 extern double _XS_chebyshev_psi(UV n);
 
-extern double _XS_ExponentialIntegral(double x);
-extern double _XS_LogarithmicIntegral(double x);
+extern long double _XS_ExponentialIntegral(long double x);
+extern long double _XS_LogarithmicIntegral(long double x);
 extern long double ld_riemann_zeta(long double x);
-extern double _XS_RiemannR(double x);
+extern long double _XS_RiemannR(long double x);
 extern UV _XS_Inverse_Li(UV x);
 
 extern int kronecker_uu(UV a, UV b);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmath-prime-util-perl.git



More information about the Pkg-perl-cvs-commits mailing list