Implement efficient reduction for pleasant-looking primes.
[u/mdw/catacomb] / gfreduce.c
index 929c46c..4f07ccf 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: gfreduce.c,v 1.3 2004/03/23 15:19:32 mdw Exp $
+ * $Id: gfreduce.c,v 1.4 2004/03/27 00:04:46 mdw Exp $
  *
  * Efficient reduction modulo sparse binary polynomials
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: gfreduce.c,v $
+ * Revision 1.4  2004/03/27 00:04:46  mdw
+ * Implement efficient reduction for pleasant-looking primes.
+ *
  * Revision 1.3  2004/03/23 15:19:32  mdw
  * Test elliptic curves more thoroughly.
  *
@@ -98,7 +101,8 @@ DA_DECL(instr_v, gfreduce_instr);
 void gfreduce_create(gfreduce *r, mp *p)
 {
   instr_v iv = DA_INIT;
-  unsigned long d, dw;
+  unsigned long d;
+  unsigned dw;
   mpscan sc;
   unsigned long i;
   gfreduce_instr *ip;
@@ -162,8 +166,8 @@ void gfreduce_create(gfreduce *r, mp *p)
       w = ww;
       wi = DA_LEN(&iv);
     }
-    INSTR(GFRI_LSL, (i - d)%MPW_BITS);
-    if ((i - d)%MPW_BITS)
+    INSTR(GFRI_LSL, (MPW_BITS + i - d)%MPW_BITS);
+    if ((MPW_BITS + i - d)%MPW_BITS)
       f |= f_lsr;
   }
   wl = DA_LEN(&iv);