[libmath-prime-util-perl] 21/35: Use Lehmer for small prime counts (below 8000 million), LMO for large
Partha P. Mukherjee
ppm-guest at moszumanska.debian.org
Thu May 21 18:50:04 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 126995b7335475361dc3cde621a6ed67e32cc211
Author: Dana Jacobsen <dana at acm.org>
Date: Thu Nov 7 14:58:15 2013 -0800
Use Lehmer for small prime counts (below 8000 million), LMO for large
---
Changes | 3 +++
XS.xs | 3 +++
lib/Math/Prime/Util.pm | 6 ++++--
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/Changes b/Changes
index 8c2726c..9cbb680 100644
--- a/Changes
+++ b/Changes
@@ -23,6 +23,9 @@ Revision history for Perl module Math::Prime::Util
- Fixed Pure Perl 33- to 64-bit is_pseudoprime.
+ - prime_count uses Lehmer below a threshold (8000M), LMO above.
+ This keeps good performance while still using low memory.
+
- Perl RiemannZeta changes:
- Borwein Zeta calculations done in BigInt instead of BigFloat (speed).
diff --git a/XS.xs b/XS.xs
index f5b5f16..de47b4e 100644
--- a/XS.xs
+++ b/XS.xs
@@ -222,6 +222,9 @@ _XS_nth_prime(IN UV n)
UV
_XS_divisor_sum(IN UV n, IN UV k)
+UV
+_XS_legendre_phi(IN UV x, IN UV a)
+
UV
_get_prime_cache_size()
diff --git a/lib/Math/Prime/Util.pm b/lib/Math/Prime/Util.pm
index fc1603d..544af84 100644
--- a/lib/Math/Prime/Util.pm
+++ b/lib/Math/Prime/Util.pm
@@ -1910,8 +1910,10 @@ sub prime_count {
#if ($est_lehmer < $est_segment) {
if ( ($high / ($high-$low+1)) < 100 ) {
my $count;
- $count = _XS_LMO_pi($high);
- $count -= _XS_LMO_pi($low-1) if $low > 2;
+ $count = ($high > 8_000_000_000) ? _XS_LMO_pi($high) : _XS_lehmer_pi($high);
+ if ($low > 2) {
+ $count -= ($low > 8_000_000_000) ? _XS_LMO_pi($low-1) : _XS_lehmer_pi($low-1);
+ }
return $count;
}
}
--
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