[libmath-prime-util-perl] 13/16: Update MR bases
Partha P. Mukherjee
ppm-guest at moszumanska.debian.org
Thu May 21 18:46:52 UTC 2015
This is an automated email from the git hooks/post-receive script.
ppm-guest pushed a commit to annotated tag v0.19
in repository libmath-prime-util-perl.
commit 7f2819e61d671538d469f61f156bb866f8321f89
Author: Dana Jacobsen <dana at acm.org>
Date: Wed Jan 23 23:35:26 2013 -0800
Update MR bases
---
Changes | 2 +-
MANIFEST | 1 +
examples/test-primality-small.pl | 42 ++++++++++++++++++++++++++++++++++++++++
factor.c | 6 +++---
4 files changed, 47 insertions(+), 4 deletions(-)
diff --git a/Changes b/Changes
index 108703b..4d678e8 100644
--- a/Changes
+++ b/Changes
@@ -2,7 +2,7 @@ Revision history for Perl extension Math::Prime::Util.
0.19 ?? January 2012
- - Update MR bases.
+ - Update MR bases with newest from http://miller-rabin.appspot.com/.
- Fixed some issues when using bignum and Calc BigInt backend, and bignum
and Perl 5.6.
diff --git a/MANIFEST b/MANIFEST
index d0f6e0b..2e04349 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -46,6 +46,7 @@ examples/test-primes-yafu.pl
examples/test-holf.pl
examples/test-nthapprox.pl
examples/test-pcapprox.pl
+examples/test-primality-small.pl
examples/sophie_germain.pl
examples/twin_primes.pl
examples/find_mr_bases.pl
diff --git a/examples/test-primality-small.pl b/examples/test-primality-small.pl
new file mode 100755
index 0000000..a3f145c
--- /dev/null
+++ b/examples/test-primality-small.pl
@@ -0,0 +1,42 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+$| = 1; # fast pipes
+
+# Make sure the is_prob_prime functionality is working for small inputs.
+# Good for making sure the first few M-R bases are set up correctly.
+
+use Math::Prime::Util qw/is_prob_prime/;
+use Math::Prime::Util::PrimeArray;
+
+my @primes; tie @primes, 'Math::Prime::Util::PrimeArray';
+
+# Test just primes
+if (0) {
+ foreach my $i (1 .. 10000000) {
+ my $n = shift @primes;
+ die unless is_prob_prime($n);
+ #print "." unless $i % 16384;
+ print "$i $n\n" unless $i % 262144;
+ }
+}
+
+# Test every number up to the 100Mth prime (about 2000M)
+if (1) {
+ die "2 should be prime" unless is_prob_prime(2);
+ shift @primes;
+ my $n = shift @primes;
+ foreach my $i (2 .. 100_000_000) {
+ die "$n should be prime" unless is_prob_prime($n);
+ print "$i $n\n" unless $i % 262144;
+ my $next = shift @primes;
+ my $diff = ($next - $n) >> 1;
+ if ($diff > 1) {
+ foreach my $d (1 .. $diff-1) {
+ my $cn = $n + 2*$d;
+ die "$cn should be composite" if is_prob_prime($cn);
+ }
+ }
+ $n = $next;
+ }
+}
diff --git a/factor.c b/factor.c
index 8cad533..59c246b 100644
--- a/factor.c
+++ b/factor.c
@@ -208,9 +208,9 @@ int _XS_is_prob_prime(UV n)
}
#else
#if 1
- /* Better bases from http://miller-rabin.appspot.com/, 15 Jan 2013 */
- if (n < UVCONST(218245)) {
- bases[0] = UVCONST(34933608779780163);
+ /* Better bases from http://miller-rabin.appspot.com/, 23 Jan 2013 */
+ if (n < UVCONST(272161)) {
+ bases[0] = UVCONST(62769592775616394);
nbases = 1;
} else if (n < UVCONST(466758181)) {
bases[0] = UVCONST( 91869414 );
--
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