[Gmp-commit] /var/hg/gmp: gen-fac_ui.c: Clean-up.

mercurial at gmplib.org mercurial at gmplib.org
Wed Apr 11 23:36:44 CEST 2012


details:   /var/hg/gmp/rev/7c37eae1640e
changeset: 14809:7c37eae1640e
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Wed Apr 11 23:36:40 2012 +0200
description:
gen-fac_ui.c: Clean-up.

diffstat:

 ChangeLog    |   2 ++
 gen-fac_ui.c |  29 ++++++++++++++++++++++++-----
 2 files changed, 26 insertions(+), 5 deletions(-)

diffs (74 lines):

diff -r fad7f412a52f -r 7c37eae1640e ChangeLog
--- a/ChangeLog	Wed Apr 11 22:45:50 2012 +0200
+++ b/ChangeLog	Wed Apr 11 23:36:40 2012 +0200
@@ -14,6 +14,8 @@
 	* mini-gmp/tests/t-root.c: New file.
 	* mini-gmp/tests/t-reuse.c: Enable root{,rem} tests.
 
+	* gen-fac_ui.c: Clean-up.
+
 2012-04-10 Marco Bodrato <bodrato at mail.dm.unipi.it>
 
 	* gen-fac_ui.c (mpz_root): Remove.
diff -r fad7f412a52f -r 7c37eae1640e gen-fac_ui.c
--- a/gen-fac_ui.c	Wed Apr 11 22:45:50 2012 +0200
+++ b/gen-fac_ui.c	Wed Apr 11 23:36:40 2012 +0200
@@ -27,16 +27,18 @@
 int
 gen_consts (int numb, int nail, int limb)
 {
-  mpz_t x, y, z, t;
+  mpz_t x, mask;
   unsigned long a, b;
 
   printf ("/* This file is automatically generated by gen-fac_ui.c */\n\n");
   printf ("#if GMP_NUMB_BITS != %d\n", numb);
   printf ("Error , error this data is for %d GMP_NUMB_BITS only\n", numb);
   printf ("#endif\n");
+#if 0
   printf ("#if GMP_LIMB_BITS != %d\n", limb);
   printf ("Error , error this data is for %d GMP_LIMB_BITS only\n", limb);
   printf ("#endif\n");
+#endif
 
   printf
     ("/* This table is 0!,1!,2!,3!,...,n! where n! has <= GMP_NUMB_BITS bits */\n");
@@ -71,6 +73,26 @@
     }
   printf (")\n");
 
+  mpz_init (mask);
+  mpz_setbit (mask, numb);
+  mpz_sub_ui (mask, mask, 1);
+#if 0
+  printf
+    ("\n/* Previous table, continued, values modulo 2^GMP_NUMB_BITS */\n");
+  printf
+    ("#define ONE_LIMB_ODD_FACTORIAL_TABLE_CONT CNST_LIMB(0x");
+  mpz_out_str (stdout, 16, x);
+  for (;b < numb; b++)
+    {
+      for (a = b; (a & 1) == 0; a >>= 1);
+      mpz_mul_ui (x, x, a);
+      mpz_and (x, x, mask);
+      printf ("),CNST_LIMB(0x");
+      mpz_out_str (stdout, 16, x);
+    }
+  printf (")\n");
+#endif
+
   printf
     ("\n/* This table is 1!!,3!!,...,(2n+1)!! where (2n+1)!! has <= GMP_NUMB_BITS bits */\n");
   printf
@@ -92,10 +114,7 @@
     ("#define NTH_ROOT_NUMB_MASK_TABLE (GMP_NUMB_MASK");
   for (b = 2;b <= 8; b++)
     {
-      mpz_set_ui (x, 1);
-      mpz_mul_2exp (x, x, numb);
-      mpz_sub_ui (x, x, 1);
-      mpz_root (x, x, b);
+      mpz_root (x, mask, b);
       if (mpz_sizeinbase (x, 2) < 4)
 	break;
       printf ("),CNST_LIMB(0x");


More information about the gmp-commit mailing list