[Gmp-commit] /home/hgfiles/gmp: Fixed bugs in jacobi_2.

mercurial at gmplib.org mercurial at gmplib.org
Fri Apr 30 13:14:24 CEST 2010


details:   /home/hgfiles/gmp/rev/11d4e9773334
changeset: 13582:11d4e9773334
user:      Niels M?ller <nisse at lysator.liu.se>
date:      Fri Apr 30 13:14:20 2010 +0200
description:
Fixed bugs in jacobi_2.

diffstat:

 ChangeLog                   |   5 +++++
 mpn/generic/jacobi_lehmer.c |  13 ++++++++++---
 2 files changed, 15 insertions(+), 3 deletions(-)

diffs (55 lines):

diff -r d8d2e4c965cc -r 11d4e9773334 ChangeLog
--- a/ChangeLog	Thu Apr 29 23:00:38 2010 +0200
+++ b/ChangeLog	Fri Apr 30 13:14:20 2010 +0200
@@ -1,3 +1,8 @@
+2010-04-30  Niels Möller  <nisse at lysator.liu.se>
+
+	* mpn/generic/jacobi_lehmer.c (mpn_jacobi_2): Fixed handling of
+	the case bl == 1. Fixed missing application of reciprocity.
+
 2010-04-29  Niels Möller  <nisse at lysator.liu.se>
 
 	* configure.in (gmp_mpn_functions): Deleted gcdext_subdiv_step.
diff -r d8d2e4c965cc -r 11d4e9773334 mpn/generic/jacobi_lehmer.c
--- a/mpn/generic/jacobi_lehmer.c	Thu Apr 29 23:00:38 2010 +0200
+++ b/mpn/generic/jacobi_lehmer.c	Fri Apr 30 13:14:20 2010 +0200
@@ -444,13 +444,14 @@
 	      al = bl;
 	      bl = ah >> c;
 	      ah = bh;
+
+	      bit ^= al & bl;
 	      goto b_reduced;
 	    }
 	  count_trailing_zeros (c, al);
 	  bit ^= (c << 1) & (bl ^ (bl >> 1));
 	  al = ((ah << (GMP_NUMB_BITS - c)) & GMP_NUMB_MASK) | (al >> c);
 	  ah >>= c;
-
 	}
       if (ah == bh)
 	goto cancel_hi;
@@ -513,7 +514,11 @@
 
  b_reduced:
   /* Compute (a|b), with b a single limb. */
-  ASSERT (bl > 1);
+  ASSERT (bl & 1);
+
+  if (bl == 1)
+    /* (a|1) = 1 */
+    return 1 - (bit & 2);
 
   while (ah > 0)
     {
@@ -535,7 +540,9 @@
       bit ^= (c << 1) & (bl ^ (bl >> 1));      
     }
  ab_reduced:
-  ASSERT (bl > 0);
+  ASSERT (bl & 1);
+  ASSERT (bl > 1);
+
   return mpn_jacobi_base (al, bl, bit);
 }
 #else


More information about the gmp-commit mailing list