[libmath-prime-util-perl] 35/43: Edge case for legendre_phi

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


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

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

commit 242de60e035d9d4083760ab3094332f481563bd6
Author: Dana Jacobsen <dana at acm.org>
Date:   Wed Apr 16 15:45:46 2014 -0700

    Edge case for legendre_phi
---
 Changes        | 2 ++
 lmo.c          | 5 ++++-
 t/19-moebius.t | 2 ++
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/Changes b/Changes
index 34144a2..b39cc29 100644
--- a/Changes
+++ b/Changes
@@ -23,6 +23,8 @@ Revision history for Perl module Math::Prime::Util
 
     - Tighten nth_prime_lower and nth_prime_upper for very small values.
 
+    - Fix legendre_phi when given tiny x and large a (odd test case).
+
 
 0.39  2014-03-01
 
diff --git a/lmo.c b/lmo.c
index 3db1ad1..eab3d92 100644
--- a/lmo.c
+++ b/lmo.c
@@ -336,7 +336,10 @@ static IV _phi(UV x, UV a, int sign, const uint32_t* const primes, const uint32_
     cache[a*PHICACHEX+x] = sign * sum;
   return sum;
 }
-UV legendre_phi(UV x, UV a) {
+UV legendre_phi(UV x, UV a)
+{
+  if (x <= PHIC)
+    return tablephi(x, (a > PHIC) ? PHIC : a);
   /* TODO: tune these */
   if ( (x > PHIC && a > 200) || (x > 1000000000 && a > 30) ) {
     uint16_t* cache;
diff --git a/t/19-moebius.t b/t/19-moebius.t
index 11415b1..b1cbd09 100644
--- a/t/19-moebius.t
+++ b/t/19-moebius.t
@@ -262,6 +262,8 @@ if ($use64) {
 }
 
 my @legendre_sums = (
+  [ 0,  92372, 0],
+  [ 5,  15, 1],
   [ 89, 4, 21 ],
   [ 46, 4, 11 ],
   [ 47, 4, 12 ],

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