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

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

commit 084e79e9cb68f951f66838ecff7afb66a005f258
Author: Dana Jacobsen <d...@acm.org>
Date:   Mon Jul 9 02:15:16 2012 -0600

    Minor GMP related change for performance and doc
---
 lib/Math/Prime/Util.pm | 34 +++++++++++++++++++++-------------
 1 file changed, 21 insertions(+), 13 deletions(-)

diff --git a/lib/Math/Prime/Util.pm b/lib/Math/Prime/Util.pm
index c3b239f..1c02e6f 100644
--- a/lib/Math/Prime/Util.pm
+++ b/lib/Math/Prime/Util.pm
@@ -292,17 +292,21 @@ sub primes {
 #
 # The random_maurer_prime function uses Maurer's algorithm of course.
 #
-# The current code is reasonably fast for native, but slow for bigints.
+# The current code is reasonably fast for native, but slow for bigints.  Using
+# the M::P::U::GMP module helps immensely.  Performance does differ though --
+# my 32-bit machine is ~5x slower than this 64-bit machine for this.
+#
 #    n-bits      no GMP      with MPU::GMP
 #    ----------  ----------  --------------
-#       24-bit         70uS
-#       64-bit       0.01s       0.01s
-#      128-bit       0.2s        0.02s
-#      256-bit       1s          0.04s
-#      512-bit      10s          0.1s
-#     1024-bit     1m            0.5s
-#     2048-bit    ~4m            5s
-#     4096-bit   ~80m           35s
+#       24-bit         15uS                 (native)
+#       64-bit         60uS                 (native)
+#      128-bit       0.2s        0.01s
+#      256-bit       1s          0.02s
+#      512-bit      10s          0.03s
+#     1024-bit     1m            0.1s
+#     2048-bit    ~4m            0.6s
+#     4096-bit   ~80m            7s
+#     8192-bit   ----           80s
 #
 # To verify distribution:
 #   perl -Iblib/lib -Iblib/arch -MMath::Prime::Util=:all -E 'my %freq; 
$n=1000000; $freq{random_nbit_prime(6)}++ for (1..$n); printf("%4d %6.3f%%\n", 
$_, 100.0*$freq{$_}/$n) for sort {$a<=>$b} keys %freq;'
@@ -551,11 +555,15 @@ sub primes {
 
       # Trial divide up to $B
       next if !($n % 3) || !($n % 5) || !($n % 7) || !($n % 11) || !($n % 13);
-      my $looks_prime = 1;
-      foreach my $p (@primes) {
-        do { $looks_prime = 0; last; } if !($n % $p);
+      if ($_HAVE_GMP) {
+        next unless Math::Prime::Util::GMP::is_strong_pseudoprime($n, 2, 7);
+      } else {
+        my $looks_prime = 1;
+        foreach my $p (@primes) {
+          do { $looks_prime = 0; last; } if !($n % $p);
+        }
+        next unless $looks_prime;
       }
-      next unless $looks_prime;
       #warn "$n passes trial division\n";
 
       # a is a random number between 2 and $n-2

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-perl/packages/libmath-prime-util-perl.git

_______________________________________________
Pkg-perl-cvs-commits mailing list
Pkg-perl-cvs-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits

Reply via email to