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

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

commit 69f6a75d8c36bc93d3b90585d6654692039d1d53
Author: Dana Jacobsen <d...@acm.org>
Date:   Wed Jul 3 13:30:52 2013 -0700

    Update Lucas tests
---
 factor.c                  | 15 ++++++++++-----
 lib/Math/Prime/Util/PP.pm | 16 ++++++++--------
 2 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/factor.c b/factor.c
index 6d9c275..92b3234 100644
--- a/factor.c
+++ b/factor.c
@@ -624,22 +624,27 @@ int _XS_is_lucas_pseudoprime(UV n, int strength)
     if (U == 0)
       return 1;
   } else if (strength == 1) {
-    if (U == 0 || V == 0)
+    if (U == 0)
       return 1;
+    /* Now check to see if V_{d*2^r} == 0 for any 0 <= r < s */
     while (s--) {
-      V = muladdmod(V, V, n - addmod(Qk, Qk, n), n);
       if (V == 0)
         return 1;
-      if (s)
+      if (s) {
+        V = mulsubmod(V, V, addmod(Qk,Qk,n), n);
         Qk = sqrmod(Qk, n);
+      }
     }
   } else {
-    if ( (U == 0 && (V == 2 || V == (n-2))) || (V == 0) )
+    if ( U == 0 && (V == 2 || V == (n-2)) )
       return 1;
+    /* Now check to see if V_{d*2^r} == 0 for any 0 <= r < s-1 */
+    s--;
     while (s--) {
-      V = mulsubmod(V, V, 2, n);
       if (V == 0)
         return 1;
+      if (s)
+        V = mulsubmod(V, V, 2, n);
     }
   }
   return 0;
diff --git a/lib/Math/Prime/Util/PP.pm b/lib/Math/Prime/Util/PP.pm
index 8a60270..e76b5a9 100644
--- a/lib/Math/Prime/Util/PP.pm
+++ b/lib/Math/Prime/Util/PP.pm
@@ -1051,11 +1051,13 @@ sub is_strong_lucas_pseudoprime {
   }
   my($U, $V, $Qk) = lucas_sequence($n, $P, $Q, $k);
 
-  return 1 if $U->is_zero || $V->is_zero;
-  foreach my $r (1 .. $s-1) { # Compute powers of V
-    $V = ($V * $V - 2*$Qk) % $n;
+  return 1 if $U->is_zero;
+  foreach my $r (0 .. $s-1) {
     return 1 if $V->is_zero;
-    $Qk = ($Qk * $Qk) % $n if $r < ($s-1);
+    if ($r < ($s-1)) {
+      $V->bmul($V)->bsub(2*$Qk)->bmod($n);
+      $Qk->bmul($Qk)->bmod($n);
+    }
   }
   return 0;
 }
@@ -1081,11 +1083,9 @@ sub is_extra_strong_lucas_pseudoprime {
   my($U, $V, $Qk) = lucas_sequence($n, $P, $Q, $k);
 
   return 1 if $U->is_zero && ($V == 2 || $V == ($n-2));
-  return 1 if $V->is_zero;
-
-  foreach my $r (1 .. $s-1) {
-    $V->bmul($V)->bsub(2)->bmod($n);
+  foreach my $r (0 .. $s-2) {
     return 1 if $V->is_zero;
+    $V->bmul($V)->bsub(2)->bmod($n);
   }
   return 0;
 }

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