[libmath-prime-util-perl] 15/35: Keep BigInt accuracy for Riemann Zeta/R

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


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

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

commit f4ffcafbb5aa6ee087d8b098e7f53699c17f7697
Author: Dana Jacobsen <dana at acm.org>
Date:   Mon Oct 28 15:54:20 2013 -0700

    Keep BigInt accuracy for Riemann Zeta/R
---
 lib/Math/Prime/Util/PP.pm           | 14 ++++++++++++--
 lib/Math/Prime/Util/ZetaBigFloat.pm |  8 +++++++-
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/lib/Math/Prime/Util/PP.pm b/lib/Math/Prime/Util/PP.pm
index 115df8a..6d3d085 100644
--- a/lib/Math/Prime/Util/PP.pm
+++ b/lib/Math/Prime/Util/PP.pm
@@ -2353,7 +2353,12 @@ sub RiemannZeta {
         eval { require Math::BigFloat;   Math::BigFloat->import(); 1; }
         or do { croak "Cannot load Math::BigFloat "; }
       }
-      $x = new Math::BigFloat "$x" if ref($x) ne 'Math::BigFloat';
+      if (ref($x) eq 'Math::BigInt') {
+        my $xacc = $x->accuracy();
+        $x = Math::BigFloat->new($x);
+        $x->accuracy($xacc) if $xacc;
+      }
+      $x = Math::BigFloat->new("$x") if ref($x) ne 'Math::BigFloat';
       $wantbf = 1;
       $xdigits = $x->accuracy || Math::BigFloat->accuracy() || Math::BigFloat->div_scale();
     }
@@ -2439,7 +2444,12 @@ sub RiemannR {
         eval { require Math::BigFloat;   Math::BigFloat->import(); 1; }
         or do { croak "Cannot load Math::BigFloat "; }
       }
-      $x = new Math::BigFloat "$x" if ref($x) ne 'Math::BigFloat';
+      if (ref($x) eq 'Math::BigInt') {
+        my $xacc = $x->accuracy();
+        $x = Math::BigFloat->new($x);
+        $x->accuracy($xacc) if $xacc;
+      }
+      $x = Math::BigFloat->new("$x") if ref($x) ne 'Math::BigFloat';
       $wantbf = 1;
       $xdigits = $x->accuracy || Math::BigFloat->accuracy() || Math::BigFloat->div_scale();
     }
diff --git a/lib/Math/Prime/Util/ZetaBigFloat.pm b/lib/Math/Prime/Util/ZetaBigFloat.pm
index 308d7f5..774c3a1 100644
--- a/lib/Math/Prime/Util/ZetaBigFloat.pm
+++ b/lib/Math/Prime/Util/ZetaBigFloat.pm
@@ -394,7 +394,13 @@ sub RiemannZeta {
 sub RiemannR {
   my($x) = @_;
 
-  $x = new Math::BigFloat "$x" if ref($x) ne 'Math::BigFloat';
+  if (ref($x) eq 'Math::BigInt') {
+    my $xacc = $x->accuracy();
+    $x = Math::BigFloat->new($x);
+    $x->accuracy($xacc) if $xacc;
+  }
+  $x = Math::BigFloat->new("$x") if ref($x) ne 'Math::BigFloat';
+
   my $xdigits = $x->accuracy || Math::BigFloat->accuracy() || Math::BigFloat->div_scale();
   my $tol = 0.0 + "1e-$xdigits";
 

-- 
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