[Gmp-commit] /var/hg/gmp: (mpz_bc_fac_1): Fix typo in allocation size.

mercurial at gmplib.org mercurial at gmplib.org
Thu Dec 8 14:29:06 CET 2011


details:   /var/hg/gmp/rev/b59543db8f7c
changeset: 14542:b59543db8f7c
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Thu Dec 08 14:29:02 2011 +0100
description:
(mpz_bc_fac_1): Fix typo in allocation size.

diffstat:

 ChangeLog    |   2 ++
 mpz/fac_ui.c |  36 ++++++++++++++++++------------------
 2 files changed, 20 insertions(+), 18 deletions(-)

diffs (102 lines):

diff -r c3fc4afe7aa7 -r b59543db8f7c ChangeLog
--- a/ChangeLog	Thu Dec 08 13:08:46 2011 +0100
+++ b/ChangeLog	Thu Dec 08 14:29:02 2011 +0100
@@ -1,5 +1,7 @@
 2011-12-08  Torbjorn Granlund  <tege at gmplib.org>
 
+	* mpz/fac_ui.c (mpz_bc_fac_1): Fix typo in allocation size.
+
 	* mpn/x86/fat/com.c: New file.
 
 	* mpn/x86_64/pentium4/aors_n.asm: Make it actually work for DOS64.
diff -r c3fc4afe7aa7 -r b59543db8f7c mpz/fac_ui.c
--- a/mpz/fac_ui.c	Thu Dec 08 13:08:46 2011 +0100
+++ b/mpz/fac_ui.c	Thu Dec 08 14:29:02 2011 +0100
@@ -42,19 +42,19 @@
   ((n) >=  0x100) + ((n) >=  0x200) + ((n) >=  0x400) + ((n) >=  0x800) + \
   ((n) >= 0x1000) + ((n) >= 0x2000) + ((n) >= 0x4000) + ((n) >= 0x8000))
 
-#define FACTOR_LIST_APPEND(PR, MAX_PR, VEC, I)	\
-  if ((PR) > (MAX_PR)) {			\
-    (VEC)[(I)++] = (PR);			\
-    (PR) = 1;					\
+#define FACTOR_LIST_APPEND(PR, MAX_PR, VEC, I)			\
+  if ((PR) > (MAX_PR)) {					\
+    (VEC)[(I)++] = (PR);					\
+    (PR) = 1;							\
   }
 
-#define FACTOR_LIST_STORE(P, PR, MAX_PR, VEC, I)	\
-  do {						\
-    if ((PR) > (MAX_PR)) {			\
-      (VEC)[(I)++] = (PR);			\
-      (PR) = (P);				\
-    } else					\
-      (PR) *= (P);				\
+#define FACTOR_LIST_STORE(P, PR, MAX_PR, VEC, I)		\
+  do {								\
+    if ((PR) > (MAX_PR)) {					\
+      (VEC)[(I)++] = (PR);					\
+      (PR) = (P);						\
+    } else							\
+      (PR) *= (P);						\
   } while (0)
 
 #define LOOP_ON_SIEVE_BEGIN(prime,start,end,off,sieve)		\
@@ -78,7 +78,7 @@
 	}							\
       __mask = __mask << 1 | __mask >> (GMP_LIMB_BITS-1);	\
       __index += __mask & 1;					\
-    }  while (__i <= __max_i);				\
+    }  while (__i <= __max_i);					\
   } while (0)
 
 /*********************************************************/
@@ -112,7 +112,7 @@
 #define SIEVE_SEED CNST_LIMB(0x8480)
 #define SEED_LIMIT 54
 #else
-#error Not implemented 
+#error Not implemented
 #endif
 #endif
 
@@ -149,9 +149,9 @@
 	  int maskrot;
 
 	  step = id_to_n(i);
-/* 	  lindex = n_to_bit(id_to_n(i)*id_to_n(i)); */
+/*	  lindex = n_to_bit(id_to_n(i)*id_to_n(i)); */
 	  lindex = i*(step+1+(i&1))-1+(i&1);
-/* 	  lindex = i*(i*3+2+(i&1)*2)-1+(i&1); */
+/*	  lindex = i*(i*3+2+(i&1)*2)-1+(i&1); */
 	  if (lindex > bits)
 	    break;
 
@@ -165,7 +165,7 @@
 	    lindex += step;
 	  } while (lindex <= bits);
 
-/* 	  lindex = n_to_bit(id_to_n(i)*bit_to_n(i)); */
+/*	  lindex = n_to_bit(id_to_n(i)*bit_to_n(i)); */
 	  lindex = i*(i*3+6)+(i&1);
 
 	  lmask = CNST_LIMB(1) << (lindex % GMP_LIMB_BITS);
@@ -493,7 +493,7 @@
     } while (i <= n);
     n >>= 1;
   } while (n >= numberof (table));
- 
+
   factors[j++] = prod;
   factors[j++] = table[n];
   mpz_prodlimbs (x, factors, j);
@@ -577,7 +577,7 @@
 
       TMP_SMARK;
       i = numberof (table);
-      factors = TMP_SALLOC_LIMBS (1 + (n - numberof (table)) / FACTORS_PER_LIMB);
+      factors = TMP_SALLOC_LIMBS (2 + (n - numberof (table)) / FACTORS_PER_LIMB);
 
       factors[0] = table[numberof (table)-1];
       j = 1;


More information about the gmp-commit mailing list