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

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

commit 82af23f5829ffc78f65f549e810f914d71c00a66
Author: Dana Jacobsen <d...@acm.org>
Date:   Tue Dec 11 03:31:20 2012 -0800

    Remove an extra loop from PP M-R
---
 lib/Math/Prime/Util/PP.pm | 25 ++++++++-----------------
 1 file changed, 8 insertions(+), 17 deletions(-)

diff --git a/lib/Math/Prime/Util/PP.pm b/lib/Math/Prime/Util/PP.pm
index 5de0e92..3a3d296 100644
--- a/lib/Math/Prime/Util/PP.pm
+++ b/lib/Math/Prime/Util/PP.pm
@@ -721,13 +721,10 @@ sub miller_rabin {
     foreach my $a (@bases) {
       my $x = $n->copy->bzero->badd($a)->bmodpow($d,$n);
       next if ($x->is_one) || ($x->bcmp($nminus1) == 0);
-      foreach my $r (1 .. $s) {
+      foreach my $r (1 .. $s-1) {
         $x->bmul($x); $x->bmod($n);
         return 0 if $x->is_one;
-        if ($x->bcmp($nminus1) == 0) {
-          $a = 0;
-          last;
-        }
+        do { $a = 0; last; } if $x->bcmp($nminus1) == 0;
       }
       return 0 if $a != 0;
     }
@@ -745,30 +742,24 @@ sub miller_rabin {
     foreach my $a (@bases) {
       my $x = _native_powmod($a, $d, $n);
       next if ($x == 1) || ($x == ($n-1));
-      foreach my $r (1 .. $s) {
+      foreach my $r (1 .. $s-1) {
         $x = ($x*$x) % $n;
         return 0 if $x == 1;
-        if ($x == ($n-1)) {
-          $a = 0;
-          last;
-        }
+        last if $x == $n-1;
       }
-      return 0 if $a != 0;
+      return 0 if $x != $n-1;
     }
    } else {
     foreach my $a (@bases) {
       my $x = _powmod($a, $d, $n);
       next if ($x == 1) || ($x == ($n-1));
 
-      foreach my $r (1 .. $s) {
+      foreach my $r (1 .. $s-1) {
         $x = ($x < $_half_word) ? ($x*$x) % $n : _mulmod($x, $x, $n);
         return 0 if $x == 1;
-        if ($x == ($n-1)) {
-          $a = 0;
-          last;
-        }
+        last if $x == $n-1;
       }
-      return 0 if $a != 0;
+      return 0 if $x != $n-1;
     }
    }
 

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