[libmath-prime-util-perl] 11/181: Speedup for Legendre Pi (use small phi)

Partha P. Mukherjee ppm-guest at moszumanska.debian.org
Thu May 21 18:51:01 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 78db558a1652d996ab8c191896a4a9c214cc1a6c
Author: Dana Jacobsen <dana at acm.org>
Date:   Thu Dec 12 17:51:34 2013 -0800

    Speedup for Legendre Pi (use small phi)
---
 lehmer.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/lehmer.c b/lehmer.c
index 169d931..1425a24 100644
--- a/lehmer.c
+++ b/lehmer.c
@@ -723,7 +723,16 @@ UV _XS_legendre_pi(UV n)
     return _XS_prime_count(2, n);
 
   a = _XS_legendre_pi(isqrt(n));
-  phina = phi(n, a);
+  /* phina = phi(n, a); */
+  { /* The small phi routine is faster for large a */
+    cache_t pcache;
+    const uint32_t* primes = 0;
+    primes = generate_small_primes(a+1);
+    phicache_init(&pcache);
+    phina = phi_small(n, a, primes, a+1, &pcache);
+    phicache_free(&pcache);
+    Safefree(primes);
+  }
   return phina + a - 1;
 }
 

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