From 5f8377b79f9ad3e9312c7346541521571802cc61 Mon Sep 17 00:00:00 2001 From: jasonmoxham Date: Sat, 26 Jun 2010 05:25:55 +0000 Subject: [PATCH] remove dumbmp.c and pre-build gen-* and just include the files they generated --- Makefile.am | 62 +--- Makefile.in | 82 +---- doc/stamp-vti | 8 +- doc/version.texi | 2 +- dumbmp.c | 889 ----------------------------------------------- fib_table.h | 11 + gen-bases.c | 183 ---------- gen-fac_ui.c | 161 --------- gen-fib.c | 147 -------- gen-psqr.c | 578 ------------------------------ mp_bases.h | 17 + mpn/fib_table.c | 160 +++++++++ mpn/mp_bases.c | 530 ++++++++++++++++++++++++++++ mpn/perfsqr.h | 91 +++++ mpz/fac_ui.h | 29 ++ 15 files changed, 862 insertions(+), 2088 deletions(-) delete mode 100644 dumbmp.c create mode 100644 fib_table.h delete mode 100644 gen-bases.c delete mode 100644 gen-fac_ui.c delete mode 100644 gen-fib.c delete mode 100644 gen-psqr.c create mode 100644 mp_bases.h create mode 100644 mpn/fib_table.c create mode 100644 mpn/mp_bases.c create mode 100644 mpn/perfsqr.h create mode 100644 mpz/fac_ui.h diff --git a/Makefile.am b/Makefile.am index 29d50078..c5af98eb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -251,7 +251,7 @@ CXX_OBJECTS = \ # -export-symbols, since the tune and speed programs, and perhaps some of # the test programs, want to access undocumented symbols. -libmpir_la_SOURCES = gmp-impl.h longlong.h randmt.h \ +libmpir_la_SOURCES = gmp-impl.h longlong.h randmt.h \ assert.c compat.c errno.c extract-dbl.c invalid.c memory.c \ mp_bpl.c mp_clz_tab.c mp_dv_tab.c mp_minv_tab.c mp_get_fns.c mp_set_fns.c \ randclr.c randdef.c randiset.c randlc2s.c randlc2x.c randmt.c \ @@ -335,66 +335,6 @@ endif # the .h files are not properly expressed for the various objects that use # them. -EXTRA_DIST += dumbmp.c - -mpz/fac_ui.h: gen-fac_ui$(EXEEXT_FOR_BUILD) - ./gen-fac_ui $(BITS_PER_MP_LIMB) $(GMP_NAIL_BITS) >mpz/fac_ui.h || (rm -f mpz/fac_ui.h; exit 1) -BUILT_SOURCES += mpz/fac_ui.h - -gen-fac_ui$(EXEEXT_FOR_BUILD): gen-fac_ui$(U_FOR_BUILD).c dumbmp.c - $(CC_FOR_BUILD) `test -f 'gen-fac_ui$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-fac_ui$(U_FOR_BUILD).c -o gen-fac_ui$(EXEEXT_FOR_BUILD) -DISTCLEANFILES += gen-fac_ui$(EXEEXT_FOR_BUILD) -EXTRA_DIST += gen-fac_ui.c - -gen-fac_ui_.c: gen-fac_ui.c - $(CPP_FOR_BUILD) `if test -f $(srcdir)/gen-fac_ui.c; then echo $(srcdir)/gen-fac_ui.c; else echo gen-fac_ui.c; fi` | sed 's/^# \([0-9]\)/#line \1/' > gen-fac_ui_.c || rm -f gen-fac_ui_.c - - -fib_table.h: gen-fib$(EXEEXT_FOR_BUILD) - ./gen-fib header $(BITS_PER_MP_LIMB) $(GMP_NAIL_BITS) >fib_table.h || (rm -f fib_table.h; exit 1) -BUILT_SOURCES += fib_table.h - -mpn/fib_table.c: gen-fib$(EXEEXT_FOR_BUILD) - ./gen-fib table $(BITS_PER_MP_LIMB) $(GMP_NAIL_BITS) >mpn/fib_table.c || (rm -f mpn/fib_table.c; exit 1) -BUILT_SOURCES += mpn/fib_table.c - -gen-fib$(EXEEXT_FOR_BUILD): gen-fib$(U_FOR_BUILD).c dumbmp.c - $(CC_FOR_BUILD) `test -f 'gen-fib$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-fib$(U_FOR_BUILD).c -o gen-fib$(EXEEXT_FOR_BUILD) -DISTCLEANFILES += gen-fib$(EXEEXT_FOR_BUILD) -EXTRA_DIST += gen-fib.c - -gen-fib_.c: gen-fib.c - $(CPP_FOR_BUILD) `if test -f $(srcdir)/gen-fib.c; then echo $(srcdir)/gen-fib.c; else echo gen-fib.c; fi` | sed 's/^# \([0-9]\)/#line \1/' > gen-fib_.c || rm -f gen-fib_.c - - -mp_bases.h: gen-bases$(EXEEXT_FOR_BUILD) - ./gen-bases header $(BITS_PER_MP_LIMB) $(GMP_NAIL_BITS) >mp_bases.h || (rm -f mp_bases.h; exit 1) -BUILT_SOURCES += mp_bases.h - -mpn/mp_bases.c: gen-bases$(EXEEXT_FOR_BUILD) - ./gen-bases table $(BITS_PER_MP_LIMB) $(GMP_NAIL_BITS) >mpn/mp_bases.c || (rm -f mpn/mp_bases.c; exit 1) -BUILT_SOURCES += mpn/mp_bases.c - -gen-bases$(EXEEXT_FOR_BUILD): gen-bases$(U_FOR_BUILD).c dumbmp.c - $(CC_FOR_BUILD) `test -f 'gen-bases$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-bases$(U_FOR_BUILD).c -o gen-bases$(EXEEXT_FOR_BUILD) $(LIBM_FOR_BUILD) -DISTCLEANFILES += gen-bases$(EXEEXT_FOR_BUILD) -EXTRA_DIST += gen-bases.c - -gen-bases_.c: gen-bases.c - $(CPP_FOR_BUILD) `if test -f $(srcdir)/gen-bases.c; then echo $(srcdir)/gen-bases.c; else echo gen-bases.c; fi` | sed 's/^# \([0-9]\)/#line \1/' > gen-bases_.c || rm -f gen-bases_.c - - -mpn/perfsqr.h: gen-psqr$(EXEEXT_FOR_BUILD) - ./gen-psqr $(BITS_PER_MP_LIMB) $(GMP_NAIL_BITS) >mpn/perfsqr.h || (rm -f mpn/perfsqr.h; exit 1) -BUILT_SOURCES += mpn/perfsqr.h - -gen-psqr$(EXEEXT_FOR_BUILD): gen-psqr$(U_FOR_BUILD).c dumbmp.c - $(CC_FOR_BUILD) `test -f 'gen-psqr$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-psqr$(U_FOR_BUILD).c -o gen-psqr$(EXEEXT_FOR_BUILD) $(LIBM_FOR_BUILD) -DISTCLEANFILES += gen-psqr$(EXEEXT_FOR_BUILD) -EXTRA_DIST += gen-psqr.c - -gen-psqr_.c: gen-psqr.c - $(CPP_FOR_BUILD) `if test -f $(srcdir)/gen-psqr.c; then echo $(srcdir)/gen-psqr.c; else echo gen-psqr.c; fi` | sed 's/^# \([0-9]\)/#line \1/' > gen-psqr_.c || rm -f gen-psqr_.c # Avoid: CVS - cvs directories diff --git a/Makefile.in b/Makefile.in index 88ed8ba5..27d3190e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -460,27 +460,10 @@ LIBMP_LT_REVISION = 0 LIBMP_LT_AGE = 0 SUBDIRS = tests $(am__append_1) mpn mpz mpq mpf printf scanf cxx tune \ doc - -# The "test -f" support for srcdir!=builddir is similar to the automake .c.o -# etc rules, but with each foo.c explicitly, since $< is not portable -# outside an inference rule. -# -# A quoted 'foo.c' is used with the "test -f"'s to avoid Sun make rewriting -# it as part of its VPATH support. See the autoconf manual "Limitations of -# Make". -# -# Generated .h files which are used by gmp-impl.h are BUILT_SOURCES since -# they must exist before anything can be compiled. -# -# Other generated .h files are also BUILT_SOURCES so as to get all the -# build-system stuff over and done with at the start. Also, dependencies on -# the .h files are not properly expressed for the various objects that use -# them. EXTRA_DIST = configfsf.guess configfsf.sub .gdbinit INSTALL.autoconf \ mpirxx.h yasm_mac.inc.fat yasm_mac.inc.nofat strip_fPIC.sh \ mpn/x86w mpn/x86_64w build.vc9 build.vc10 doc/devel \ - doc/fdl.texi cpuid.c gpl-2.0.txt lgpl-2.1.txt dumbmp.c \ - gen-fac_ui.c gen-fib.c gen-bases.c gen-psqr.c + doc/fdl.texi cpuid.c gpl-2.0.txt lgpl-2.1.txt @WANT_CXX_TRUE@GMPXX_HEADERS_OPTION = mpirxx.h # mpir.h and mp.h are architecture dependent, mainly since they encode the @@ -497,11 +480,8 @@ include_HEADERS = $(GMPXX_HEADERS_OPTION) nodist_includeexec_HEADERS = mpir.h lib_LTLIBRARIES = libmpir.la $(am__append_2) \ $(GMPXX_LTLIBRARIES_OPTION) -BUILT_SOURCES = mpir.h mpz/fac_ui.h fib_table.h mpn/fib_table.c \ - mp_bases.h mpn/mp_bases.c mpn/perfsqr.h -DISTCLEANFILES = $(BUILT_SOURCES) config.m4 fat.h @gmp_srclinks@ \ - gen-fac_ui$(EXEEXT_FOR_BUILD) gen-fib$(EXEEXT_FOR_BUILD) \ - gen-bases$(EXEEXT_FOR_BUILD) gen-psqr$(EXEEXT_FOR_BUILD) +BUILT_SOURCES = mpir.h +DISTCLEANFILES = $(BUILT_SOURCES) config.m4 fat.h @gmp_srclinks@ # Tell mpir.h it's building gmp, not an application, used by windows DLL stuff. INCLUDES = -D__GMP_WITHIN_GMP @@ -1241,47 +1221,21 @@ install-data-hook: @echo '+-------------------------------------------------------------+' @echo '' -mpz/fac_ui.h: gen-fac_ui$(EXEEXT_FOR_BUILD) - ./gen-fac_ui $(BITS_PER_MP_LIMB) $(GMP_NAIL_BITS) >mpz/fac_ui.h || (rm -f mpz/fac_ui.h; exit 1) - -gen-fac_ui$(EXEEXT_FOR_BUILD): gen-fac_ui$(U_FOR_BUILD).c dumbmp.c - $(CC_FOR_BUILD) `test -f 'gen-fac_ui$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-fac_ui$(U_FOR_BUILD).c -o gen-fac_ui$(EXEEXT_FOR_BUILD) - -gen-fac_ui_.c: gen-fac_ui.c - $(CPP_FOR_BUILD) `if test -f $(srcdir)/gen-fac_ui.c; then echo $(srcdir)/gen-fac_ui.c; else echo gen-fac_ui.c; fi` | sed 's/^# \([0-9]\)/#line \1/' > gen-fac_ui_.c || rm -f gen-fac_ui_.c - -fib_table.h: gen-fib$(EXEEXT_FOR_BUILD) - ./gen-fib header $(BITS_PER_MP_LIMB) $(GMP_NAIL_BITS) >fib_table.h || (rm -f fib_table.h; exit 1) - -mpn/fib_table.c: gen-fib$(EXEEXT_FOR_BUILD) - ./gen-fib table $(BITS_PER_MP_LIMB) $(GMP_NAIL_BITS) >mpn/fib_table.c || (rm -f mpn/fib_table.c; exit 1) - -gen-fib$(EXEEXT_FOR_BUILD): gen-fib$(U_FOR_BUILD).c dumbmp.c - $(CC_FOR_BUILD) `test -f 'gen-fib$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-fib$(U_FOR_BUILD).c -o gen-fib$(EXEEXT_FOR_BUILD) - -gen-fib_.c: gen-fib.c - $(CPP_FOR_BUILD) `if test -f $(srcdir)/gen-fib.c; then echo $(srcdir)/gen-fib.c; else echo gen-fib.c; fi` | sed 's/^# \([0-9]\)/#line \1/' > gen-fib_.c || rm -f gen-fib_.c - -mp_bases.h: gen-bases$(EXEEXT_FOR_BUILD) - ./gen-bases header $(BITS_PER_MP_LIMB) $(GMP_NAIL_BITS) >mp_bases.h || (rm -f mp_bases.h; exit 1) - -mpn/mp_bases.c: gen-bases$(EXEEXT_FOR_BUILD) - ./gen-bases table $(BITS_PER_MP_LIMB) $(GMP_NAIL_BITS) >mpn/mp_bases.c || (rm -f mpn/mp_bases.c; exit 1) - -gen-bases$(EXEEXT_FOR_BUILD): gen-bases$(U_FOR_BUILD).c dumbmp.c - $(CC_FOR_BUILD) `test -f 'gen-bases$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-bases$(U_FOR_BUILD).c -o gen-bases$(EXEEXT_FOR_BUILD) $(LIBM_FOR_BUILD) - -gen-bases_.c: gen-bases.c - $(CPP_FOR_BUILD) `if test -f $(srcdir)/gen-bases.c; then echo $(srcdir)/gen-bases.c; else echo gen-bases.c; fi` | sed 's/^# \([0-9]\)/#line \1/' > gen-bases_.c || rm -f gen-bases_.c - -mpn/perfsqr.h: gen-psqr$(EXEEXT_FOR_BUILD) - ./gen-psqr $(BITS_PER_MP_LIMB) $(GMP_NAIL_BITS) >mpn/perfsqr.h || (rm -f mpn/perfsqr.h; exit 1) - -gen-psqr$(EXEEXT_FOR_BUILD): gen-psqr$(U_FOR_BUILD).c dumbmp.c - $(CC_FOR_BUILD) `test -f 'gen-psqr$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-psqr$(U_FOR_BUILD).c -o gen-psqr$(EXEEXT_FOR_BUILD) $(LIBM_FOR_BUILD) - -gen-psqr_.c: gen-psqr.c - $(CPP_FOR_BUILD) `if test -f $(srcdir)/gen-psqr.c; then echo $(srcdir)/gen-psqr.c; else echo gen-psqr.c; fi` | sed 's/^# \([0-9]\)/#line \1/' > gen-psqr_.c || rm -f gen-psqr_.c +# The "test -f" support for srcdir!=builddir is similar to the automake .c.o +# etc rules, but with each foo.c explicitly, since $< is not portable +# outside an inference rule. +# +# A quoted 'foo.c' is used with the "test -f"'s to avoid Sun make rewriting +# it as part of its VPATH support. See the autoconf manual "Limitations of +# Make". +# +# Generated .h files which are used by gmp-impl.h are BUILT_SOURCES since +# they must exist before anything can be compiled. +# +# Other generated .h files are also BUILT_SOURCES so as to get all the +# build-system stuff over and done with at the start. Also, dependencies on +# the .h files are not properly expressed for the various objects that use +# them. # Avoid: CVS - cvs directories # *~ - emacs backups diff --git a/doc/stamp-vti b/doc/stamp-vti index 903857fa..96c63ef6 100644 --- a/doc/stamp-vti +++ b/doc/stamp-vti @@ -1,4 +1,4 @@ -@set UPDATED 23 May 2010 -@set UPDATED-MONTH May 2010 -@set EDITION 2.0.0 -@set VERSION 2.0.0 +@set UPDATED 25 June 2010 +@set UPDATED-MONTH June 2010 +@set EDITION 2.1.1 +@set VERSION 2.1.1 diff --git a/doc/version.texi b/doc/version.texi index 56a5f179..96c63ef6 100644 --- a/doc/version.texi +++ b/doc/version.texi @@ -1,4 +1,4 @@ -@set UPDATED 24 June 2010 +@set UPDATED 25 June 2010 @set UPDATED-MONTH June 2010 @set EDITION 2.1.1 @set VERSION 2.1.1 diff --git a/dumbmp.c b/dumbmp.c deleted file mode 100644 index 87aee2ef..00000000 --- a/dumbmp.c +++ /dev/null @@ -1,889 +0,0 @@ -/* dumbmp mini GMP compatible library. - -Copyright 2001, 2002, 2004 Free Software Foundation, Inc. - -This file is part of the GNU MP Library. - -The GNU MP Library is free software; you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation; either version 2.1 of the License, or (at your -option) any later version. - -The GNU MP Library is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public -License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -MA 02110-1301, USA. */ - - -/* The code here implements a subset (a very limited subset) of the main GMP - functions. It's designed for use in a few build-time calculations and - will be slow, but highly portable. - - None of the normal GMP configure things are used, nor any of the normal - mpir.h or gmp-impl.h. To use this file in a program just #include - "dumbmp.c". - - ANSI function definitions can be used here but other ANSI-isms like - "const" should be avoided. - - mp_limb_t here is an unsigned long, since that's a sensible type - everywhere we know of, with 8*sizeof(unsigned long) giving the number of - bits in the type (that not being true for instance with int or short on - Cray vector systems.) - - Only the low half of each mp_limb_t is used, so as to make carry handling - and limb multiplies easy. GMP_LIMB_BITS is the number of bits used. */ - -#include -#include -#include - - -typedef unsigned long mp_limb_t; - -typedef struct { - int _mp_alloc; - int _mp_size; - mp_limb_t *_mp_d; -} mpz_t[1]; - -#define GMP_LIMB_BITS (sizeof (mp_limb_t) * 8 / 2) - -#define ABS(x) ((x) >= 0 ? (x) : -(x)) -#define MIN(l,o) ((l) < (o) ? (l) : (o)) -#define MAX(h,i) ((h) > (i) ? (h) : (i)) - -#define ALLOC(x) ((x)->_mp_alloc) -#define PTR(x) ((x)->_mp_d) -#define SIZ(x) ((x)->_mp_size) -#define ABSIZ(x) ABS (SIZ (x)) -#define LOMASK ((1L << GMP_LIMB_BITS) - 1) -#define LO(x) ((x) & LOMASK) -#define HI(x) ((x) >> GMP_LIMB_BITS) - -#define ASSERT(cond) \ - do { \ - if (! (cond)) \ - { \ - fprintf (stderr, "Assertion failure\n"); \ - abort (); \ - } \ - } while (0) - - -char * -xmalloc (int n) -{ - char *p; - p = malloc (n); - if (p == NULL) - { - fprintf (stderr, "Out of memory (alloc %d bytes)\n", n); - abort (); - } - return p; -} - -mp_limb_t * -xmalloc_limbs (int n) -{ - return (mp_limb_t *) xmalloc (n * sizeof (mp_limb_t)); -} - -void -mem_copyi (char *dst, char *src, int size) -{ - int i; - for (i = 0; i < size; i++) - dst[i] = src[i]; -} - -int -isprime (int n) -{ - int i; - if (n < 2) - return 0; - for (i = 2; i < n; i++) - if ((n % i) == 0) - return 0; - return 1; -} - -int -log2_ceil (int n) -{ - int e; - ASSERT (n >= 1); - for (e = 0; ; e++) - if ((1 << e) >= n) - break; - return e; -} - -void -mpz_realloc (mpz_t r, int n) -{ - if (n <= ALLOC(r)) - return; - - ALLOC(r) = n; - PTR(r) = (mp_limb_t *) realloc (PTR(r), n * sizeof (mp_limb_t)); - if (PTR(r) == NULL) - { - fprintf (stderr, "Out of memory (realloc to %d)\n", n); - abort (); - } -} - -void -mpn_normalize (mp_limb_t *rp, int *rnp) -{ - int rn = *rnp; - while (rn > 0 && rp[rn-1] == 0) - rn--; - *rnp = rn; -} - -void -mpn_copyi (mp_limb_t *dst, mp_limb_t *src, int n) -{ - int i; - for (i = 0; i < n; i++) - dst[i] = src[i]; -} - -void -mpn_zero (mp_limb_t *rp, int rn) -{ - int i; - for (i = 0; i < rn; i++) - rp[i] = 0; -} - -void -mpz_init (mpz_t r) -{ - ALLOC(r) = 1; - PTR(r) = xmalloc_limbs (ALLOC(r)); - PTR(r)[0] = 0; - SIZ(r) = 0; -} - -void -mpz_clear (mpz_t r) -{ - free (PTR (r)); - ALLOC(r) = -1; - SIZ (r) = 0xbadcafeL; - PTR (r) = (mp_limb_t *) 0xdeadbeefL; -} - -int -mpz_sgn (mpz_t a) -{ - return (SIZ(a) > 0 ? 1 : SIZ(a) == 0 ? 0 : -1); -} - -int -mpz_odd_p (mpz_t a) -{ - if (SIZ(a) == 0) - return 0; - else - return (PTR(a)[0] & 1) != 0; -} - -int -mpz_even_p (mpz_t a) -{ - if (SIZ(a) == 0) - return 1; - else - return (PTR(a)[0] & 1) == 0; -} - -size_t -mpz_sizeinbase (mpz_t a, int base) -{ - int an = ABSIZ (a); - mp_limb_t *ap = PTR (a); - int cnt; - mp_limb_t hi; - - if (base != 2) - abort (); - - if (an == 0) - return 1; - - cnt = 0; - for (hi = ap[an - 1]; hi != 0; hi >>= 1) - cnt += 1; - return (an - 1) * GMP_LIMB_BITS + cnt; -} - -void -mpz_set (mpz_t r, mpz_t a) -{ - mpz_realloc (r, ABSIZ (a)); - SIZ(r) = SIZ(a); - mpn_copyi (PTR(r), PTR(a), ABSIZ (a)); -} - -void -mpz_init_set (mpz_t r, mpz_t a) -{ - mpz_init (r); - mpz_set (r, a); -} - -void -mpz_set_ui (mpz_t r, unsigned long ui) -{ - int rn; - mpz_realloc (r, 2); - PTR(r)[0] = LO(ui); - PTR(r)[1] = HI(ui); - rn = 2; - mpn_normalize (PTR(r), &rn); - SIZ(r) = rn; -} - -void -mpz_init_set_ui (mpz_t r, unsigned long ui) -{ - mpz_init (r); - mpz_set_ui (r, ui); -} - -void -mpz_setbit (mpz_t r, unsigned long bit) -{ - int limb, rn, extend; - mp_limb_t *rp; - - rn = SIZ(r); - if (rn < 0) - abort (); /* only r>=0 */ - - limb = bit / GMP_LIMB_BITS; - bit %= GMP_LIMB_BITS; - - mpz_realloc (r, limb+1); - rp = PTR(r); - extend = (limb+1) - rn; - if (extend > 0) - mpn_zero (rp + rn, extend); - - rp[limb] |= (mp_limb_t) 1 << bit; - SIZ(r) = MAX (rn, limb+1); -} - -int -mpz_tstbit (mpz_t r, unsigned long bit) -{ - int limb; - - if (SIZ(r) < 0) - abort (); /* only r>=0 */ - - limb = bit / GMP_LIMB_BITS; - if (SIZ(r) <= limb) - return 0; - - bit %= GMP_LIMB_BITS; - return (PTR(r)[limb] >> bit) & 1; -} - -int -popc_limb (mp_limb_t a) -{ - int ret = 0; - while (a != 0) - { - ret += (a & 1); - a >>= 1; - } - return ret; -} - -unsigned long -mpz_popcount (mpz_t a) -{ - unsigned long ret; - int i; - - if (SIZ(a) < 0) - abort (); - - ret = 0; - for (i = 0; i < SIZ(a); i++) - ret += popc_limb (PTR(a)[i]); - return ret; -} - -void -mpz_add (mpz_t r, mpz_t a, mpz_t b) -{ - int an = ABSIZ (a), bn = ABSIZ (b), rn; - mp_limb_t *rp, *ap, *bp; - int i; - mp_limb_t t, cy; - - if ((SIZ (a) ^ SIZ (b)) < 0) - abort (); /* really subtraction */ - if (SIZ (a) < 0) - abort (); - - mpz_realloc (r, MAX (an, bn) + 1); - ap = PTR (a); bp = PTR (b); rp = PTR (r); - if (an < bn) - { - mp_limb_t *tp; int tn; - tn = an; an = bn; bn = tn; - tp = ap; ap = bp; bp = tp; - } - - cy = 0; - for (i = 0; i < bn; i++) - { - t = ap[i] + bp[i] + cy; - rp[i] = LO (t); - cy = HI (t); - } - for (i = bn; i < an; i++) - { - t = ap[i] + cy; - rp[i] = LO (t); - cy = HI (t); - } - rp[an] = cy; - rn = an + 1; - - mpn_normalize (rp, &rn); - SIZ (r) = rn; -} - -void -mpz_add_ui (mpz_t r, mpz_t a, unsigned long int ui) -{ - mpz_t b; - - mpz_init (b); - mpz_set_ui (b, ui); - mpz_add (r, a, b); - mpz_clear (b); -} - -void -mpz_sub (mpz_t r, mpz_t a, mpz_t b) -{ - int an = ABSIZ (a), bn = ABSIZ (b), rn; - mp_limb_t *rp, *ap, *bp; - int i; - mp_limb_t t, cy; - - if ((SIZ (a) ^ SIZ (b)) < 0) - abort (); /* really addition */ - if (SIZ (a) < 0) - abort (); - - mpz_realloc (r, MAX (an, bn) + 1); - ap = PTR (a); bp = PTR (b); rp = PTR (r); - if (an < bn) - { - mp_limb_t *tp; int tn; - tn = an; an = bn; bn = tn; - tp = ap; ap = bp; bp = tp; - } - - cy = 0; - for (i = 0; i < bn; i++) - { - t = ap[i] - bp[i] - cy; - rp[i] = LO (t); - cy = LO (-HI (t)); - } - for (i = bn; i < an; i++) - { - t = ap[i] - cy; - rp[i] = LO (t); - cy = LO (-HI (t)); - } - rp[an] = cy; - rn = an + 1; - - if (cy != 0) - { - cy = 0; - for (i = 0; i < rn; i++) - { - t = -rp[i] - cy; - rp[i] = LO (t); - cy = LO (-HI (t)); - } - SIZ (r) = -rn; - return; - } - - mpn_normalize (rp, &rn); - SIZ (r) = rn; -} - -void -mpz_sub_ui (mpz_t r, mpz_t a, unsigned long int ui) -{ - mpz_t b; - - mpz_init (b); - mpz_set_ui (b, ui); - mpz_sub (r, a, b); - mpz_clear (b); -} - -void -mpz_mul (mpz_t r, mpz_t a, mpz_t b) -{ - int an = ABSIZ (a), bn = ABSIZ (b), rn; - mp_limb_t *scratch, *tmp, *ap = PTR (a), *bp = PTR (b); - int ai, bi; - mp_limb_t t, cy; - - scratch = xmalloc_limbs (an + bn); - tmp = scratch; - - for (bi = 0; bi < bn; bi++) - tmp[bi] = 0; - - for (ai = 0; ai < an; ai++) - { - tmp = scratch + ai; - cy = 0; - for (bi = 0; bi < bn; bi++) - { - t = ap[ai] * bp[bi] + tmp[bi] + cy; - tmp[bi] = LO (t); - cy = HI (t); - } - tmp[bn] = cy; - } - - rn = an + bn; - mpn_normalize (scratch, &rn); - free (PTR (r)); - PTR (r) = scratch; - SIZ (r) = (SIZ (a) ^ SIZ (b)) >= 0 ? rn : -rn; - ALLOC (r) = an + bn; -} - -void -mpz_mul_ui (mpz_t r, mpz_t a, unsigned long int ui) -{ - mpz_t b; - - mpz_init (b); - mpz_set_ui (b, ui); - mpz_mul (r, a, b); - mpz_clear (b); -} - -void -mpz_mul_2exp (mpz_t r, mpz_t a, unsigned long int bcnt) -{ - mpz_set (r, a); - while (bcnt) - { - mpz_add (r, r, r); - bcnt -= 1; - } -} - -void -mpz_ui_pow_ui (mpz_t r, unsigned long b, unsigned long e) -{ - unsigned long i; - mpz_t bz; - - mpz_init (bz); - mpz_set_ui (bz, b); - - mpz_set_ui (r, 1L); - for (i = 0; i < e; i++) - mpz_mul (r, r, bz); - - mpz_clear (bz); -} - -void -mpz_tdiv_q_2exp (mpz_t r, mpz_t a, unsigned long int bcnt) -{ - int as, rn; - int cnt, tnc; - int lcnt; - mp_limb_t high_limb, low_limb; - int i; - - as = SIZ (a); - lcnt = bcnt / GMP_LIMB_BITS; - rn = ABS (as) - lcnt; - if (rn <= 0) - SIZ (r) = 0; - else - { - mp_limb_t *rp, *ap; - - mpz_realloc (r, rn); - - rp = PTR (r); - ap = PTR (a); - - cnt = bcnt % GMP_LIMB_BITS; - if (cnt != 0) - { - ap += lcnt; - tnc = GMP_LIMB_BITS - cnt; - high_limb = *ap++; - low_limb = high_limb >> cnt; - - for (i = rn - 1; i != 0; i--) - { - high_limb = *ap++; - *rp++ = low_limb | LO (high_limb << tnc); - low_limb = high_limb >> cnt; - } - *rp = low_limb; - rn -= low_limb == 0; - } - else - { - ap += lcnt; - mpn_copyi (rp, ap, rn); - } - - SIZ (r) = as >= 0 ? rn : -rn; - } -} - -void -mpz_tdiv_r_2exp (mpz_t r, mpz_t a, unsigned long int bcnt) -{ - int rn, bwhole; - - mpz_set (r, a); - rn = ABSIZ(r); - - bwhole = bcnt / GMP_LIMB_BITS; - bcnt %= GMP_LIMB_BITS; - if (rn > bwhole) - { - rn = bwhole+1; - PTR(r)[rn-1] &= ((mp_limb_t) 1 << bcnt) - 1; - mpn_normalize (PTR(r), &rn); - SIZ(r) = (SIZ(r) >= 0 ? rn : -rn); - } -} - -int -mpz_cmp (mpz_t a, mpz_t b) -{ - mp_limb_t *ap, *bp, al, bl; - int as = SIZ (a), bs = SIZ (b); - int i; - int sign; - - if (as != bs) - return as > bs ? 1 : -1; - - sign = as > 0 ? 1 : -1; - - ap = PTR (a); - bp = PTR (b); - for (i = ABS (as) - 1; i >= 0; i--) - { - al = ap[i]; - bl = bp[i]; - if (al != bl) - return al > bl ? sign : -sign; - } - return 0; -} - -int -mpz_cmp_ui (mpz_t a, unsigned long b) -{ - mpz_t bz; - int ret; - mpz_init_set_ui (bz, b); - ret = mpz_cmp (a, bz); - mpz_clear (bz); - return ret; -} - -void -mpz_tdiv_qr (mpz_t q, mpz_t r, mpz_t a, mpz_t b) -{ - mpz_t tmpr, tmpb; - unsigned long cnt; - - ASSERT (mpz_sgn(a) >= 0); - ASSERT (mpz_sgn(b) > 0); - - mpz_init_set (tmpr, a); - mpz_init_set (tmpb, b); - mpz_set_ui (q, 0L); - - if (mpz_cmp (tmpr, tmpb) > 0) - { - cnt = mpz_sizeinbase (tmpr, 2) - mpz_sizeinbase (tmpb, 2) + 1; - mpz_mul_2exp (tmpb, tmpb, cnt); - - for ( ; cnt > 0; cnt--) - { - mpz_mul_2exp (q, q, 1); - mpz_tdiv_q_2exp (tmpb, tmpb, 1L); - if (mpz_cmp (tmpr, tmpb) >= 0) - { - mpz_sub (tmpr, tmpr, tmpb); - mpz_add_ui (q, q, 1L); - ASSERT (mpz_cmp (tmpr, tmpb) < 0); - } - } - } - - mpz_set (r, tmpr); - mpz_clear (tmpr); - mpz_clear (tmpb); -} - -void -mpz_tdiv_qr_ui (mpz_t q, mpz_t r, mpz_t a, unsigned long b) -{ - mpz_t bz; - mpz_init_set_ui (bz, b); - mpz_tdiv_qr (q, r, a, bz); - mpz_clear (bz); -} - -void -mpz_tdiv_q (mpz_t q, mpz_t a, mpz_t b) -{ - mpz_t r; - - mpz_init (r); - mpz_tdiv_qr (q, r, a, b); - mpz_clear (r); -} - -void -mpz_tdiv_q_ui (mpz_t q, mpz_t n, unsigned long d) -{ - mpz_t dz; - mpz_init_set_ui (dz, d); - mpz_tdiv_q (q, n, dz); - mpz_clear (dz); -} - -/* Set inv to the inverse of d, in the style of invert_limb, ie. for - udiv_qrnnd_preinv. */ -void -mpz_preinv_invert (mpz_t inv, mpz_t d, int numb_bits) -{ - mpz_t t; - int norm; - ASSERT (SIZ(d) > 0); - - norm = numb_bits - mpz_sizeinbase (d, 2); - ASSERT (norm >= 0); - mpz_init_set_ui (t, 1L); - mpz_mul_2exp (t, t, 2*numb_bits - norm); - mpz_tdiv_q (inv, t, d); - mpz_set_ui (t, 1L); - mpz_mul_2exp (t, t, numb_bits); - mpz_sub (inv, inv, t); - - mpz_clear (t); -} - -/* Remove leading '0' characters from the start of a string, by copying the - remainder down. */ -void -strstrip_leading_zeros (char *s) -{ - char c, *p; - - p = s; - while (*s == '0') - s++; - - do - { - c = *s++; - *p++ = c; - } - while (c != '\0'); -} - -char * -mpz_get_str (char *buf, int base, mpz_t a) -{ - static char tohex[] = "0123456789abcdef"; - - mp_limb_t alimb, *ap; - int an, bn, i, j; - char *bp; - - if (base != 16) - abort (); - if (SIZ (a) < 0) - abort (); - - if (buf == 0) - buf = xmalloc (ABSIZ (a) * (GMP_LIMB_BITS / 4) + 3); - - an = ABSIZ (a); - if (an == 0) - { - buf[0] = '0'; - buf[1] = '\0'; - return buf; - } - - ap = PTR (a); - bn = an * (GMP_LIMB_BITS / 4); - bp = buf + bn; - - for (i = 0; i < an; i++) - { - alimb = ap[i]; - for (j = 0; j < GMP_LIMB_BITS / 4; j++) - { - bp--; - *bp = tohex [alimb & 0xF]; - alimb >>= 4; - } - ASSERT (alimb == 0); - } - ASSERT (bp == buf); - - buf[bn] = '\0'; - - strstrip_leading_zeros (buf); - return buf; -} - -void -mpz_out_str (FILE *file, int base, mpz_t a) -{ - char *str; - - if (file == 0) - file = stdout; - - str = mpz_get_str (0, 16, a); - fputs (str, file); - free (str); -} - -/* Calculate r satisfying r*d == 1 mod 2^n. */ -void -mpz_invert_2exp (mpz_t r, mpz_t a, unsigned long n) -{ - unsigned long i; - mpz_t inv, prod; - - ASSERT (mpz_odd_p (a)); - - mpz_init_set_ui (inv, 1L); - mpz_init (prod); - - for (i = 1; i < n; i++) - { - mpz_mul (prod, inv, a); - if (mpz_tstbit (prod, i) != 0) - mpz_setbit (inv, i); - } - - mpz_mul (prod, inv, a); - mpz_tdiv_r_2exp (prod, prod, n); - ASSERT (mpz_cmp_ui (prod, 1L) == 0); - - mpz_set (r, inv); - - mpz_clear (inv); - mpz_clear (prod); -} - -/* Calculate inv satisfying r*a == 1 mod 2^n. */ -void -mpz_invert_ui_2exp (mpz_t r, unsigned long a, unsigned long n) -{ - mpz_t az; - mpz_init_set_ui (az, a); - mpz_invert_2exp (r, az, n); - mpz_clear (az); -} - -/* x=y^z */ -void -mpz_pow_ui (mpz_t x, mpz_t y, unsigned long z) -{ - mpz_t t; - - mpz_init_set_ui (t, 1); - for (; z != 0; z--) - mpz_mul (t, t, y); - mpz_set (x, t); - mpz_clear (t); -} - -/* x=x+y*z */ -void -mpz_addmul_ui (mpz_t x, mpz_t y, unsigned long z) -{ - mpz_t t; - - mpz_init (t); - mpz_mul_ui (t, y, z); - mpz_add (x, x, t); - mpz_clear (t); -} - -/* x=floor(y^(1/z)) */ -void -mpz_root (mpz_t x, mpz_t y, unsigned long z) -{ - mpz_t t, u; - - if (mpz_sgn (y) < 0) - { - fprintf (stderr, "mpz_root does not accept negative values\n"); - abort (); - } - if (mpz_cmp_ui (y, 1) <= 0) - { - mpz_set (x, y); - return; - } - mpz_init (t); - mpz_init_set (u, y); - do - { - mpz_pow_ui (t, u, z - 1); - mpz_tdiv_q (t, y, t); - mpz_addmul_ui (t, u, z - 1); - mpz_tdiv_q_ui (t, t, z); - if (mpz_cmp (t, u) >= 0) - break; - mpz_set (u, t); - } - while (1); - mpz_set (x, u); - mpz_clear (t); - mpz_clear (u); -} diff --git a/fib_table.h b/fib_table.h new file mode 100644 index 00000000..f14c89b1 --- /dev/null +++ b/fib_table.h @@ -0,0 +1,11 @@ +/* This file generated by gen-fib.c - DO NOT EDIT. */ + +#if GMP_NUMB_BITS == 32 +#define FIB_TABLE_LIMIT 47 +#define FIB_TABLE_LUCNUM_LIMIT 46 +#endif /* 32bit */ + +#if GMP_NUMB_BITS == 64 +#define FIB_TABLE_LIMIT 93 +#define FIB_TABLE_LUCNUM_LIMIT 92 +#endif /* 64bits */ diff --git a/gen-bases.c b/gen-bases.c deleted file mode 100644 index dae7e096..00000000 --- a/gen-bases.c +++ /dev/null @@ -1,183 +0,0 @@ -/* Generate mp_bases data. - -Copyright 1991, 1993, 1994, 1996, 2000, 2002, 2004 Free Software Foundation, -Inc. - -This file is part of the GNU MP Library. - -The GNU MP Library is free software; you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation; either version 2.1 of the License, or (at your -option) any later version. - -The GNU MP Library is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public -License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -MA 02110-1301, USA. */ - -#include - -#include "dumbmp.c" - - -int chars_per_limb; -double chars_per_bit_exactly; -mpz_t big_base; -int normalization_steps; -mpz_t big_base_inverted; - -mpz_t t; - -#define POW2_P(n) (((n) & ((n) - 1)) == 0) - -unsigned int -ulog2 (unsigned int x) -{ - unsigned int i; - for (i = 0; x != 0; i++) - x >>= 1; - return i; -} - -void -generate (int limb_bits, int nail_bits, int base) -{ - int numb_bits = limb_bits - nail_bits; - - mpz_set_ui (t, 1L); - mpz_mul_2exp (t, t, numb_bits); - mpz_set_ui (big_base, 1L); - chars_per_limb = 0; - for (;;) - { - mpz_mul_ui (big_base, big_base, (long) base); - if (mpz_cmp (big_base, t) > 0) - break; - chars_per_limb++; - } - - chars_per_bit_exactly = 0.69314718055994530942 / log ((double) base); - - mpz_ui_pow_ui (big_base, (long) base, (long) chars_per_limb); - - normalization_steps = limb_bits - mpz_sizeinbase (big_base, 2); - - mpz_set_ui (t, 1L); - mpz_mul_2exp (t, t, 2*limb_bits - normalization_steps); - mpz_tdiv_q (big_base_inverted, t, big_base); - mpz_set_ui (t, 1L); - mpz_mul_2exp (t, t, limb_bits); - mpz_sub (big_base_inverted, big_base_inverted, t); -} - -void -header (int limb_bits, int nail_bits) -{ - int numb_bits = limb_bits - nail_bits; - - generate (limb_bits, nail_bits, 10); - - printf ("/* This file generated by gen-bases.c - DO NOT EDIT. */\n"); - printf ("\n"); - printf ("#if GMP_NUMB_BITS != %d\n", numb_bits); - printf ("Error, error, this data is for %d bits\n", numb_bits); - printf ("#endif\n"); - printf ("\n"); - printf ("/* mp_bases[10] data, as literal values */\n"); - printf ("#define MP_BASES_CHARS_PER_LIMB_10 %d\n", chars_per_limb); - printf ("#define MP_BASES_BIG_BASE_10 CNST_LIMB(0x"); - mpz_out_str (stdout, 16, big_base); - printf (")\n"); - printf ("#define MP_BASES_BIG_BASE_INVERTED_10 CNST_LIMB(0x"); - mpz_out_str (stdout, 16, big_base_inverted); - printf (")\n"); - printf ("#define MP_BASES_NORMALIZATION_STEPS_10 %d\n", normalization_steps); -} - -void -table (int limb_bits, int nail_bits) -{ - int numb_bits = limb_bits - nail_bits; - int base; - - printf ("/* This file generated by gen-bases.c - DO NOT EDIT. */\n"); - printf ("\n"); - printf ("#include \"mpir.h\"\n"); - printf ("#include \"gmp-impl.h\"\n"); - printf ("\n"); - printf ("#if GMP_NUMB_BITS != %d\n", numb_bits); - printf ("Error, error, this data is for %d bits\n", numb_bits); - printf ("#endif\n"); - printf ("\n"); - puts ("const struct bases mp_bases[257] =\n{"); - puts (" /* 0 */ { 0, 0.0, 0 },"); - puts (" /* 1 */ { 0, 1e37, 0 },"); - for (base = 2; base <= 256; base++) - { - generate (limb_bits, nail_bits, base); - - printf (" /* %3u */ { ", base); - if (POW2_P (base)) - { - printf ("%u, %.16f, 0x%x },\n", - chars_per_limb, chars_per_bit_exactly, ulog2 (base) - 1); - } - else - { - printf ("%u, %.16f, CNST_LIMB(0x", - chars_per_limb, chars_per_bit_exactly); - mpz_out_str (stdout, 16, big_base); - printf ("), CNST_LIMB(0x"); - mpz_out_str (stdout, 16, big_base_inverted); - printf (") },\n"); - } - } - - puts ("};"); -} - -int -main (int argc, char **argv) -{ - int limb_bits, nail_bits; - - mpz_init (big_base); - mpz_init (big_base_inverted); - mpz_init (t); - - if (argc != 4) - { - fprintf (stderr, "Usage: gen-bases \n"); - exit (1); - } - - limb_bits = atoi (argv[2]); - nail_bits = atoi (argv[3]); - - if (limb_bits <= 0 - || nail_bits < 0 - || nail_bits >= limb_bits) - { - fprintf (stderr, "Invalid limb/nail bits: %d %d\n", - limb_bits, nail_bits); - exit (1); - } - - if (strcmp (argv[1], "header") == 0) - header (limb_bits, nail_bits); - else if (strcmp (argv[1], "table") == 0) - table (limb_bits, nail_bits); - else - { - fprintf (stderr, "Invalid header/table choice: %s\n", argv[1]); - exit (1); - } - - return 0; -} - diff --git a/gen-fac_ui.c b/gen-fac_ui.c deleted file mode 100644 index 00cfbf68..00000000 --- a/gen-fac_ui.c +++ /dev/null @@ -1,161 +0,0 @@ -/* Generate mpz_fac_ui data. - -Copyright 2002 Free Software Foundation, Inc. - -This file is part of the GNU MP Library. - -The GNU MP Library is free software; you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation; either version 2.1 of the License, or (at your -option) any later version. - -The GNU MP Library is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public -License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -MA 02110-1301, USA. */ - -#include -#include - -#include "dumbmp.c" - - -/* sets x=y*(y+2)*(y+4)*....*(y+2*(z-1)) */ -void -odd_products (mpz_t x, mpz_t y, int z) -{ - mpz_t t; - - mpz_init_set (t, y); - mpz_set_ui (x, 1); - for (; z != 0; z--) - { - mpz_mul (x, x, t); - mpz_add_ui (t, t, 2); - } - mpz_clear (t); - return; -} - -/* returns 0 on success */ -int -gen_consts (int numb, int nail, int limb) -{ - mpz_t x, y, z, t; - unsigned long a, b, first = 1; - - 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"); - 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"); - - printf - ("/* This table is 0!,1!,2!,3!,...,n! where n! has <= GMP_NUMB_BITS bits */\n"); - printf - ("#define ONE_LIMB_FACTORIAL_TABLE CNST_LIMB(0x1),CNST_LIMB(0x1),CNST_LIMB(0x2),"); - mpz_init_set_ui (x, 2); - for (b = 3;; b++) - { - mpz_mul_ui (x, x, b); /* so b!=a */ - if (mpz_sizeinbase (x, 2) > numb) - break; - if (first) - { - first = 0; - } - else - { - printf ("),"); - } - printf ("CNST_LIMB(0x"); - mpz_out_str (stdout, 16, x); - } - printf (")\n"); - - - mpz_set_ui (x, 1); - mpz_mul_2exp (x, x, limb + 1); /* x=2^(limb+1) */ - mpz_init (y); - mpz_set_ui (y, 10000); - mpz_mul (x, x, y); /* x=2^(limb+1)*10^4 */ - mpz_set_ui (y, 27182); /* exp(1)*10^4 */ - mpz_tdiv_q (x, x, y); /* x=2^(limb+1)/exp(1) */ - printf ("\n/* is 2^(GMP_LIMB_BITS+1)/exp(1) */\n"); - printf ("#define FAC2OVERE CNST_LIMB(0x"); - mpz_out_str (stdout, 16, x); - printf (")\n"); - - - printf - ("\n/* FACMULn is largest odd x such that x*(x+2)*...*(x+2(n-1))<=2^GMP_NUMB_BITS-1 */\n\n"); - mpz_init (z); - mpz_init (t); - for (a = 2; a <= 4; a++) - { - mpz_set_ui (x, 1); - mpz_mul_2exp (x, x, numb); - mpz_root (x, x, a); - /* so x is approx sol */ - if (mpz_even_p (x)) - mpz_sub_ui (x, x, 1); - mpz_set_ui (y, 1); - mpz_mul_2exp (y, y, numb); - mpz_sub_ui (y, y, 1); - /* decrement x until we are <= real sol */ - do - { - mpz_sub_ui (x, x, 2); - odd_products (t, x, a); - if (mpz_cmp (t, y) <= 0) - break; - } - while (1); - /* increment x until > real sol */ - do - { - mpz_add_ui (x, x, 2); - odd_products (t, x, a); - if (mpz_cmp (t, y) > 0) - break; - } - while (1); - /* dec once to get real sol */ - mpz_sub_ui (x, x, 2); - printf ("#define FACMUL%lu CNST_LIMB(0x", a); - mpz_out_str (stdout, 16, x); - printf (")\n"); - } - - return 0; -} - -int -main (int argc, char *argv[]) -{ - int nail_bits, limb_bits, numb_bits; - - if (argc != 3) - { - fprintf (stderr, "Usage: gen-fac_ui limbbits nailbits\n"); - exit (1); - } - limb_bits = atoi (argv[1]); - nail_bits = atoi (argv[2]); - numb_bits = limb_bits - nail_bits; - if (limb_bits < 0 || nail_bits < 0 || numb_bits < 0) - { - fprintf (stderr, "Invalid limb/nail bits %d,%d\n", limb_bits, - nail_bits); - exit (1); - } - gen_consts (numb_bits, nail_bits, limb_bits); - return 0; -} diff --git a/gen-fib.c b/gen-fib.c deleted file mode 100644 index 8a5f1411..00000000 --- a/gen-fib.c +++ /dev/null @@ -1,147 +0,0 @@ -/* Generate Fibonacci table data. - -Copyright 2001, 2002, 2004 Free Software Foundation, Inc. - -This file is part of the GNU MP Library. - -The GNU MP Library is free software; you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation; either version 2.1 of the License, or (at your -option) any later version. - -The GNU MP Library is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public -License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -MA 02110-1301, USA. */ - -#include -#include "dumbmp.c" - -mpz_t *f; -int fnum, fib_limit, luc_limit; - -void -generate (int numb_bits) -{ - mpz_t limit, l; - int falloc, i; - - mpz_init_set_ui (limit, 1L); - mpz_mul_2exp (limit, limit, numb_bits); - - /* fib(2n) > 2^n, so use 2n as a limit for the table size */ - falloc = 2 * numb_bits; - f = (mpz_t *) xmalloc (falloc * sizeof (*f)); - - mpz_init_set_ui (f[0], 1L); /* F[-1] */ - mpz_init_set_ui (f[1], 0L); /* F[0] */ - - mpz_init (l); - - for (i = 2; ; i++) - { - ASSERT (i < falloc); - - /* F[i] = F[i-1] + F[i-2] */ - mpz_init (f[i]); - mpz_add (f[i], f[i-1], f[i-2]); - if (mpz_cmp (f[i], limit) >= 0) - break; - - fnum = i+1; - fib_limit = i-1; - - /* L[i] = F[i]+2*F[i-1] */ - mpz_add (l, f[i], f[i-1]); - mpz_add (l, l, f[i-1]); - - if (mpz_cmp (l, limit) < 0) - luc_limit = i-1; - } - - mpz_clear (limit); -} - - -void -header (int numb_bits) -{ - printf ("/* This file generated by gen-fib.c - DO NOT EDIT. */\n"); - printf ("\n"); - printf ("#if GMP_NUMB_BITS != %d\n", numb_bits); - printf ("Error, error, this data is for %d bits\n", numb_bits); - printf ("#endif\n"); - printf ("\n"); - printf ("#define FIB_TABLE_LIMIT %d\n", fib_limit); - printf ("#define FIB_TABLE_LUCNUM_LIMIT %d\n", luc_limit); -} - -void -table (int numb_bits) -{ - int i; - - printf ("/* This file generated by gen-fib.c - DO NOT EDIT. */\n"); - printf ("\n"); - printf ("#include \"mpir.h\"\n"); - printf ("#include \"gmp-impl.h\"\n"); - printf ("\n"); - printf ("#if GMP_NUMB_BITS != %d\n", numb_bits); - printf ("Error, error, this data is for %d bits\n", numb_bits); - printf ("#endif\n"); - printf ("\n"); - printf ("const mp_limb_t\n"); - printf ("__gmp_fib_table[FIB_TABLE_LIMIT+2] = {\n"); - - for (i = 0; i < fnum; i++) - { - printf (" CNST_LIMB (0x"); - mpz_out_str (stdout, 16, f[i]); - printf ("), /* %d */\n", i-1); - } - printf ("};\n"); -} - -int -main (int argc, char *argv[]) -{ - int limb_bits, nail_bits, numb_bits; - - if (argc != 4) - { - fprintf (stderr, "Usage: gen-bases \n"); - exit (1); - } - - limb_bits = atoi (argv[2]); - nail_bits = atoi (argv[3]); - - if (limb_bits <= 0 - || nail_bits < 0 - || nail_bits >= limb_bits) - { - fprintf (stderr, "Invalid limb/nail bits: %d %d\n", - limb_bits, nail_bits); - exit (1); - } - numb_bits = limb_bits - nail_bits; - - generate (numb_bits); - - if (strcmp (argv[1], "header") == 0) - header (numb_bits); - else if (strcmp (argv[1], "table") == 0) - table (numb_bits); - else - { - fprintf (stderr, "Invalid header/table choice: %s\n", argv[1]); - exit (1); - } - - return 0; -} diff --git a/gen-psqr.c b/gen-psqr.c deleted file mode 100644 index f92905b2..00000000 --- a/gen-psqr.c +++ /dev/null @@ -1,578 +0,0 @@ -/* Generate perfect square testing data. - -Copyright 2002, 2003, 2004 Free Software Foundation, Inc. - -This file is part of the GNU MP Library. - -The GNU MP Library is free software; you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation; either version 2.1 of the License, or (at your -option) any later version. - -The GNU MP Library is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public -License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -MA 02110-1301, USA. */ - -#include -#include - -#include "dumbmp.c" - - -/* The aim of this program is to choose either mpn_mod_34lsub1 or mpn_mod_1 - (plus a PERFSQR_PP modulus), and generate tables indicating quadratic - residues and non-residues modulo small factors of that modulus. - - For the usual 32 or 64 bit cases mpn_mod_34lsub1 gets used. That - function exists specifically because 2^24-1 and 2^48-1 have nice sets of - prime factors. For other limb sizes it's considered, but if it doesn't - have good factors then mpn_mod_1 will be used instead. - - When mpn_mod_1 is used, the modulus PERFSQR_PP is created from a - selection of small primes, chosen to fill PERFSQR_MOD_BITS of a limb, - with that bit count chosen so (2*GMP_LIMB_BITS)*2^PERFSQR_MOD_BITS <= - GMP_LIMB_MAX, allowing PERFSQR_MOD_IDX in mpn/generic/perfsqr.c to do its - calculation within a single limb. - - In either case primes can be combined to make divisors. The table data - then effectively indicates remainders which are quadratic residues mod - all the primes. This sort of combining reduces the number of steps - needed after mpn_mod_34lsub1 or mpn_mod_1, saving code size and time. - Nothing is gained or lost in terms of detections, the same total fraction - of non-residues will be identified. - - Nothing particularly sophisticated is attempted for combining factors to - make divisors. This is probably a kind of knapsack problem so it'd be - too hard to attempt anything completely general. For the usual 32 and 64 - bit limbs we get a good enough result just pairing the biggest and - smallest which fit together, repeatedly. - - Another aim is to get powerful combinations, ie. divisors which identify - biggest fraction of non-residues, and have those run first. Again for - the usual 32 and 64 bits it seems good enough just to pair for big - divisors then sort according to the resulting fraction of non-residues - identified. - - Also in this program, a table sq_res_0x100 of residues modulo 256 is - generated. This simply fills bits into limbs of the appropriate - build-time GMP_LIMB_BITS each. - -*/ - - -/* Normally we aren't using const in gen*.c programs, so as not to have to - bother figuring out if it works, but using it with f_cmp_divisor and - f_cmp_fraction avoids warnings from the qsort calls. */ - -/* Same tests as mpir.h. */ -#if defined (__STDC__) \ - || defined (__cplusplus) \ - || defined (_AIX) \ - || defined (__DECC) \ - || (defined (__mips) && defined (_SYSTYPE_SVR4)) \ - || defined (_MSC_VER) \ - || defined (_WIN32) -#define HAVE_CONST 1 -#endif - -#if ! HAVE_CONST -#define const -#endif - - -mpz_t *sq_res_0x100; /* table of limbs */ -int nsq_res_0x100; /* elements in sq_res_0x100 array */ -int sq_res_0x100_num; /* squares in sq_res_0x100 */ -double sq_res_0x100_fraction; /* sq_res_0x100_num / 256 */ - -int mod34_bits; /* 3*GMP_NUMB_BITS/4 */ -int mod_bits; /* bits from PERFSQR_MOD_34 or MOD_PP */ -int max_divisor; /* all divisors <= max_divisor */ -int max_divisor_bits; /* ceil(log2(max_divisor)) */ -double total_fraction; /* of squares */ -mpz_t pp; /* product of primes, or 0 if mod_34lsub1 used */ -mpz_t pp_norm; /* pp shifted so NUMB high bit set */ -mpz_t pp_inverted; /* invert_limb style inverse */ -mpz_t mod_mask; /* 2^mod_bits-1 */ -char mod34_excuse[128]; /* why mod_34lsub1 not used (if it's not) */ - -/* raw list of divisors of 2^mod34_bits-1 or pp, just to show in a comment */ -struct rawfactor_t { - int divisor; - int multiplicity; -}; -struct rawfactor_t *rawfactor; -int nrawfactor; - -/* factors of 2^mod34_bits-1 or pp and associated data, after combining etc */ -struct factor_t { - int divisor; - mpz_t inverse; /* 1/divisor mod 2^mod_bits */ - mpz_t mask; /* indicating squares mod divisor */ - double fraction; /* squares/total */ -}; -struct factor_t *factor; -int nfactor; /* entries in use in factor array */ -int factor_alloc; /* entries allocated to factor array */ - - -int -f_cmp_divisor (const void *parg, const void *qarg) -{ - const struct factor_t *p, *q; - p = parg; - q = qarg; - if (p->divisor > q->divisor) - return 1; - else if (p->divisor < q->divisor) - return -1; - else - return 0; -} - -int -f_cmp_fraction (const void *parg, const void *qarg) -{ - const struct factor_t *p, *q; - p = parg; - q = qarg; - if (p->fraction > q->fraction) - return 1; - else if (p->fraction < q->fraction) - return -1; - else - return 0; -} - -/* Remove array[idx] by copying the remainder down, and adjust narray - accordingly. */ -#define COLLAPSE_ELEMENT(array, idx, narray) \ - do { \ - mem_copyi ((char *) &(array)[idx], \ - (char *) &(array)[idx+1], \ - ((narray)-((idx)+1)) * sizeof (array[0])); \ - (narray)--; \ - } while (0) - - -/* return n*2^p mod m */ -int -mul_2exp_mod (int n, int p, int m) -{ - int i; - for (i = 0; i < p; i++) - n = (2 * n) % m; - return n; -} - -/* return -n mod m */ -int -neg_mod (int n, int m) -{ - ASSERT (n >= 0 && n < m); - return (n == 0 ? 0 : m-n); -} - -/* Set "mask" to a value such that "mask & (1< max_divisor / i) - break; - multiplicity++; - mpz_set (m, q); - mpz_tdiv_qr_ui (q, r, m, (unsigned long) i); - } - while (mpz_sgn (r) == 0); - - ASSERT (nrawfactor < factor_alloc); - rawfactor[nrawfactor].divisor = i; - rawfactor[nrawfactor].multiplicity = multiplicity; - nrawfactor++; - } - - mpz_clear (m); - mpz_clear (q); - mpz_clear (r); - } - - if (nrawfactor <= 2) - { - mpz_t new_pp; - - sprintf (mod34_excuse, "only %d small factor%s", - nrawfactor, nrawfactor == 1 ? "" : "s"); - - use_pp: - /* reset to two limbs of max_divisor, in case the mpn_mod_34lsub1 code - tried with just one */ - max_divisor = 2*limb_bits; - max_divisor_bits = log2_ceil (max_divisor); - - mpz_init (new_pp); - nrawfactor = 0; - mod_bits = MIN (numb_bits, limb_bits - max_divisor_bits); - - /* one copy of each small prime */ - mpz_set_ui (pp, 1L); - for (i = 3; i <= max_divisor; i++) - { - if (! isprime (i)) - continue; - - mpz_mul_ui (new_pp, pp, (unsigned long) i); - if (mpz_sizeinbase (new_pp, 2) > mod_bits) - break; - mpz_set (pp, new_pp); - - ASSERT (nrawfactor < factor_alloc); - rawfactor[nrawfactor].divisor = i; - rawfactor[nrawfactor].multiplicity = 1; - nrawfactor++; - } - - /* Plus an extra copy of one or more of the primes selected, if that - still fits in max_divisor and the total in mod_bits. Usually only - 3 or 5 will be candidates */ - for (i = nrawfactor-1; i >= 0; i--) - { - if (rawfactor[i].divisor > max_divisor / rawfactor[i].divisor) - continue; - mpz_mul_ui (new_pp, pp, (unsigned long) rawfactor[i].divisor); - if (mpz_sizeinbase (new_pp, 2) > mod_bits) - continue; - mpz_set (pp, new_pp); - - rawfactor[i].multiplicity++; - } - - mod_bits = mpz_sizeinbase (pp, 2); - - mpz_set (pp_norm, pp); - while (mpz_sizeinbase (pp_norm, 2) < numb_bits) - mpz_add (pp_norm, pp_norm, pp_norm); - - mpz_preinv_invert (pp_inverted, pp_norm, numb_bits); - - mpz_clear (new_pp); - } - - /* start the factor array */ - for (i = 0; i < nrawfactor; i++) - { - int j; - ASSERT (nfactor < factor_alloc); - factor[nfactor].divisor = 1; - for (j = 0; j < rawfactor[i].multiplicity; j++) - factor[nfactor].divisor *= rawfactor[i].divisor; - nfactor++; - } - - combine: - /* Combine entries in the factor array. Combine the smallest entry with - the biggest one that will fit with it (ie. under max_divisor), then - repeat that with the new smallest entry. */ - qsort (factor, nfactor, sizeof (factor[0]), f_cmp_divisor); - for (i = nfactor-1; i >= 1; i--) - { - if (factor[i].divisor <= max_divisor / factor[0].divisor) - { - factor[0].divisor *= factor[i].divisor; - COLLAPSE_ELEMENT (factor, i, nfactor); - goto combine; - } - } - - total_fraction = 1.0; - for (i = 0; i < nfactor; i++) - { - mpz_init (factor[i].inverse); - mpz_invert_ui_2exp (factor[i].inverse, - (unsigned long) factor[i].divisor, - (unsigned long) mod_bits); - - mpz_init (factor[i].mask); - square_mask (factor[i].mask, factor[i].divisor); - - /* fraction of possible squares */ - factor[i].fraction = (double) mpz_popcount (factor[i].mask) - / factor[i].divisor; - - /* total fraction of possible squares */ - total_fraction *= factor[i].fraction; - } - - /* best tests first (ie. smallest fraction) */ - qsort (factor, nfactor, sizeof (factor[0]), f_cmp_fraction); -} - -void -print (int limb_bits, int nail_bits) -{ - int i; - mpz_t mhi, mlo; - - printf ("/* This file generated by gen-psqr.c - DO NOT EDIT. */\n"); - printf ("\n"); - - printf ("#if GMP_LIMB_BITS != %d || GMP_NAIL_BITS != %d\n", - limb_bits, nail_bits); - printf ("Error, error, this data is for %d bit limb and %d bit nail\n", - limb_bits, nail_bits); - printf ("#endif\n"); - printf ("\n"); - - printf ("/* Non-zero bit indicates a quadratic residue mod 0x100.\n"); - printf (" This test identifies %.2f%% as non-squares (%d/256). */\n", - (1.0 - sq_res_0x100_fraction) * 100.0, - 0x100 - sq_res_0x100_num); - printf ("static const mp_limb_t\n"); - printf ("sq_res_0x100[%d] = {\n", nsq_res_0x100); - for (i = 0; i < nsq_res_0x100; i++) - { - printf (" CNST_LIMB(0x"); - mpz_out_str (stdout, 16, sq_res_0x100[i]); - printf ("),\n"); - } - printf ("};\n"); - printf ("\n"); - - if (mpz_sgn (pp) != 0) - { - printf ("/* mpn_mod_34lsub1 not used due to %s */\n", mod34_excuse); - printf ("/* PERFSQR_PP = "); - } - else - printf ("/* 2^%d-1 = ", mod34_bits); - for (i = 0; i < nrawfactor; i++) - { - if (i != 0) - printf (" * "); - printf ("%d", rawfactor[i].divisor); - if (rawfactor[i].multiplicity != 1) - printf ("^%d", rawfactor[i].multiplicity); - } - printf (" %s*/\n", mpz_sgn (pp) == 0 ? "... " : ""); - - printf ("#define PERFSQR_MOD_BITS %d\n", mod_bits); - if (mpz_sgn (pp) != 0) - { - printf ("#define PERFSQR_PP CNST_LIMB(0x"); - mpz_out_str (stdout, 16, pp); - printf (")\n"); - printf ("#define PERFSQR_PP_NORM CNST_LIMB(0x"); - mpz_out_str (stdout, 16, pp_norm); - printf (")\n"); - printf ("#define PERFSQR_PP_INVERTED CNST_LIMB(0x"); - mpz_out_str (stdout, 16, pp_inverted); - printf (")\n"); - } - printf ("\n"); - - mpz_init (mhi); - mpz_init (mlo); - - printf ("/* This test identifies %.2f%% as non-squares. */\n", - (1.0 - total_fraction) * 100.0); - printf ("#define PERFSQR_MOD_TEST(up, usize) \\\n"); - printf (" do { \\\n"); - printf (" mp_limb_t r; \\\n"); - if (mpz_sgn (pp) != 0) - printf (" PERFSQR_MOD_PP (r, up, usize); \\\n"); - else - printf (" PERFSQR_MOD_34 (r, up, usize); \\\n"); - - for (i = 0; i < nfactor; i++) - { - printf (" \\\n"); - printf (" /* %5.2f%% */ \\\n", - (1.0 - factor[i].fraction) * 100.0); - - printf (" PERFSQR_MOD_%d (r, CNST_LIMB(%2d), CNST_LIMB(0x", - factor[i].divisor <= limb_bits ? 1 : 2, - factor[i].divisor); - mpz_out_str (stdout, 16, factor[i].inverse); - printf ("), \\\n"); - printf (" CNST_LIMB(0x"); - - if ( factor[i].divisor <= limb_bits) - { - mpz_out_str (stdout, 16, factor[i].mask); - } - else - { - mpz_tdiv_r_2exp (mlo, factor[i].mask, (unsigned long) limb_bits); - mpz_tdiv_q_2exp (mhi, factor[i].mask, (unsigned long) limb_bits); - mpz_out_str (stdout, 16, mhi); - printf ("), CNST_LIMB(0x"); - mpz_out_str (stdout, 16, mlo); - } - printf (")); \\\n"); - } - - printf (" } while (0)\n"); - printf ("\n"); - - printf ("/* Grand total sq_res_0x100 and PERFSQR_MOD_TEST, %.2f%% non-squares. */\n", - (1.0 - (total_fraction * 44.0/256.0)) * 100.0); - printf ("\n"); - - printf ("/* helper for tests/mpz/t-perfsqr.c */\n"); - printf ("#define PERFSQR_DIVISORS { 256,"); - for (i = 0; i < nfactor; i++) - printf (" %d,", factor[i].divisor); - printf (" }\n"); - - - mpz_clear (mhi); - mpz_clear (mlo); -} - -int -main (int argc, char *argv[]) -{ - int limb_bits, nail_bits; - - if (argc != 3) - { - fprintf (stderr, "Usage: gen-psqr \n"); - exit (1); - } - - limb_bits = atoi (argv[1]); - nail_bits = atoi (argv[2]); - - if (limb_bits <= 0 - || nail_bits < 0 - || nail_bits >= limb_bits) - { - fprintf (stderr, "Invalid limb/nail bits: %d %d\n", - limb_bits, nail_bits); - exit (1); - } - - generate_sq_res_0x100 (limb_bits); - generate_mod (limb_bits, nail_bits); - - print (limb_bits, nail_bits); - - return 0; -} diff --git a/mp_bases.h b/mp_bases.h new file mode 100644 index 00000000..f280122c --- /dev/null +++ b/mp_bases.h @@ -0,0 +1,17 @@ +/* This file generated by gen-bases.c - DO NOT EDIT. */ + +#if GMP_NUMB_BITS == 32 +/* mp_bases[10] data, as literal values */ +#define MP_BASES_CHARS_PER_LIMB_10 9 +#define MP_BASES_BIG_BASE_10 CNST_LIMB(0x3b9aca00) +#define MP_BASES_BIG_BASE_INVERTED_10 CNST_LIMB(0x12e0be82) +#define MP_BASES_NORMALIZATION_STEPS_10 2 +#endif /* 32bit */ + +#if GMP_NUMB_BITS == 64 +/* mp_bases[10] data, as literal values */ +#define MP_BASES_CHARS_PER_LIMB_10 19 +#define MP_BASES_BIG_BASE_10 CNST_LIMB(0x8ac7230489e80000) +#define MP_BASES_BIG_BASE_INVERTED_10 CNST_LIMB(0xd83c94fb6d2ac34a) +#define MP_BASES_NORMALIZATION_STEPS_10 0 +#endif /* 64bit */ diff --git a/mpn/fib_table.c b/mpn/fib_table.c new file mode 100644 index 00000000..b59ecc4d --- /dev/null +++ b/mpn/fib_table.c @@ -0,0 +1,160 @@ +/* This file generated by gen-fib.c - DO NOT EDIT. */ + +#include "mpir.h" +#include "gmp-impl.h" + +#if GMP_NUMB_BITS == 32 +const mp_limb_t +__gmp_fib_table[FIB_TABLE_LIMIT+2] = { + CNST_LIMB (0x1), /* -1 */ + CNST_LIMB (0x0), /* 0 */ + CNST_LIMB (0x1), /* 1 */ + CNST_LIMB (0x1), /* 2 */ + CNST_LIMB (0x2), /* 3 */ + CNST_LIMB (0x3), /* 4 */ + CNST_LIMB (0x5), /* 5 */ + CNST_LIMB (0x8), /* 6 */ + CNST_LIMB (0xd), /* 7 */ + CNST_LIMB (0x15), /* 8 */ + CNST_LIMB (0x22), /* 9 */ + CNST_LIMB (0x37), /* 10 */ + CNST_LIMB (0x59), /* 11 */ + CNST_LIMB (0x90), /* 12 */ + CNST_LIMB (0xe9), /* 13 */ + CNST_LIMB (0x179), /* 14 */ + CNST_LIMB (0x262), /* 15 */ + CNST_LIMB (0x3db), /* 16 */ + CNST_LIMB (0x63d), /* 17 */ + CNST_LIMB (0xa18), /* 18 */ + CNST_LIMB (0x1055), /* 19 */ + CNST_LIMB (0x1a6d), /* 20 */ + CNST_LIMB (0x2ac2), /* 21 */ + CNST_LIMB (0x452f), /* 22 */ + CNST_LIMB (0x6ff1), /* 23 */ + CNST_LIMB (0xb520), /* 24 */ + CNST_LIMB (0x12511), /* 25 */ + CNST_LIMB (0x1da31), /* 26 */ + CNST_LIMB (0x2ff42), /* 27 */ + CNST_LIMB (0x4d973), /* 28 */ + CNST_LIMB (0x7d8b5), /* 29 */ + CNST_LIMB (0xcb228), /* 30 */ + CNST_LIMB (0x148add), /* 31 */ + CNST_LIMB (0x213d05), /* 32 */ + CNST_LIMB (0x35c7e2), /* 33 */ + CNST_LIMB (0x5704e7), /* 34 */ + CNST_LIMB (0x8cccc9), /* 35 */ + CNST_LIMB (0xe3d1b0), /* 36 */ + CNST_LIMB (0x1709e79), /* 37 */ + CNST_LIMB (0x2547029), /* 38 */ + CNST_LIMB (0x3c50ea2), /* 39 */ + CNST_LIMB (0x6197ecb), /* 40 */ + CNST_LIMB (0x9de8d6d), /* 41 */ + CNST_LIMB (0xff80c38), /* 42 */ + CNST_LIMB (0x19d699a5), /* 43 */ + CNST_LIMB (0x29cea5dd), /* 44 */ + CNST_LIMB (0x43a53f82), /* 45 */ + CNST_LIMB (0x6d73e55f), /* 46 */ + CNST_LIMB (0xb11924e1), /* 47 */ +}; +#endif /* 32bit */ + +#if GMP_NUMB_BITS == 64 +const mp_limb_t +__gmp_fib_table[FIB_TABLE_LIMIT+2] = { + CNST_LIMB (0x1), /* -1 */ + CNST_LIMB (0x0), /* 0 */ + CNST_LIMB (0x1), /* 1 */ + CNST_LIMB (0x1), /* 2 */ + CNST_LIMB (0x2), /* 3 */ + CNST_LIMB (0x3), /* 4 */ + CNST_LIMB (0x5), /* 5 */ + CNST_LIMB (0x8), /* 6 */ + CNST_LIMB (0xd), /* 7 */ + CNST_LIMB (0x15), /* 8 */ + CNST_LIMB (0x22), /* 9 */ + CNST_LIMB (0x37), /* 10 */ + CNST_LIMB (0x59), /* 11 */ + CNST_LIMB (0x90), /* 12 */ + CNST_LIMB (0xe9), /* 13 */ + CNST_LIMB (0x179), /* 14 */ + CNST_LIMB (0x262), /* 15 */ + CNST_LIMB (0x3db), /* 16 */ + CNST_LIMB (0x63d), /* 17 */ + CNST_LIMB (0xa18), /* 18 */ + CNST_LIMB (0x1055), /* 19 */ + CNST_LIMB (0x1a6d), /* 20 */ + CNST_LIMB (0x2ac2), /* 21 */ + CNST_LIMB (0x452f), /* 22 */ + CNST_LIMB (0x6ff1), /* 23 */ + CNST_LIMB (0xb520), /* 24 */ + CNST_LIMB (0x12511), /* 25 */ + CNST_LIMB (0x1da31), /* 26 */ + CNST_LIMB (0x2ff42), /* 27 */ + CNST_LIMB (0x4d973), /* 28 */ + CNST_LIMB (0x7d8b5), /* 29 */ + CNST_LIMB (0xcb228), /* 30 */ + CNST_LIMB (0x148add), /* 31 */ + CNST_LIMB (0x213d05), /* 32 */ + CNST_LIMB (0x35c7e2), /* 33 */ + CNST_LIMB (0x5704e7), /* 34 */ + CNST_LIMB (0x8cccc9), /* 35 */ + CNST_LIMB (0xe3d1b0), /* 36 */ + CNST_LIMB (0x1709e79), /* 37 */ + CNST_LIMB (0x2547029), /* 38 */ + CNST_LIMB (0x3c50ea2), /* 39 */ + CNST_LIMB (0x6197ecb), /* 40 */ + CNST_LIMB (0x9de8d6d), /* 41 */ + CNST_LIMB (0xff80c38), /* 42 */ + CNST_LIMB (0x19d699a5), /* 43 */ + CNST_LIMB (0x29cea5dd), /* 44 */ + CNST_LIMB (0x43a53f82), /* 45 */ + CNST_LIMB (0x6d73e55f), /* 46 */ + CNST_LIMB (0xb11924e1), /* 47 */ + CNST_LIMB (0x11e8d0a40), /* 48 */ + CNST_LIMB (0x1cfa62f21), /* 49 */ + CNST_LIMB (0x2ee333961), /* 50 */ + CNST_LIMB (0x4bdd96882), /* 51 */ + CNST_LIMB (0x7ac0ca1e3), /* 52 */ + CNST_LIMB (0xc69e60a65), /* 53 */ + CNST_LIMB (0x1415f2ac48), /* 54 */ + CNST_LIMB (0x207fd8b6ad), /* 55 */ + CNST_LIMB (0x3495cb62f5), /* 56 */ + CNST_LIMB (0x5515a419a2), /* 57 */ + CNST_LIMB (0x89ab6f7c97), /* 58 */ + CNST_LIMB (0xdec1139639), /* 59 */ + CNST_LIMB (0x1686c8312d0), /* 60 */ + CNST_LIMB (0x2472d96a909), /* 61 */ + CNST_LIMB (0x3af9a19bbd9), /* 62 */ + CNST_LIMB (0x5f6c7b064e2), /* 63 */ + CNST_LIMB (0x9a661ca20bb), /* 64 */ + CNST_LIMB (0xf9d297a859d), /* 65 */ + CNST_LIMB (0x19438b44a658), /* 66 */ + CNST_LIMB (0x28e0b4bf2bf5), /* 67 */ + CNST_LIMB (0x42244003d24d), /* 68 */ + CNST_LIMB (0x6b04f4c2fe42), /* 69 */ + CNST_LIMB (0xad2934c6d08f), /* 70 */ + CNST_LIMB (0x1182e2989ced1), /* 71 */ + CNST_LIMB (0x1c5575e509f60), /* 72 */ + CNST_LIMB (0x2dd8587da6e31), /* 73 */ + CNST_LIMB (0x4a2dce62b0d91), /* 74 */ + CNST_LIMB (0x780626e057bc2), /* 75 */ + CNST_LIMB (0xc233f54308953), /* 76 */ + CNST_LIMB (0x13a3a1c2360515), /* 77 */ + CNST_LIMB (0x1fc6e116668e68), /* 78 */ + CNST_LIMB (0x336a82d89c937d), /* 79 */ + CNST_LIMB (0x533163ef0321e5), /* 80 */ + CNST_LIMB (0x869be6c79fb562), /* 81 */ + CNST_LIMB (0xd9cd4ab6a2d747), /* 82 */ + CNST_LIMB (0x16069317e428ca9), /* 83 */ + CNST_LIMB (0x23a367c34e563f0), /* 84 */ + CNST_LIMB (0x39a9fadb327f099), /* 85 */ + CNST_LIMB (0x5d4d629e80d5489), /* 86 */ + CNST_LIMB (0x96f75d79b354522), /* 87 */ + CNST_LIMB (0xf444c01834299ab), /* 88 */ + CNST_LIMB (0x18b3c1d91e77decd), /* 89 */ + CNST_LIMB (0x27f80ddaa1ba7878), /* 90 */ + CNST_LIMB (0x40abcfb3c0325745), /* 91 */ + CNST_LIMB (0x68a3dd8e61eccfbd), /* 92 */ + CNST_LIMB (0xa94fad42221f2702), /* 93 */ +}; +#endif /* 64bit */ diff --git a/mpn/mp_bases.c b/mpn/mp_bases.c new file mode 100644 index 00000000..7fc3ac23 --- /dev/null +++ b/mpn/mp_bases.c @@ -0,0 +1,530 @@ +/* This file generated by gen-bases.c - DO NOT EDIT. */ + +#include "mpir.h" +#include "gmp-impl.h" + +#if GMP_NUMB_BITS == 32 +const struct bases mp_bases[257] = +{ + /* 0 */ { 0, 0.0, 0 }, + /* 1 */ { 0, 1e37, 0 }, + /* 2 */ { 32, 1.0000000000000000, 0x1 }, + /* 3 */ { 20, 0.6309297535714574, CNST_LIMB(0xcfd41b91), CNST_LIMB(0x3b563c24) }, + /* 4 */ { 16, 0.5000000000000000, 0x2 }, + /* 5 */ { 13, 0.4306765580733931, CNST_LIMB(0x48c27395), CNST_LIMB(0xc25c2684) }, + /* 6 */ { 12, 0.3868528072345416, CNST_LIMB(0x81bf1000), CNST_LIMB(0xf91bd1b6) }, + /* 7 */ { 11, 0.3562071871080222, CNST_LIMB(0x75db9c97), CNST_LIMB(0x1607a2cb) }, + /* 8 */ { 10, 0.3333333333333334, 0x3 }, + /* 9 */ { 10, 0.3154648767857287, CNST_LIMB(0xcfd41b91), CNST_LIMB(0x3b563c24) }, + /* 10 */ { 9, 0.3010299956639811, CNST_LIMB(0x3b9aca00), CNST_LIMB(0x12e0be82) }, + /* 11 */ { 9, 0.2890648263178878, CNST_LIMB(0x8c8b6d2b), CNST_LIMB(0xd24cde04) }, + /* 12 */ { 8, 0.2789429456511298, CNST_LIMB(0x19a10000), CNST_LIMB(0x3fa39ab5) }, + /* 13 */ { 8, 0.2702381544273197, CNST_LIMB(0x309f1021), CNST_LIMB(0x50f8ac5f) }, + /* 14 */ { 8, 0.2626495350371936, CNST_LIMB(0x57f6c100), CNST_LIMB(0x74843b1e) }, + /* 15 */ { 8, 0.2559580248098155, CNST_LIMB(0x98c29b81), CNST_LIMB(0xad0326c2) }, + /* 16 */ { 8, 0.2500000000000000, 0x4 }, + /* 17 */ { 7, 0.2446505421182260, CNST_LIMB(0x18754571), CNST_LIMB(0x4ef0b6bd) }, + /* 18 */ { 7, 0.2398124665681315, CNST_LIMB(0x247dbc80), CNST_LIMB(0xc0fc48a1) }, + /* 19 */ { 7, 0.2354089133666382, CNST_LIMB(0x3547667b), CNST_LIMB(0x33838942) }, + /* 20 */ { 7, 0.2313782131597592, CNST_LIMB(0x4c4b4000), CNST_LIMB(0xad7f29ab) }, + /* 21 */ { 7, 0.2276702486969530, CNST_LIMB(0x6b5a6e1d), CNST_LIMB(0x313c3d15) }, + /* 22 */ { 7, 0.2242438242175754, CNST_LIMB(0x94ace180), CNST_LIMB(0xb8cca9e0) }, + /* 23 */ { 7, 0.2210647294575037, CNST_LIMB(0xcaf18367), CNST_LIMB(0x42ed6de9) }, + /* 24 */ { 6, 0.2181042919855316, CNST_LIMB(0xb640000), CNST_LIMB(0x67980e0b) }, + /* 25 */ { 6, 0.2153382790366965, CNST_LIMB(0xe8d4a51), CNST_LIMB(0x19799812) }, + /* 26 */ { 6, 0.2127460535533632, CNST_LIMB(0x1269ae40), CNST_LIMB(0xbce85396) }, + /* 27 */ { 6, 0.2103099178571525, CNST_LIMB(0x17179149), CNST_LIMB(0x62c103a9) }, + /* 28 */ { 6, 0.2080145976765095, CNST_LIMB(0x1cb91000), CNST_LIMB(0x1d353d43) }, + /* 29 */ { 6, 0.2058468324604344, CNST_LIMB(0x23744899), CNST_LIMB(0xce1decea) }, + /* 30 */ { 6, 0.2037950470905062, CNST_LIMB(0x2b73a840), CNST_LIMB(0x790fc511) }, + /* 31 */ { 6, 0.2018490865820999, CNST_LIMB(0x34e63b41), CNST_LIMB(0x35b865a0) }, + /* 32 */ { 6, 0.2000000000000000, 0x5 }, + /* 33 */ { 6, 0.1982398631705605, CNST_LIMB(0x4cfa3cc1), CNST_LIMB(0xa9aed1b3) }, + /* 34 */ { 6, 0.1965616322328226, CNST_LIMB(0x5c13d840), CNST_LIMB(0x63dfc229) }, + /* 35 */ { 6, 0.1949590218937863, CNST_LIMB(0x6d91b519), CNST_LIMB(0x2b0fee30) }, + /* 36 */ { 6, 0.1934264036172708, CNST_LIMB(0x81bf1000), CNST_LIMB(0xf91bd1b6) }, + /* 37 */ { 6, 0.1919587200065601, CNST_LIMB(0x98ede0c9), CNST_LIMB(0xac89c3a9) }, + /* 38 */ { 6, 0.1905514124267734, CNST_LIMB(0xb3773e40), CNST_LIMB(0x6d2c32fe) }, + /* 39 */ { 6, 0.1892003595168700, CNST_LIMB(0xd1bbc4d1), CNST_LIMB(0x387907c9) }, + /* 40 */ { 6, 0.1879018247091076, CNST_LIMB(0xf4240000), CNST_LIMB(0xc6f7a0b) }, + /* 41 */ { 5, 0.1866524112389434, CNST_LIMB(0x6e7d349), CNST_LIMB(0x28928154) }, + /* 42 */ { 5, 0.1854490234153689, CNST_LIMB(0x7ca30a0), CNST_LIMB(0x6e8629d) }, + /* 43 */ { 5, 0.1842888331487062, CNST_LIMB(0x8c32bbb), CNST_LIMB(0xd373dca0) }, + /* 44 */ { 5, 0.1831692509136336, CNST_LIMB(0x9d46c00), CNST_LIMB(0xa0b17895) }, + /* 45 */ { 5, 0.1820879004699383, CNST_LIMB(0xaffacfd), CNST_LIMB(0x746811a5) }, + /* 46 */ { 5, 0.1810425967800402, CNST_LIMB(0xc46bee0), CNST_LIMB(0x4da6500f) }, + /* 47 */ { 5, 0.1800313266566926, CNST_LIMB(0xdab86ef), CNST_LIMB(0x2ba23582) }, + /* 48 */ { 5, 0.1790522317510413, CNST_LIMB(0xf300000), CNST_LIMB(0xdb20a88) }, + /* 49 */ { 5, 0.1781035935540111, CNST_LIMB(0x10d63af1), CNST_LIMB(0xe68d5ce4) }, + /* 50 */ { 5, 0.1771838201355579, CNST_LIMB(0x12a05f20), CNST_LIMB(0xb7cdfd9d) }, + /* 51 */ { 5, 0.1762914343888821, CNST_LIMB(0x1490aae3), CNST_LIMB(0x8e583933) }, + /* 52 */ { 5, 0.1754250635819545, CNST_LIMB(0x16a97400), CNST_LIMB(0x697cc3ea) }, + /* 53 */ { 5, 0.1745834300480449, CNST_LIMB(0x18ed2825), CNST_LIMB(0x48a5ca6c) }, + /* 54 */ { 5, 0.1737653428714400, CNST_LIMB(0x1b5e4d60), CNST_LIMB(0x2b52db16) }, + /* 55 */ { 5, 0.1729696904450771, CNST_LIMB(0x1dff8297), CNST_LIMB(0x111586a6) }, + /* 56 */ { 5, 0.1721954337940981, CNST_LIMB(0x20d38000), CNST_LIMB(0xf31d2b36) }, + /* 57 */ { 5, 0.1714416005739134, CNST_LIMB(0x23dd1799), CNST_LIMB(0xc8d76d19) }, + /* 58 */ { 5, 0.1707072796637201, CNST_LIMB(0x271f35a0), CNST_LIMB(0xa2cb1eb4) }, + /* 59 */ { 5, 0.1699916162869140, CNST_LIMB(0x2a9ce10b), CNST_LIMB(0x807c3ec3) }, + /* 60 */ { 5, 0.1692938075987814, CNST_LIMB(0x2e593c00), CNST_LIMB(0x617ec8bf) }, + /* 61 */ { 5, 0.1686130986895011, CNST_LIMB(0x3257844d), CNST_LIMB(0x45746cbe) }, + /* 62 */ { 5, 0.1679487789570419, CNST_LIMB(0x369b13e0), CNST_LIMB(0x2c0aa273) }, + /* 63 */ { 5, 0.1673001788101741, CNST_LIMB(0x3b27613f), CNST_LIMB(0x14f90805) }, + /* 64 */ { 5, 0.1666666666666667, 0x6 }, + /* 65 */ { 5, 0.1660476462159378, CNST_LIMB(0x4528a141), CNST_LIMB(0xd9cf0829) }, + /* 66 */ { 5, 0.1654425539190583, CNST_LIMB(0x4aa51420), CNST_LIMB(0xb6fc4841) }, + /* 67 */ { 5, 0.1648508567221604, CNST_LIMB(0x50794633), CNST_LIMB(0x973054cb) }, + /* 68 */ { 5, 0.1642720499620502, CNST_LIMB(0x56a94400), CNST_LIMB(0x7a1dbe4b) }, + /* 69 */ { 5, 0.1637056554452156, CNST_LIMB(0x5d393975), CNST_LIMB(0x5f7fcd7f) }, + /* 70 */ { 5, 0.1631512196835108, CNST_LIMB(0x642d7260), CNST_LIMB(0x47196c84) }, + /* 71 */ { 5, 0.1626083122716341, CNST_LIMB(0x6b8a5ae7), CNST_LIMB(0x30b43635) }, + /* 72 */ { 5, 0.1620765243931223, CNST_LIMB(0x73548000), CNST_LIMB(0x1c1fa5f6) }, + /* 73 */ { 5, 0.1615554674429964, CNST_LIMB(0x7b908fe9), CNST_LIMB(0x930634a) }, + /* 74 */ { 5, 0.1610447717564444, CNST_LIMB(0x84435aa0), CNST_LIMB(0xef7f4a3c) }, + /* 75 */ { 5, 0.1605440854340214, CNST_LIMB(0x8d71d25b), CNST_LIMB(0xcf5552d2) }, + /* 76 */ { 5, 0.1600530732548213, CNST_LIMB(0x97210c00), CNST_LIMB(0xb1a47c8e) }, + /* 77 */ { 5, 0.1595714156699382, CNST_LIMB(0xa1563f9d), CNST_LIMB(0x9634b43e) }, + /* 78 */ { 5, 0.1590988078692941, CNST_LIMB(0xac16c8e0), CNST_LIMB(0x7cd3817d) }, + /* 79 */ { 5, 0.1586349589155960, CNST_LIMB(0xb768278f), CNST_LIMB(0x65536761) }, + /* 80 */ { 5, 0.1581795909397823, CNST_LIMB(0xc3500000), CNST_LIMB(0x4f8b588e) }, + /* 81 */ { 5, 0.1577324383928644, CNST_LIMB(0xcfd41b91), CNST_LIMB(0x3b563c24) }, + /* 82 */ { 5, 0.1572932473495469, CNST_LIMB(0xdcfa6920), CNST_LIMB(0x28928154) }, + /* 83 */ { 5, 0.1568617748594410, CNST_LIMB(0xeac8fd83), CNST_LIMB(0x1721bfb0) }, + /* 84 */ { 5, 0.1564377883420716, CNST_LIMB(0xf9461400), CNST_LIMB(0x6e8629d) }, + /* 85 */ { 4, 0.1560210650222250, CNST_LIMB(0x31c84b1), CNST_LIMB(0x491cc17c) }, + /* 86 */ { 4, 0.1556113914024940, CNST_LIMB(0x342ab10), CNST_LIMB(0x3a11d83b) }, + /* 87 */ { 4, 0.1552085627701551, CNST_LIMB(0x36a2c21), CNST_LIMB(0x2be074cd) }, + /* 88 */ { 4, 0.1548123827357682, CNST_LIMB(0x3931000), CNST_LIMB(0x1e7a02e7) }, + /* 89 */ { 4, 0.1544226628011101, CNST_LIMB(0x3bd5ee1), CNST_LIMB(0x11d10edd) }, + /* 90 */ { 4, 0.1540392219542636, CNST_LIMB(0x3e92110), CNST_LIMB(0x5d92c68) }, + /* 91 */ { 4, 0.1536618862898642, CNST_LIMB(0x4165ef1), CNST_LIMB(0xf50dbfb2) }, + /* 92 */ { 4, 0.1532904886526781, CNST_LIMB(0x4452100), CNST_LIMB(0xdf9f1316) }, + /* 93 */ { 4, 0.1529248683028321, CNST_LIMB(0x4756fd1), CNST_LIMB(0xcb52a684) }, + /* 94 */ { 4, 0.1525648706011593, CNST_LIMB(0x4a75410), CNST_LIMB(0xb8163e97) }, + /* 95 */ { 4, 0.1522103467132434, CNST_LIMB(0x4dad681), CNST_LIMB(0xa5d8f269) }, + /* 96 */ { 4, 0.1518611533308632, CNST_LIMB(0x5100000), CNST_LIMB(0x948b0fcd) }, + /* 97 */ { 4, 0.1515171524096389, CNST_LIMB(0x546d981), CNST_LIMB(0x841e0215) }, + /* 98 */ { 4, 0.1511782109217764, CNST_LIMB(0x57f6c10), CNST_LIMB(0x74843b1e) }, + /* 99 */ { 4, 0.1508442006228941, CNST_LIMB(0x5b9c0d1), CNST_LIMB(0x65b11e6e) }, + /* 100 */ { 4, 0.1505149978319906, CNST_LIMB(0x5f5e100), CNST_LIMB(0x5798ee23) }, + /* 101 */ { 4, 0.1501904832236879, CNST_LIMB(0x633d5f1), CNST_LIMB(0x4a30b99b) }, + /* 102 */ { 4, 0.1498705416319474, CNST_LIMB(0x673a910), CNST_LIMB(0x3d6e4d94) }, + /* 103 */ { 4, 0.1495550618645152, CNST_LIMB(0x6b563e1), CNST_LIMB(0x314825b0) }, + /* 104 */ { 4, 0.1492439365274121, CNST_LIMB(0x6f91000), CNST_LIMB(0x25b55f2e) }, + /* 105 */ { 4, 0.1489370618588283, CNST_LIMB(0x73eb721), CNST_LIMB(0x1aadaccb) }, + /* 106 */ { 4, 0.1486343375718350, CNST_LIMB(0x7866310), CNST_LIMB(0x10294ba2) }, + /* 107 */ { 4, 0.1483356667053617, CNST_LIMB(0x7d01db1), CNST_LIMB(0x620f8f6) }, + /* 108 */ { 4, 0.1480409554829326, CNST_LIMB(0x81bf100), CNST_LIMB(0xf91bd1b6) }, + /* 109 */ { 4, 0.1477501131786861, CNST_LIMB(0x869e711), CNST_LIMB(0xe6d37b2a) }, + /* 110 */ { 4, 0.1474630519902391, CNST_LIMB(0x8ba0a10), CNST_LIMB(0xd55cff6e) }, + /* 111 */ { 4, 0.1471796869179852, CNST_LIMB(0x90c6441), CNST_LIMB(0xc4ad2db2) }, + /* 112 */ { 4, 0.1468999356504447, CNST_LIMB(0x9610000), CNST_LIMB(0xb4b985cf) }, + /* 113 */ { 4, 0.1466237184553111, CNST_LIMB(0x9b7e7c1), CNST_LIMB(0xa5782bef) }, + /* 114 */ { 4, 0.1463509580758620, CNST_LIMB(0xa112610), CNST_LIMB(0x96dfdd2a) }, + /* 115 */ { 4, 0.1460815796324244, CNST_LIMB(0xa6cc591), CNST_LIMB(0x88e7e509) }, + /* 116 */ { 4, 0.1458155105286054, CNST_LIMB(0xacad100), CNST_LIMB(0x7b8813d3) }, + /* 117 */ { 4, 0.1455526803620167, CNST_LIMB(0xb2b5331), CNST_LIMB(0x6eb8b595) }, + /* 118 */ { 4, 0.1452930208392428, CNST_LIMB(0xb8e5710), CNST_LIMB(0x627289db) }, + /* 119 */ { 4, 0.1450364656948130, CNST_LIMB(0xbf3e7a1), CNST_LIMB(0x56aebc07) }, + /* 120 */ { 4, 0.1447829506139581, CNST_LIMB(0xc5c1000), CNST_LIMB(0x4b66dc33) }, + /* 121 */ { 4, 0.1445324131589439, CNST_LIMB(0xcc6db61), CNST_LIMB(0x4094d8a3) }, + /* 122 */ { 4, 0.1442847926987864, CNST_LIMB(0xd345510), CNST_LIMB(0x3632f7a5) }, + /* 123 */ { 4, 0.1440400303421672, CNST_LIMB(0xda48871), CNST_LIMB(0x2c3bd1f0) }, + /* 124 */ { 4, 0.1437980688733775, CNST_LIMB(0xe178100), CNST_LIMB(0x22aa4d5f) }, + /* 125 */ { 4, 0.1435588526911310, CNST_LIMB(0xe8d4a51), CNST_LIMB(0x19799812) }, + /* 126 */ { 4, 0.1433223277500932, CNST_LIMB(0xf05f010), CNST_LIMB(0x10a523e5) }, + /* 127 */ { 4, 0.1430884415049874, CNST_LIMB(0xf817e01), CNST_LIMB(0x828a237) }, + /* 128 */ { 4, 0.1428571428571428, 0x7 }, + /* 129 */ { 4, 0.1426283821033600, CNST_LIMB(0x10818201), CNST_LIMB(0xf04ec452) }, + /* 130 */ { 4, 0.1424021108869747, CNST_LIMB(0x11061010), CNST_LIMB(0xe136444a) }, + /* 131 */ { 4, 0.1421782821510107, CNST_LIMB(0x118db651), CNST_LIMB(0xd2af9589) }, + /* 132 */ { 4, 0.1419568500933153, CNST_LIMB(0x12188100), CNST_LIMB(0xc4b42a83) }, + /* 133 */ { 4, 0.1417377701235801, CNST_LIMB(0x12a67c71), CNST_LIMB(0xb73dccf5) }, + /* 134 */ { 4, 0.1415209988221527, CNST_LIMB(0x1337b510), CNST_LIMB(0xaa4698c5) }, + /* 135 */ { 4, 0.1413064939005528, CNST_LIMB(0x13cc3761), CNST_LIMB(0x9dc8f729) }, + /* 136 */ { 4, 0.1410942141636095, CNST_LIMB(0x14641000), CNST_LIMB(0x91bf9a30) }, + /* 137 */ { 4, 0.1408841194731412, CNST_LIMB(0x14ff4ba1), CNST_LIMB(0x86257887) }, + /* 138 */ { 4, 0.1406761707131039, CNST_LIMB(0x159df710), CNST_LIMB(0x7af5c98c) }, + /* 139 */ { 4, 0.1404703297561400, CNST_LIMB(0x16401f31), CNST_LIMB(0x702c01a0) }, + /* 140 */ { 4, 0.1402665594314587, CNST_LIMB(0x16e5d100), CNST_LIMB(0x65c3ceb1) }, + /* 141 */ { 4, 0.1400648234939879, CNST_LIMB(0x178f1991), CNST_LIMB(0x5bb91502) }, + /* 142 */ { 4, 0.1398650865947379, CNST_LIMB(0x183c0610), CNST_LIMB(0x5207ec23) }, + /* 143 */ { 4, 0.1396673142523192, CNST_LIMB(0x18eca3c1), CNST_LIMB(0x48ac9c19) }, + /* 144 */ { 4, 0.1394714728255649, CNST_LIMB(0x19a10000), CNST_LIMB(0x3fa39ab5) }, + /* 145 */ { 4, 0.1392775294872041, CNST_LIMB(0x1a592841), CNST_LIMB(0x36e98912) }, + /* 146 */ { 4, 0.1390854521985406, CNST_LIMB(0x1b152a10), CNST_LIMB(0x2e7b3140) }, + /* 147 */ { 4, 0.1388952096850913, CNST_LIMB(0x1bd51311), CNST_LIMB(0x2655840b) }, + /* 148 */ { 4, 0.1387067714131417, CNST_LIMB(0x1c98f100), CNST_LIMB(0x1e7596ea) }, + /* 149 */ { 4, 0.1385201075671774, CNST_LIMB(0x1d60d1b1), CNST_LIMB(0x16d8a20d) }, + /* 150 */ { 4, 0.1383351890281539, CNST_LIMB(0x1e2cc310), CNST_LIMB(0xf7bfe87) }, + /* 151 */ { 4, 0.1381519873525671, CNST_LIMB(0x1efcd321), CNST_LIMB(0x85d2492) }, + /* 152 */ { 4, 0.1379704747522905, CNST_LIMB(0x1fd11000), CNST_LIMB(0x179a9f4) }, + /* 153 */ { 4, 0.1377906240751463, CNST_LIMB(0x20a987e1), CNST_LIMB(0xf59e80eb) }, + /* 154 */ { 4, 0.1376124087861776, CNST_LIMB(0x21864910), CNST_LIMB(0xe8b768db) }, + /* 155 */ { 4, 0.1374358029495937, CNST_LIMB(0x226761f1), CNST_LIMB(0xdc39d6d5) }, + /* 156 */ { 4, 0.1372607812113589, CNST_LIMB(0x234ce100), CNST_LIMB(0xd021c5d1) }, + /* 157 */ { 4, 0.1370873187823978, CNST_LIMB(0x2436d4d1), CNST_LIMB(0xc46b5e37) }, + /* 158 */ { 4, 0.1369153914223921, CNST_LIMB(0x25254c10), CNST_LIMB(0xb912f39c) }, + /* 159 */ { 4, 0.1367449754241439, CNST_LIMB(0x26185581), CNST_LIMB(0xae150294) }, + /* 160 */ { 4, 0.1365760475984821, CNST_LIMB(0x27100000), CNST_LIMB(0xa36e2eb1) }, + /* 161 */ { 4, 0.1364085852596902, CNST_LIMB(0x280c5a81), CNST_LIMB(0x991b4094) }, + /* 162 */ { 4, 0.1362425662114337, CNST_LIMB(0x290d7410), CNST_LIMB(0x8f19241e) }, + /* 163 */ { 4, 0.1360779687331669, CNST_LIMB(0x2a135bd1), CNST_LIMB(0x8564e6b7) }, + /* 164 */ { 4, 0.1359147715670014, CNST_LIMB(0x2b1e2100), CNST_LIMB(0x7bfbb5b4) }, + /* 165 */ { 4, 0.1357529539050150, CNST_LIMB(0x2c2dd2f1), CNST_LIMB(0x72dadcc8) }, + /* 166 */ { 4, 0.1355924953769863, CNST_LIMB(0x2d428110), CNST_LIMB(0x69ffc498) }, + /* 167 */ { 4, 0.1354333760385373, CNST_LIMB(0x2e5c3ae1), CNST_LIMB(0x6167f154) }, + /* 168 */ { 4, 0.1352755763596663, CNST_LIMB(0x2f7b1000), CNST_LIMB(0x5911016e) }, + /* 169 */ { 4, 0.1351190772136599, CNST_LIMB(0x309f1021), CNST_LIMB(0x50f8ac5f) }, + /* 170 */ { 4, 0.1349638598663645, CNST_LIMB(0x31c84b10), CNST_LIMB(0x491cc17c) }, + /* 171 */ { 4, 0.1348099059658079, CNST_LIMB(0x32f6d0b1), CNST_LIMB(0x417b26d8) }, + /* 172 */ { 4, 0.1346571975321549, CNST_LIMB(0x342ab100), CNST_LIMB(0x3a11d83b) }, + /* 173 */ { 4, 0.1345057169479844, CNST_LIMB(0x3563fc11), CNST_LIMB(0x32dee622) }, + /* 174 */ { 4, 0.1343554469488779, CNST_LIMB(0x36a2c210), CNST_LIMB(0x2be074cd) }, + /* 175 */ { 4, 0.1342063706143054, CNST_LIMB(0x37e71341), CNST_LIMB(0x2514bb58) }, + /* 176 */ { 4, 0.1340584713587980, CNST_LIMB(0x39310000), CNST_LIMB(0x1e7a02e7) }, + /* 177 */ { 4, 0.1339117329233981, CNST_LIMB(0x3a8098c1), CNST_LIMB(0x180ea5d0) }, + /* 178 */ { 4, 0.1337661393673756, CNST_LIMB(0x3bd5ee10), CNST_LIMB(0x11d10edd) }, + /* 179 */ { 4, 0.1336216750601996, CNST_LIMB(0x3d311091), CNST_LIMB(0xbbfb88e) }, + /* 180 */ { 4, 0.1334783246737591, CNST_LIMB(0x3e921100), CNST_LIMB(0x5d92c68) }, + /* 181 */ { 4, 0.1333360731748201, CNST_LIMB(0x3ff90031), CNST_LIMB(0x1c024c) }, + /* 182 */ { 4, 0.1331949058177136, CNST_LIMB(0x4165ef10), CNST_LIMB(0xf50dbfb2) }, + /* 183 */ { 4, 0.1330548081372441, CNST_LIMB(0x42d8eea1), CNST_LIMB(0xea30efa3) }, + /* 184 */ { 4, 0.1329157659418126, CNST_LIMB(0x44521000), CNST_LIMB(0xdf9f1316) }, + /* 185 */ { 4, 0.1327777653067443, CNST_LIMB(0x45d16461), CNST_LIMB(0xd555c0c9) }, + /* 186 */ { 4, 0.1326407925678156, CNST_LIMB(0x4756fd10), CNST_LIMB(0xcb52a684) }, + /* 187 */ { 4, 0.1325048343149731, CNST_LIMB(0x48e2eb71), CNST_LIMB(0xc193881f) }, + /* 188 */ { 4, 0.1323698773862368, CNST_LIMB(0x4a754100), CNST_LIMB(0xb8163e97) }, + /* 189 */ { 4, 0.1322359088617821, CNST_LIMB(0x4c0e0f51), CNST_LIMB(0xaed8b724) }, + /* 190 */ { 4, 0.1321029160581950, CNST_LIMB(0x4dad6810), CNST_LIMB(0xa5d8f269) }, + /* 191 */ { 4, 0.1319708865228925, CNST_LIMB(0x4f535d01), CNST_LIMB(0x9d15039d) }, + /* 192 */ { 4, 0.1318398080287045, CNST_LIMB(0x51000000), CNST_LIMB(0x948b0fcd) }, + /* 193 */ { 4, 0.1317096685686114, CNST_LIMB(0x52b36301), CNST_LIMB(0x8c394d1d) }, + /* 194 */ { 4, 0.1315804563506306, CNST_LIMB(0x546d9810), CNST_LIMB(0x841e0215) }, + /* 195 */ { 4, 0.1314521597928493, CNST_LIMB(0x562eb151), CNST_LIMB(0x7c3784f8) }, + /* 196 */ { 4, 0.1313247675185968, CNST_LIMB(0x57f6c100), CNST_LIMB(0x74843b1e) }, + /* 197 */ { 4, 0.1311982683517524, CNST_LIMB(0x59c5d971), CNST_LIMB(0x6d02985d) }, + /* 198 */ { 4, 0.1310726513121843, CNST_LIMB(0x5b9c0d10), CNST_LIMB(0x65b11e6e) }, + /* 199 */ { 4, 0.1309479056113158, CNST_LIMB(0x5d796e61), CNST_LIMB(0x5e8e5c64) }, + /* 200 */ { 4, 0.1308240206478128, CNST_LIMB(0x5f5e1000), CNST_LIMB(0x5798ee23) }, + /* 201 */ { 4, 0.1307009860033912, CNST_LIMB(0x614a04a1), CNST_LIMB(0x50cf7bde) }, + /* 202 */ { 4, 0.1305787914387386, CNST_LIMB(0x633d5f10), CNST_LIMB(0x4a30b99b) }, + /* 203 */ { 4, 0.1304574268895465, CNST_LIMB(0x65383231), CNST_LIMB(0x43bb66bd) }, + /* 204 */ { 4, 0.1303368824626505, CNST_LIMB(0x673a9100), CNST_LIMB(0x3d6e4d94) }, + /* 205 */ { 4, 0.1302171484322746, CNST_LIMB(0x69448e91), CNST_LIMB(0x374842ee) }, + /* 206 */ { 4, 0.1300982152363760, CNST_LIMB(0x6b563e10), CNST_LIMB(0x314825b0) }, + /* 207 */ { 4, 0.1299800734730872, CNST_LIMB(0x6d6fb2c1), CNST_LIMB(0x2b6cde75) }, + /* 208 */ { 4, 0.1298627138972530, CNST_LIMB(0x6f910000), CNST_LIMB(0x25b55f2e) }, + /* 209 */ { 4, 0.1297461274170591, CNST_LIMB(0x71ba3941), CNST_LIMB(0x2020a2c5) }, + /* 210 */ { 4, 0.1296303050907487, CNST_LIMB(0x73eb7210), CNST_LIMB(0x1aadaccb) }, + /* 211 */ { 4, 0.1295152381234257, CNST_LIMB(0x7624be11), CNST_LIMB(0x155b891f) }, + /* 212 */ { 4, 0.1294009178639407, CNST_LIMB(0x78663100), CNST_LIMB(0x10294ba2) }, + /* 213 */ { 4, 0.1292873358018581, CNST_LIMB(0x7aafdeb1), CNST_LIMB(0xb160fe9) }, + /* 214 */ { 4, 0.1291744835645007, CNST_LIMB(0x7d01db10), CNST_LIMB(0x620f8f6) }, + /* 215 */ { 4, 0.1290623529140715, CNST_LIMB(0x7f5c3a21), CNST_LIMB(0x14930ef) }, + /* 216 */ { 4, 0.1289509357448472, CNST_LIMB(0x81bf1000), CNST_LIMB(0xf91bd1b6) }, + /* 217 */ { 4, 0.1288402240804449, CNST_LIMB(0x842a70e1), CNST_LIMB(0xefdcb0c7) }, + /* 218 */ { 4, 0.1287302100711567, CNST_LIMB(0x869e7110), CNST_LIMB(0xe6d37b2a) }, + /* 219 */ { 4, 0.1286208859913518, CNST_LIMB(0x891b24f1), CNST_LIMB(0xddfeb94a) }, + /* 220 */ { 4, 0.1285122442369443, CNST_LIMB(0x8ba0a100), CNST_LIMB(0xd55cff6e) }, + /* 221 */ { 4, 0.1284042773229231, CNST_LIMB(0x8e2ef9d1), CNST_LIMB(0xcceced50) }, + /* 222 */ { 4, 0.1282969778809442, CNST_LIMB(0x90c64410), CNST_LIMB(0xc4ad2db2) }, + /* 223 */ { 4, 0.1281903386569819, CNST_LIMB(0x93669481), CNST_LIMB(0xbc9c75f9) }, + /* 224 */ { 4, 0.1280843525090381, CNST_LIMB(0x96100000), CNST_LIMB(0xb4b985cf) }, + /* 225 */ { 4, 0.1279790124049077, CNST_LIMB(0x98c29b81), CNST_LIMB(0xad0326c2) }, + /* 226 */ { 4, 0.1278743114199984, CNST_LIMB(0x9b7e7c10), CNST_LIMB(0xa5782bef) }, + /* 227 */ { 4, 0.1277702427352035, CNST_LIMB(0x9e43b6d1), CNST_LIMB(0x9e1771a9) }, + /* 228 */ { 4, 0.1276667996348261, CNST_LIMB(0xa1126100), CNST_LIMB(0x96dfdd2a) }, + /* 229 */ { 4, 0.1275639755045533, CNST_LIMB(0xa3ea8ff1), CNST_LIMB(0x8fd05c41) }, + /* 230 */ { 4, 0.1274617638294791, CNST_LIMB(0xa6cc5910), CNST_LIMB(0x88e7e509) }, + /* 231 */ { 4, 0.1273601581921741, CNST_LIMB(0xa9b7d1e1), CNST_LIMB(0x8225759d) }, + /* 232 */ { 4, 0.1272591522708010, CNST_LIMB(0xacad1000), CNST_LIMB(0x7b8813d3) }, + /* 233 */ { 4, 0.1271587398372755, CNST_LIMB(0xafac2921), CNST_LIMB(0x750eccf9) }, + /* 234 */ { 4, 0.1270589147554692, CNST_LIMB(0xb2b53310), CNST_LIMB(0x6eb8b595) }, + /* 235 */ { 4, 0.1269596709794558, CNST_LIMB(0xb5c843b1), CNST_LIMB(0x6884e923) }, + /* 236 */ { 4, 0.1268610025517973, CNST_LIMB(0xb8e57100), CNST_LIMB(0x627289db) }, + /* 237 */ { 4, 0.1267629036018709, CNST_LIMB(0xbc0cd111), CNST_LIMB(0x5c80c07b) }, + /* 238 */ { 4, 0.1266653683442337, CNST_LIMB(0xbf3e7a10), CNST_LIMB(0x56aebc07) }, + /* 239 */ { 4, 0.1265683910770258, CNST_LIMB(0xc27a8241), CNST_LIMB(0x50fbb19b) }, + /* 240 */ { 4, 0.1264719661804097, CNST_LIMB(0xc5c10000), CNST_LIMB(0x4b66dc33) }, + /* 241 */ { 4, 0.1263760881150453, CNST_LIMB(0xc91209c1), CNST_LIMB(0x45ef7c7c) }, + /* 242 */ { 4, 0.1262807514205999, CNST_LIMB(0xcc6db610), CNST_LIMB(0x4094d8a3) }, + /* 243 */ { 4, 0.1261859507142915, CNST_LIMB(0xcfd41b91), CNST_LIMB(0x3b563c24) }, + /* 244 */ { 4, 0.1260916806894653, CNST_LIMB(0xd3455100), CNST_LIMB(0x3632f7a5) }, + /* 245 */ { 4, 0.1259979361142023, CNST_LIMB(0xd6c16d31), CNST_LIMB(0x312a60c3) }, + /* 246 */ { 4, 0.1259047118299582, CNST_LIMB(0xda488710), CNST_LIMB(0x2c3bd1f0) }, + /* 247 */ { 4, 0.1258120027502338, CNST_LIMB(0xdddab5a1), CNST_LIMB(0x2766aa45) }, + /* 248 */ { 4, 0.1257198038592741, CNST_LIMB(0xe1781000), CNST_LIMB(0x22aa4d5f) }, + /* 249 */ { 4, 0.1256281102107963, CNST_LIMB(0xe520ad61), CNST_LIMB(0x1e06233c) }, + /* 250 */ { 4, 0.1255369169267456, CNST_LIMB(0xe8d4a510), CNST_LIMB(0x19799812) }, + /* 251 */ { 4, 0.1254462191960791, CNST_LIMB(0xec940e71), CNST_LIMB(0x15041c33) }, + /* 252 */ { 4, 0.1253560122735751, CNST_LIMB(0xf05f0100), CNST_LIMB(0x10a523e5) }, + /* 253 */ { 4, 0.1252662914786691, CNST_LIMB(0xf4359451), CNST_LIMB(0xc5c2749) }, + /* 254 */ { 4, 0.1251770521943144, CNST_LIMB(0xf817e010), CNST_LIMB(0x828a237) }, + /* 255 */ { 4, 0.1250882898658681, CNST_LIMB(0xfc05fc01), CNST_LIMB(0x40a1423) }, + /* 256 */ { 4, 0.1250000000000000, 0x8 }, +}; +#endif /* 32bit */ + +#if GMP_NUMB_BITS == 64 +const struct bases mp_bases[257] = +{ + /* 0 */ { 0, 0.0, 0 }, + /* 1 */ { 0, 1e37, 0 }, + /* 2 */ { 64, 1.0000000000000000, 0x1 }, + /* 3 */ { 40, 0.6309297535714574, CNST_LIMB(0xa8b8b452291fe821), CNST_LIMB(0x846d550e37b5063d) }, + /* 4 */ { 32, 0.5000000000000000, 0x2 }, + /* 5 */ { 27, 0.4306765580733931, CNST_LIMB(0x6765c793fa10079d), CNST_LIMB(0x3ce9a36f23c0fc90) }, + /* 6 */ { 24, 0.3868528072345416, CNST_LIMB(0x41c21cb8e1000000), CNST_LIMB(0xf24f62335024a295) }, + /* 7 */ { 22, 0.3562071871080222, CNST_LIMB(0x3642798750226111), CNST_LIMB(0x2df495ccaa57147b) }, + /* 8 */ { 21, 0.3333333333333334, 0x3 }, + /* 9 */ { 20, 0.3154648767857287, CNST_LIMB(0xa8b8b452291fe821), CNST_LIMB(0x846d550e37b5063d) }, + /* 10 */ { 19, 0.3010299956639811, CNST_LIMB(0x8ac7230489e80000), CNST_LIMB(0xd83c94fb6d2ac34a) }, + /* 11 */ { 18, 0.2890648263178878, CNST_LIMB(0x4d28cb56c33fa539), CNST_LIMB(0xa8adf7ae45e7577b) }, + /* 12 */ { 17, 0.2789429456511298, CNST_LIMB(0x1eca170c00000000), CNST_LIMB(0xa10c2bec5da8f8f) }, + /* 13 */ { 17, 0.2702381544273197, CNST_LIMB(0x780c7372621bd74d), CNST_LIMB(0x10f4becafe412ec3) }, + /* 14 */ { 16, 0.2626495350371936, CNST_LIMB(0x1e39a5057d810000), CNST_LIMB(0xf08480f672b4e86) }, + /* 15 */ { 16, 0.2559580248098155, CNST_LIMB(0x5b27ac993df97701), CNST_LIMB(0x6779c7f90dc42f48) }, + /* 16 */ { 16, 0.2500000000000000, 0x4 }, + /* 17 */ { 15, 0.2446505421182260, CNST_LIMB(0x27b95e997e21d9f1), CNST_LIMB(0x9c71e11bab279323) }, + /* 18 */ { 15, 0.2398124665681315, CNST_LIMB(0x5da0e1e53c5c8000), CNST_LIMB(0x5dfaa697ec6f6a1c) }, + /* 19 */ { 15, 0.2354089133666382, CNST_LIMB(0xd2ae3299c1c4aedb), CNST_LIMB(0x3711783f6be7e9ec) }, + /* 20 */ { 14, 0.2313782131597592, CNST_LIMB(0x16bcc41e90000000), CNST_LIMB(0x6849b86a12b9b01e) }, + /* 21 */ { 14, 0.2276702486969530, CNST_LIMB(0x2d04b7fdd9c0ef49), CNST_LIMB(0x6bf097ba5ca5e239) }, + /* 22 */ { 14, 0.2242438242175754, CNST_LIMB(0x5658597bcaa24000), CNST_LIMB(0x7b8015c8d7af8f08) }, + /* 23 */ { 14, 0.2210647294575037, CNST_LIMB(0xa0e2073737609371), CNST_LIMB(0x975a24b3a3151b38) }, + /* 24 */ { 13, 0.2181042919855316, CNST_LIMB(0xc29e98000000000), CNST_LIMB(0x50bd367972689db1) }, + /* 25 */ { 13, 0.2153382790366965, CNST_LIMB(0x14adf4b7320334b9), CNST_LIMB(0x8c240c4aecb13bb5) }, + /* 26 */ { 13, 0.2127460535533632, CNST_LIMB(0x226ed36478bfa000), CNST_LIMB(0xdbd2e56854e118c9) }, + /* 27 */ { 13, 0.2103099178571525, CNST_LIMB(0x383d9170b85ff80b), CNST_LIMB(0x2351ffcaa9c7c4ae) }, + /* 28 */ { 13, 0.2080145976765095, CNST_LIMB(0x5a3c23e39c000000), CNST_LIMB(0x6b24188ca33b0636) }, + /* 29 */ { 13, 0.2058468324604344, CNST_LIMB(0x8e65137388122bcd), CNST_LIMB(0xcc3dceaf2b8ba99d) }, + /* 30 */ { 13, 0.2037950470905062, CNST_LIMB(0xdd41bb36d259e000), CNST_LIMB(0x2832e835c6c7d6b6) }, + /* 31 */ { 12, 0.2018490865820999, CNST_LIMB(0xaee5720ee830681), CNST_LIMB(0x76b6aa272e1873c5) }, + /* 32 */ { 12, 0.2000000000000000, 0x5 }, + /* 33 */ { 12, 0.1982398631705605, CNST_LIMB(0x172588ad4f5f0981), CNST_LIMB(0x61eaf5d402c7bf4f) }, + /* 34 */ { 12, 0.1965616322328226, CNST_LIMB(0x211e44f7d02c1000), CNST_LIMB(0xeeb658123ffb27ec) }, + /* 35 */ { 12, 0.1949590218937863, CNST_LIMB(0x2ee56725f06e5c71), CNST_LIMB(0x5d5e3762e6fdf509) }, + /* 36 */ { 12, 0.1934264036172708, CNST_LIMB(0x41c21cb8e1000000), CNST_LIMB(0xf24f62335024a295) }, + /* 37 */ { 12, 0.1919587200065601, CNST_LIMB(0x5b5b57f8a98a5dd1), CNST_LIMB(0x66ae7831762efb6f) }, + /* 38 */ { 12, 0.1905514124267734, CNST_LIMB(0x7dcff8986ea31000), CNST_LIMB(0x47388865a00f544) }, + /* 39 */ { 12, 0.1892003595168700, CNST_LIMB(0xabd4211662a6b2a1), CNST_LIMB(0x7d673c33a123b54c) }, + /* 40 */ { 12, 0.1879018247091076, CNST_LIMB(0xe8d4a51000000000), CNST_LIMB(0x19799812dea11197) }, + /* 41 */ { 11, 0.1866524112389434, CNST_LIMB(0x7a32956ad081b79), CNST_LIMB(0xc27e62e0686feae) }, + /* 42 */ { 11, 0.1854490234153689, CNST_LIMB(0x9f49aaff0e86800), CNST_LIMB(0x9b6e7507064ce7c7) }, + /* 43 */ { 11, 0.1842888331487062, CNST_LIMB(0xce583bb812d37b3), CNST_LIMB(0x3d9ac2bf66cfed94) }, + /* 44 */ { 11, 0.1831692509136336, CNST_LIMB(0x109b79a654c00000), CNST_LIMB(0xed46bc50ce59712a) }, + /* 45 */ { 11, 0.1820879004699383, CNST_LIMB(0x1543beff214c8b95), CNST_LIMB(0x813d97e2c89b8d46) }, + /* 46 */ { 11, 0.1810425967800402, CNST_LIMB(0x1b149a79459a3800), CNST_LIMB(0x2e81751956af8083) }, + /* 47 */ { 11, 0.1800313266566926, CNST_LIMB(0x224edfb5434a830f), CNST_LIMB(0xdd8e0a95e30c0988) }, + /* 48 */ { 11, 0.1790522317510413, CNST_LIMB(0x2b3fb00000000000), CNST_LIMB(0x7ad4dd48a0b5b167) }, + /* 49 */ { 11, 0.1781035935540111, CNST_LIMB(0x3642798750226111), CNST_LIMB(0x2df495ccaa57147b) }, + /* 50 */ { 11, 0.1771838201355579, CNST_LIMB(0x43c33c1937564800), CNST_LIMB(0xe392010175ee5962) }, + /* 51 */ { 11, 0.1762914343888821, CNST_LIMB(0x54411b2441c3cd8b), CNST_LIMB(0x84eaf11b2fe7738e) }, + /* 52 */ { 11, 0.1754250635819545, CNST_LIMB(0x6851455acd400000), CNST_LIMB(0x3a1e3971e008995d) }, + /* 53 */ { 11, 0.1745834300480449, CNST_LIMB(0x80a23b117c8feb6d), CNST_LIMB(0xfd7a462344ffce25) }, + /* 54 */ { 11, 0.1737653428714400, CNST_LIMB(0x9dff7d32d5dc1800), CNST_LIMB(0x9eca40b40ebcef8a) }, + /* 55 */ { 11, 0.1729696904450771, CNST_LIMB(0xc155af6faeffe6a7), CNST_LIMB(0x52fa161a4a48e43d) }, + /* 56 */ { 11, 0.1721954337940981, CNST_LIMB(0xebb7392e00000000), CNST_LIMB(0x1607a2cbacf930c1) }, + /* 57 */ { 10, 0.1714416005739134, CNST_LIMB(0x50633659656d971), CNST_LIMB(0x97a014f8e3be55f1) }, + /* 58 */ { 10, 0.1707072796637201, CNST_LIMB(0x5fa8624c7fba400), CNST_LIMB(0x568df8b76cbf212c) }, + /* 59 */ { 10, 0.1699916162869140, CNST_LIMB(0x717d9faa73c5679), CNST_LIMB(0x20ba7c4b4e6ef492) }, + /* 60 */ { 10, 0.1692938075987814, CNST_LIMB(0x86430aac6100000), CNST_LIMB(0xe81ee46b9ef492f5) }, + /* 61 */ { 10, 0.1686130986895011, CNST_LIMB(0x9e64d9944b57f29), CNST_LIMB(0x9dc0d10d51940416) }, + /* 62 */ { 10, 0.1679487789570419, CNST_LIMB(0xba5ca5392cb0400), CNST_LIMB(0x5fa8ed2f450272a5) }, + /* 63 */ { 10, 0.1673001788101741, CNST_LIMB(0xdab2ce1d022cd81), CNST_LIMB(0x2ba9eb8c5e04e641) }, + /* 64 */ { 10, 0.1666666666666667, 0x6 }, + /* 65 */ { 10, 0.1660476462159378, CNST_LIMB(0x12aeed5fd3e2d281), CNST_LIMB(0xb67759cc00287bf1) }, + /* 66 */ { 10, 0.1654425539190583, CNST_LIMB(0x15c3da1572d50400), CNST_LIMB(0x78621feeb7f4ed33) }, + /* 67 */ { 10, 0.1648508567221604, CNST_LIMB(0x194c05534f75ee29), CNST_LIMB(0x43d55b5f72943bc0) }, + /* 68 */ { 10, 0.1642720499620502, CNST_LIMB(0x1d56299ada100000), CNST_LIMB(0x173decb64d1d4409) }, + /* 69 */ { 10, 0.1637056554452156, CNST_LIMB(0x21f2a089a4ff4f79), CNST_LIMB(0xe29fb54fd6b6074f) }, + /* 70 */ { 10, 0.1631512196835108, CNST_LIMB(0x2733896c68d9a400), CNST_LIMB(0xa1f1f5c210d54e62) }, + /* 71 */ { 10, 0.1626083122716341, CNST_LIMB(0x2d2cf2c33b533c71), CNST_LIMB(0x6aac7f9bfafd57b2) }, + /* 72 */ { 10, 0.1620765243931223, CNST_LIMB(0x33f506e440000000), CNST_LIMB(0x3b563c2478b72ee2) }, + /* 73 */ { 10, 0.1615554674429964, CNST_LIMB(0x3ba43bec1d062211), CNST_LIMB(0x12b536b574e92d1b) }, + /* 74 */ { 10, 0.1610447717564444, CNST_LIMB(0x4455872d8fd4e400), CNST_LIMB(0xdf86c03020404fa5) }, + /* 75 */ { 10, 0.1605440854340214, CNST_LIMB(0x4e2694539f2f6c59), CNST_LIMB(0xa34adf02234eea8e) }, + /* 76 */ { 10, 0.1600530732548213, CNST_LIMB(0x5938006c18900000), CNST_LIMB(0x6f46eb8574eb59dd) }, + /* 77 */ { 10, 0.1595714156699382, CNST_LIMB(0x65ad9912474aa649), CNST_LIMB(0x42459b481df47cec) }, + /* 78 */ { 10, 0.1590988078692941, CNST_LIMB(0x73ae9ff4241ec400), CNST_LIMB(0x1b424b95d80ca505) }, + /* 79 */ { 10, 0.1586349589155960, CNST_LIMB(0x836612ee9c4ce1e1), CNST_LIMB(0xf2c1b982203a0dac) }, + /* 80 */ { 10, 0.1581795909397823, CNST_LIMB(0x9502f90000000000), CNST_LIMB(0xb7cdfd9d7bdbab7d) }, + /* 81 */ { 10, 0.1577324383928644, CNST_LIMB(0xa8b8b452291fe821), CNST_LIMB(0x846d550e37b5063d) }, + /* 82 */ { 10, 0.1572932473495469, CNST_LIMB(0xbebf59a07dab4400), CNST_LIMB(0x57931eeaf85cf64f) }, + /* 83 */ { 10, 0.1568617748594410, CNST_LIMB(0xd7540d4093bc3109), CNST_LIMB(0x305a944507c82f47) }, + /* 84 */ { 10, 0.1564377883420716, CNST_LIMB(0xf2b96616f1900000), CNST_LIMB(0xe007ccc9c22781a) }, + /* 85 */ { 9, 0.1560210650222250, CNST_LIMB(0x336de62af2bca35), CNST_LIMB(0x3e92c42e000eeed4) }, + /* 86 */ { 9, 0.1556113914024940, CNST_LIMB(0x39235ec33d49600), CNST_LIMB(0x1ebe59130db2795e) }, + /* 87 */ { 9, 0.1552085627701551, CNST_LIMB(0x3f674e539585a17), CNST_LIMB(0x268859e90f51b89) }, + /* 88 */ { 9, 0.1548123827357682, CNST_LIMB(0x4645b6958000000), CNST_LIMB(0xd24cde0463108cfa) }, + /* 89 */ { 9, 0.1544226628011101, CNST_LIMB(0x4dcb74afbc49c19), CNST_LIMB(0xa536009f37adc383) }, + /* 90 */ { 9, 0.1540392219542636, CNST_LIMB(0x56064e1d18d9a00), CNST_LIMB(0x7cea06ce1c9ace10) }, + /* 91 */ { 9, 0.1536618862898642, CNST_LIMB(0x5f04fe2cd8a39fb), CNST_LIMB(0x58db032e72e8ba43) }, + /* 92 */ { 9, 0.1532904886526781, CNST_LIMB(0x68d74421f5c0000), CNST_LIMB(0x388cc17cae105447) }, + /* 93 */ { 9, 0.1529248683028321, CNST_LIMB(0x738df1f6ab4827d), CNST_LIMB(0x1b92672857620ce0) }, + /* 94 */ { 9, 0.1525648706011593, CNST_LIMB(0x7f3afbc9cfb5e00), CNST_LIMB(0x18c6a9575c2ade4) }, + /* 95 */ { 9, 0.1522103467132434, CNST_LIMB(0x8bf187fba88f35f), CNST_LIMB(0xd44da7da8e44b24f) }, + /* 96 */ { 9, 0.1518611533308632, CNST_LIMB(0x99c600000000000), CNST_LIMB(0xaa2f78f1b4cc6794) }, + /* 97 */ { 9, 0.1515171524096389, CNST_LIMB(0xa8ce21eb6531361), CNST_LIMB(0x843c067d091ee4cc) }, + /* 98 */ { 9, 0.1511782109217764, CNST_LIMB(0xb92112c1a0b6200), CNST_LIMB(0x62005e1e913356e3) }, + /* 99 */ { 9, 0.1508442006228941, CNST_LIMB(0xcad7718b8747c43), CNST_LIMB(0x4316eed01dedd518) }, + /* 100 */ { 9, 0.1505149978319906, CNST_LIMB(0xde0b6b3a7640000), CNST_LIMB(0x2725dd1d243aba0e) }, + /* 101 */ { 9, 0.1501904832236879, CNST_LIMB(0xf2d8cf5fe6d74c5), CNST_LIMB(0xddd9057c24cb54f) }, + /* 102 */ { 9, 0.1498705416319474, CNST_LIMB(0x1095d25bfa712600), CNST_LIMB(0xedeee175a736d2a1) }, + /* 103 */ { 9, 0.1495550618645152, CNST_LIMB(0x121b7c4c3698faa7), CNST_LIMB(0xc4699f3df8b6b328) }, + /* 104 */ { 9, 0.1492439365274121, CNST_LIMB(0x13c09e8d68000000), CNST_LIMB(0x9ebbe7d859cb5a7c) }, + /* 105 */ { 9, 0.1489370618588283, CNST_LIMB(0x15876ccb0b709ca9), CNST_LIMB(0x7c828b9887eb2179) }, + /* 106 */ { 9, 0.1486343375718350, CNST_LIMB(0x17723c2976da2a00), CNST_LIMB(0x5d652ab99001adcf) }, + /* 107 */ { 9, 0.1483356667053617, CNST_LIMB(0x198384e9c259048b), CNST_LIMB(0x4114f1754e5d7b32) }, + /* 108 */ { 9, 0.1480409554829326, CNST_LIMB(0x1bbde41dfeec0000), CNST_LIMB(0x274b7c902f7e0188) }, + /* 109 */ { 9, 0.1477501131786861, CNST_LIMB(0x1e241d6e3337910d), CNST_LIMB(0xfc9e0fbb32e210c) }, + /* 110 */ { 9, 0.1474630519902391, CNST_LIMB(0x20b91cee9901ee00), CNST_LIMB(0xf4afa3e594f8ea1f) }, + /* 111 */ { 9, 0.1471796869179852, CNST_LIMB(0x237ff9079863dfef), CNST_LIMB(0xcd85c32e9e4437b0) }, + /* 112 */ { 9, 0.1468999356504447, CNST_LIMB(0x267bf47000000000), CNST_LIMB(0xa9bbb147e0dd92a8) }, + /* 113 */ { 9, 0.1466237184553111, CNST_LIMB(0x29b08039fbeda7f1), CNST_LIMB(0x8900447b70e8eb82) }, + /* 114 */ { 9, 0.1463509580758620, CNST_LIMB(0x2d213df34f65f200), CNST_LIMB(0x6b0a92adaad5848a) }, + /* 115 */ { 9, 0.1460815796324244, CNST_LIMB(0x30d201d957a7c2d3), CNST_LIMB(0x4f990ad8740f0ee5) }, + /* 116 */ { 9, 0.1458155105286054, CNST_LIMB(0x34c6d52160f40000), CNST_LIMB(0x3670a9663a8d3610) }, + /* 117 */ { 9, 0.1455526803620167, CNST_LIMB(0x3903f855d8f4c755), CNST_LIMB(0x1f5c44188057be3c) }, + /* 118 */ { 9, 0.1452930208392428, CNST_LIMB(0x3d8de5c8ec59b600), CNST_LIMB(0xa2bea956c4e4977) }, + /* 119 */ { 9, 0.1450364656948130, CNST_LIMB(0x4269541d1ff01337), CNST_LIMB(0xed68b23033c3637e) }, + /* 120 */ { 9, 0.1447829506139581, CNST_LIMB(0x479b38e478000000), CNST_LIMB(0xc99cf624e50549c5) }, + /* 121 */ { 9, 0.1445324131589439, CNST_LIMB(0x4d28cb56c33fa539), CNST_LIMB(0xa8adf7ae45e7577b) }, + /* 122 */ { 9, 0.1442847926987864, CNST_LIMB(0x5317871fa13aba00), CNST_LIMB(0x8a5bc740b1c113e5) }, + /* 123 */ { 9, 0.1440400303421672, CNST_LIMB(0x596d2f44de9fa71b), CNST_LIMB(0x6e6c7efb81cfbb9b) }, + /* 124 */ { 9, 0.1437980688733775, CNST_LIMB(0x602fd125c47c0000), CNST_LIMB(0x54aba5c5cada5f10) }, + /* 125 */ { 9, 0.1435588526911310, CNST_LIMB(0x6765c793fa10079d), CNST_LIMB(0x3ce9a36f23c0fc90) }, + /* 126 */ { 9, 0.1433223277500932, CNST_LIMB(0x6f15be069b847e00), CNST_LIMB(0x26fb43de2c8cd2a8) }, + /* 127 */ { 9, 0.1430884415049874, CNST_LIMB(0x7746b3e82a77047f), CNST_LIMB(0x12b94793db8486a1) }, + /* 128 */ { 9, 0.1428571428571428, 0x7 }, + /* 129 */ { 9, 0.1426283821033600, CNST_LIMB(0x894953f7ea890481), CNST_LIMB(0xdd5deca404c0156d) }, + /* 130 */ { 9, 0.1424021108869747, CNST_LIMB(0x932abffea4848200), CNST_LIMB(0xbd51373330291de0) }, + /* 131 */ { 9, 0.1421782821510107, CNST_LIMB(0x9dacb687d3d6a163), CNST_LIMB(0x9fa4025d66f23085) }, + /* 132 */ { 9, 0.1419568500933153, CNST_LIMB(0xa8d8102a44840000), CNST_LIMB(0x842530ee2db4949d) }, + /* 133 */ { 9, 0.1417377701235801, CNST_LIMB(0xb4b60f9d140541e5), CNST_LIMB(0x6aa7f2766b03dc25) }, + /* 134 */ { 9, 0.1415209988221527, CNST_LIMB(0xc15065d4856e4600), CNST_LIMB(0x53035ba7ebf32e8d) }, + /* 135 */ { 9, 0.1413064939005528, CNST_LIMB(0xceb1363f396d23c7), CNST_LIMB(0x3d12091fc9fb4914) }, + /* 136 */ { 9, 0.1410942141636095, CNST_LIMB(0xdce31b2488000000), CNST_LIMB(0x28b1cb81b1ef1849) }, + /* 137 */ { 9, 0.1408841194731412, CNST_LIMB(0xebf12a24bca135c9), CNST_LIMB(0x15c35be67ae3e2c9) }, + /* 138 */ { 9, 0.1406761707131039, CNST_LIMB(0xfbe6f8dbf88f4a00), CNST_LIMB(0x42a17bd09be1ff0) }, + /* 139 */ { 8, 0.1404703297561400, CNST_LIMB(0x1ef156c084ce761), CNST_LIMB(0x8bf461f03cf0bbf) }, + /* 140 */ { 8, 0.1402665594314587, CNST_LIMB(0x20c4e3b94a10000), CNST_LIMB(0xf3fbb43f68a32d05) }, + /* 141 */ { 8, 0.1400648234939879, CNST_LIMB(0x22b0695a08ba421), CNST_LIMB(0xd84f44c48564dc19) }, + /* 142 */ { 8, 0.1398650865947379, CNST_LIMB(0x24b4f35d7a4c100), CNST_LIMB(0xbe58ebcce7956abe) }, + /* 143 */ { 8, 0.1396673142523192, CNST_LIMB(0x26d397284975781), CNST_LIMB(0xa5fac463c7c134b7) }, + /* 144 */ { 8, 0.1394714728255649, CNST_LIMB(0x290d74100000000), CNST_LIMB(0x8f19241e28c7d757) }, + /* 145 */ { 8, 0.1392775294872041, CNST_LIMB(0x2b63b3a37866081), CNST_LIMB(0x799a6d046c0ae1ae) }, + /* 146 */ { 8, 0.1390854521985406, CNST_LIMB(0x2dd789f4d894100), CNST_LIMB(0x6566e37d746a9e40) }, + /* 147 */ { 8, 0.1388952096850913, CNST_LIMB(0x306a35e51b58721), CNST_LIMB(0x526887dbfb5f788f) }, + /* 148 */ { 8, 0.1387067714131417, CNST_LIMB(0x331d01712e10000), CNST_LIMB(0x408af3382b8efd3d) }, + /* 149 */ { 8, 0.1385201075671774, CNST_LIMB(0x35f14200a827c61), CNST_LIMB(0x2fbb374806ec05f1) }, + /* 150 */ { 8, 0.1383351890281539, CNST_LIMB(0x38e858b62216100), CNST_LIMB(0x1fe7c0f0afce87fe) }, + /* 151 */ { 8, 0.1381519873525671, CNST_LIMB(0x3c03b2c13176a41), CNST_LIMB(0x11003d517540d32e) }, + /* 152 */ { 8, 0.1379704747522905, CNST_LIMB(0x3f44c9b21000000), CNST_LIMB(0x2f5810f98eff0dc) }, + /* 153 */ { 8, 0.1377906240751463, CNST_LIMB(0x42ad23cef3113c1), CNST_LIMB(0xeb72e35e7840d910) }, + /* 154 */ { 8, 0.1376124087861776, CNST_LIMB(0x463e546b19a2100), CNST_LIMB(0xd27de19593dc3614) }, + /* 155 */ { 8, 0.1374358029495937, CNST_LIMB(0x49f9fc3f96684e1), CNST_LIMB(0xbaf391fd3e5e6fc2) }, + /* 156 */ { 8, 0.1372607812113589, CNST_LIMB(0x4de1c9c5dc10000), CNST_LIMB(0xa4bd38c55228c81d) }, + /* 157 */ { 8, 0.1370873187823978, CNST_LIMB(0x51f77994116d2a1), CNST_LIMB(0x8fc5a8de8e1de782) }, + /* 158 */ { 8, 0.1369153914223921, CNST_LIMB(0x563cd6bb3398100), CNST_LIMB(0x7bf9265bea9d3a3b) }, + /* 159 */ { 8, 0.1367449754241439, CNST_LIMB(0x5ab3bb270beeb01), CNST_LIMB(0x69454b325983dccd) }, + /* 160 */ { 8, 0.1365760475984821, CNST_LIMB(0x5f5e10000000000), CNST_LIMB(0x5798ee2308c39df9) }, + /* 161 */ { 8, 0.1364085852596902, CNST_LIMB(0x643dce0ec16f501), CNST_LIMB(0x46e40ba0fa66a753) }, + /* 162 */ { 8, 0.1362425662114337, CNST_LIMB(0x6954fe21e3e8100), CNST_LIMB(0x3717b0870b0db3a7) }, + /* 163 */ { 8, 0.1360779687331669, CNST_LIMB(0x6ea5b9755f440a1), CNST_LIMB(0x2825e6775d11cdeb) }, + /* 164 */ { 8, 0.1359147715670014, CNST_LIMB(0x74322a1c0410000), CNST_LIMB(0x1a01a1c09d1b4dac) }, + /* 165 */ { 8, 0.1357529539050150, CNST_LIMB(0x79fc8b6ae8a46e1), CNST_LIMB(0xc9eb0a8bebc8f3e) }, + /* 166 */ { 8, 0.1355924953769863, CNST_LIMB(0x80072a66d512100), CNST_LIMB(0xffe357ff59e6a004) }, + /* 167 */ { 8, 0.1354333760385373, CNST_LIMB(0x86546633b42b9c1), CNST_LIMB(0xe7dfd1be05fa61a8) }, + /* 168 */ { 8, 0.1352755763596663, CNST_LIMB(0x8ce6b0861000000), CNST_LIMB(0xd11ed6fc78f760e5) }, + /* 169 */ { 8, 0.1351190772136599, CNST_LIMB(0x93c08e16a022441), CNST_LIMB(0xbb8db609dd29ebfe) }, + /* 170 */ { 8, 0.1349638598663645, CNST_LIMB(0x9ae49717f026100), CNST_LIMB(0xa71aec8d1813d532) }, + /* 171 */ { 8, 0.1348099059658079, CNST_LIMB(0xa25577ae24c1a61), CNST_LIMB(0x93b612a9f20fbc02) }, + /* 172 */ { 8, 0.1346571975321549, CNST_LIMB(0xaa15f068e610000), CNST_LIMB(0x814fc7b19a67d317) }, + /* 173 */ { 8, 0.1345057169479844, CNST_LIMB(0xb228d6bf7577921), CNST_LIMB(0x6fd9a03f2e0a4b7c) }, + /* 174 */ { 8, 0.1343554469488779, CNST_LIMB(0xba91158ef5c4100), CNST_LIMB(0x5f4615a38d0d316e) }, + /* 175 */ { 8, 0.1342063706143054, CNST_LIMB(0xc351ad9aec0b681), CNST_LIMB(0x4f8876863479a286) }, + /* 176 */ { 8, 0.1340584713587980, CNST_LIMB(0xcc6db6100000000), CNST_LIMB(0x4094d8a3041b60eb) }, + /* 177 */ { 8, 0.1339117329233981, CNST_LIMB(0xd5e85d09025c181), CNST_LIMB(0x32600b8ed883a09b) }, + /* 178 */ { 8, 0.1337661393673756, CNST_LIMB(0xdfc4e816401c100), CNST_LIMB(0x24df8c6eb4b6d1f1) }, + /* 179 */ { 8, 0.1336216750601996, CNST_LIMB(0xea06b4c72947221), CNST_LIMB(0x18097a8ee151acef) }, + /* 180 */ { 8, 0.1334783246737591, CNST_LIMB(0xf4b139365210000), CNST_LIMB(0xbd48cc8ec1cd8e3) }, + /* 181 */ { 8, 0.1333360731748201, CNST_LIMB(0xffc80497d520961), CNST_LIMB(0x3807a8d67485fb) }, + /* 182 */ { 8, 0.1331949058177136, CNST_LIMB(0x10b4ebfca1dee100), CNST_LIMB(0xea5768860b62e8d8) }, + /* 183 */ { 8, 0.1330548081372441, CNST_LIMB(0x117492de921fc141), CNST_LIMB(0xd54faf5b635c5005) }, + /* 184 */ { 8, 0.1329157659418126, CNST_LIMB(0x123bb2ce41000000), CNST_LIMB(0xc14a56233a377926) }, + /* 185 */ { 8, 0.1327777653067443, CNST_LIMB(0x130a8b6157bdecc1), CNST_LIMB(0xae39a88db7cd329f) }, + /* 186 */ { 8, 0.1326407925678156, CNST_LIMB(0x13e15dede0e8a100), CNST_LIMB(0x9c10bde69efa7ab6) }, + /* 187 */ { 8, 0.1325048343149731, CNST_LIMB(0x14c06d941c0ca7e1), CNST_LIMB(0x8ac36c42a2836497) }, + /* 188 */ { 8, 0.1323698773862368, CNST_LIMB(0x15a7ff487a810000), CNST_LIMB(0x7a463c8b84f5ef67) }, + /* 189 */ { 8, 0.1322359088617821, CNST_LIMB(0x169859ddc5c697a1), CNST_LIMB(0x6a8e5f5ad090fd4b) }, + /* 190 */ { 8, 0.1321029160581950, CNST_LIMB(0x1791c60f6fed0100), CNST_LIMB(0x5b91a2943596fc56) }, + /* 191 */ { 8, 0.1319708865228925, CNST_LIMB(0x18948e8c0e6fba01), CNST_LIMB(0x4d4667b1c468e8f0) }, + /* 192 */ { 8, 0.1318398080287045, CNST_LIMB(0x19a1000000000000), CNST_LIMB(0x3fa39ab547994daf) }, + /* 193 */ { 8, 0.1317096685686114, CNST_LIMB(0x1ab769203dafc601), CNST_LIMB(0x32a0a9b2faee1e2a) }, + /* 194 */ { 8, 0.1315804563506306, CNST_LIMB(0x1bd81ab557f30100), CNST_LIMB(0x26357ceac0e96962) }, + /* 195 */ { 8, 0.1314521597928493, CNST_LIMB(0x1d0367a69fed1ba1), CNST_LIMB(0x1a5a6f65caa5859e) }, + /* 196 */ { 8, 0.1313247675185968, CNST_LIMB(0x1e39a5057d810000), CNST_LIMB(0xf08480f672b4e86) }, + /* 197 */ { 8, 0.1311982683517524, CNST_LIMB(0x1f7b2a18f29ac3e1), CNST_LIMB(0x4383340615612ca) }, + /* 198 */ { 8, 0.1310726513121843, CNST_LIMB(0x20c850694c2aa100), CNST_LIMB(0xf3c77969ee4be5a2) }, + /* 199 */ { 8, 0.1309479056113158, CNST_LIMB(0x222173cc014980c1), CNST_LIMB(0xe00993cc187c5ec9) }, + /* 200 */ { 8, 0.1308240206478128, CNST_LIMB(0x2386f26fc1000000), CNST_LIMB(0xcd2b297d889bc2b6) }, + /* 201 */ { 8, 0.1307009860033912, CNST_LIMB(0x24f92ce8af296d41), CNST_LIMB(0xbb214d5064862b22) }, + /* 202 */ { 8, 0.1305787914387386, CNST_LIMB(0x2678863cd0ece100), CNST_LIMB(0xa9e1a7ca7ea10e20) }, + /* 203 */ { 8, 0.1304574268895465, CNST_LIMB(0x280563f0a9472d61), CNST_LIMB(0x99626e72b39ea0cf) }, + /* 204 */ { 8, 0.1303368824626505, CNST_LIMB(0x29a02e1406210000), CNST_LIMB(0x899a5ba9c13fafd9) }, + /* 205 */ { 8, 0.1302171484322746, CNST_LIMB(0x2b494f4efe6d2e21), CNST_LIMB(0x7a80a705391e96ff) }, + /* 206 */ { 8, 0.1300982152363760, CNST_LIMB(0x2d0134ef21cbc100), CNST_LIMB(0x6c0cfe23de23042a) }, + /* 207 */ { 8, 0.1299800734730872, CNST_LIMB(0x2ec84ef4da2ef581), CNST_LIMB(0x5e377df359c944dd) }, + /* 208 */ { 8, 0.1298627138972530, CNST_LIMB(0x309f102100000000), CNST_LIMB(0x50f8ac5fc8f53985) }, + /* 209 */ { 8, 0.1297461274170591, CNST_LIMB(0x3285ee02a1420281), CNST_LIMB(0x44497266278e35b7) }, + /* 210 */ { 8, 0.1296303050907487, CNST_LIMB(0x347d6104fc324100), CNST_LIMB(0x382316831f7ee175) }, + /* 211 */ { 8, 0.1295152381234257, CNST_LIMB(0x3685e47dade53d21), CNST_LIMB(0x2c7f377833b8946e) }, + /* 212 */ { 8, 0.1294009178639407, CNST_LIMB(0x389ff6bb15610000), CNST_LIMB(0x2157c761ab4163ef) }, + /* 213 */ { 8, 0.1292873358018581, CNST_LIMB(0x3acc1912ebb57661), CNST_LIMB(0x16a7071803cc49a9) }, + /* 214 */ { 8, 0.1291744835645007, CNST_LIMB(0x3d0acff111946100), CNST_LIMB(0xc6781d80f8224fc) }, + /* 215 */ { 8, 0.1290623529140715, CNST_LIMB(0x3f5ca2e692eaf841), CNST_LIMB(0x294092d370a900b) }, + /* 216 */ { 8, 0.1289509357448472, CNST_LIMB(0x41c21cb8e1000000), CNST_LIMB(0xf24f62335024a295) }, + /* 217 */ { 8, 0.1288402240804449, CNST_LIMB(0x443bcb714399a5c1), CNST_LIMB(0xe03b98f103fad6d2) }, + /* 218 */ { 8, 0.1287302100711567, CNST_LIMB(0x46ca406c81af2100), CNST_LIMB(0xcee3d32cad2a9049) }, + /* 219 */ { 8, 0.1286208859913518, CNST_LIMB(0x496e106ac22aaae1), CNST_LIMB(0xbe3f9df9277fdada) }, + /* 220 */ { 8, 0.1285122442369443, CNST_LIMB(0x4c27d39fa5410000), CNST_LIMB(0xae46f0d94c05e933) }, + /* 221 */ { 8, 0.1284042773229231, CNST_LIMB(0x4ef825c296e43ca1), CNST_LIMB(0x9ef2280fb437a33d) }, + /* 222 */ { 8, 0.1282969778809442, CNST_LIMB(0x51dfa61f5ad88100), CNST_LIMB(0x9039ff426d3f284b) }, + /* 223 */ { 8, 0.1281903386569819, CNST_LIMB(0x54def7a6d2f16901), CNST_LIMB(0x82178c6d6b51f8f4) }, + /* 224 */ { 8, 0.1280843525090381, CNST_LIMB(0x57f6c10000000000), CNST_LIMB(0x74843b1ee4c1e053) }, + /* 225 */ { 8, 0.1279790124049077, CNST_LIMB(0x5b27ac993df97701), CNST_LIMB(0x6779c7f90dc42f48) }, + /* 226 */ { 8, 0.1278743114199984, CNST_LIMB(0x5e7268b9bbdf8100), CNST_LIMB(0x5af23c74f9ad9fe9) }, + /* 227 */ { 8, 0.1277702427352035, CNST_LIMB(0x61d7a7932ff3d6a1), CNST_LIMB(0x4ee7eae2acdc617e) }, + /* 228 */ { 8, 0.1276667996348261, CNST_LIMB(0x65581f53c8c10000), CNST_LIMB(0x43556aa2ac262a0b) }, + /* 229 */ { 8, 0.1275639755045533, CNST_LIMB(0x68f48a385b8320e1), CNST_LIMB(0x3835949593b8ddd1) }, + /* 230 */ { 8, 0.1274617638294791, CNST_LIMB(0x6cada69ed07c2100), CNST_LIMB(0x2d837fbe78458762) }, + /* 231 */ { 8, 0.1273601581921741, CNST_LIMB(0x70843718cdbf27c1), CNST_LIMB(0x233a7e150a54a555) }, + /* 232 */ { 8, 0.1272591522708010, CNST_LIMB(0x7479027ea1000000), CNST_LIMB(0x19561984a50ff8fe) }, + /* 233 */ { 8, 0.1271587398372755, CNST_LIMB(0x788cd40268f39641), CNST_LIMB(0xfd211159fe3490f) }, + /* 234 */ { 8, 0.1270589147554692, CNST_LIMB(0x7cc07b437ecf6100), CNST_LIMB(0x6aa563e655033e3) }, + /* 235 */ { 8, 0.1269596709794558, CNST_LIMB(0x8114cc6220762061), CNST_LIMB(0xfbb614b3f2d3b14c) }, + /* 236 */ { 8, 0.1268610025517973, CNST_LIMB(0x858aa0135be10000), CNST_LIMB(0xeac0f8837fb05773) }, + /* 237 */ { 8, 0.1267629036018709, CNST_LIMB(0x8a22d3b53c54c321), CNST_LIMB(0xda6e4c10e8615ca5) }, + /* 238 */ { 8, 0.1266653683442337, CNST_LIMB(0x8ede496339f34100), CNST_LIMB(0xcab755a8d01fa67f) }, + /* 239 */ { 8, 0.1265683910770258, CNST_LIMB(0x93bde80aec3a1481), CNST_LIMB(0xbb95a9ae71aa3e0c) }, + /* 240 */ { 8, 0.1264719661804097, CNST_LIMB(0x98c29b8100000000), CNST_LIMB(0xad0326c296b4f529) }, + /* 241 */ { 8, 0.1263760881150453, CNST_LIMB(0x9ded549671832381), CNST_LIMB(0x9ef9f21eed31b7c1) }, + /* 242 */ { 8, 0.1262807514205999, CNST_LIMB(0xa33f092e0b1ac100), CNST_LIMB(0x91747422be14b0b2) }, + /* 243 */ { 8, 0.1261859507142915, CNST_LIMB(0xa8b8b452291fe821), CNST_LIMB(0x846d550e37b5063d) }, + /* 244 */ { 8, 0.1260916806894653, CNST_LIMB(0xae5b564ac3a10000), CNST_LIMB(0x77df79e9a96c06f6) }, + /* 245 */ { 8, 0.1259979361142023, CNST_LIMB(0xb427f4b3be74c361), CNST_LIMB(0x6bc6019636c7d0c2) }, + /* 246 */ { 8, 0.1259047118299582, CNST_LIMB(0xba1f9a938041e100), CNST_LIMB(0x601c4205aebd9e47) }, + /* 247 */ { 8, 0.1258120027502338, CNST_LIMB(0xc0435871d1110f41), CNST_LIMB(0x54ddc59756f05016) }, + /* 248 */ { 8, 0.1257198038592741, CNST_LIMB(0xc694446f01000000), CNST_LIMB(0x4a0648979c838c18) }, + /* 249 */ { 8, 0.1256281102107963, CNST_LIMB(0xcd137a5b57ac3ec1), CNST_LIMB(0x3f91b6e0bb3a053d) }, + /* 250 */ { 8, 0.1255369169267456, CNST_LIMB(0xd3c21bcecceda100), CNST_LIMB(0x357c299a88ea76a5) }, + /* 251 */ { 8, 0.1254462191960791, CNST_LIMB(0xdaa150410b788de1), CNST_LIMB(0x2bc1e517aecc56e3) }, + /* 252 */ { 8, 0.1253560122735751, CNST_LIMB(0xe1b24521be010000), CNST_LIMB(0x225f56ceb3da9f5d) }, + /* 253 */ { 8, 0.1252662914786691, CNST_LIMB(0xe8f62df12777c1a1), CNST_LIMB(0x1951136d53ad63ac) }, + /* 254 */ { 8, 0.1251770521943144, CNST_LIMB(0xf06e445906fc0100), CNST_LIMB(0x1093d504b3cd7d93) }, + /* 255 */ { 8, 0.1250882898658681, CNST_LIMB(0xf81bc845c81bf801), CNST_LIMB(0x824794d1ec1814f) }, + /* 256 */ { 8, 0.1250000000000000, 0x8 }, +}; +#endif /* 64bit */ diff --git a/mpn/perfsqr.h b/mpn/perfsqr.h new file mode 100644 index 00000000..e24a718b --- /dev/null +++ b/mpn/perfsqr.h @@ -0,0 +1,91 @@ +/* This file generated by gen-psqr.c - DO NOT EDIT. */ + +#if GMP_LIMB_BITS == 32 && GMP_NAIL_BITS == 0 +/* Non-zero bit indicates a quadratic residue mod 0x100. + This test identifies 82.81% as non-squares (212/256). */ +static const mp_limb_t +sq_res_0x100[8] = { + CNST_LIMB(0x2030213), + CNST_LIMB(0x2020212), + CNST_LIMB(0x2020213), + CNST_LIMB(0x2020212), + CNST_LIMB(0x2030212), + CNST_LIMB(0x2020212), + CNST_LIMB(0x2020212), + CNST_LIMB(0x2020212), +}; + +/* 2^24-1 = 3^2 * 5 * 7 * 13 * 17 ... */ +#define PERFSQR_MOD_BITS 25 + +/* This test identifies 95.66% as non-squares. */ +#define PERFSQR_MOD_TEST(up, usize) \ + do { \ + mp_limb_t r; \ + PERFSQR_MOD_34 (r, up, usize); \ + \ + /* 73.33% */ \ + PERFSQR_MOD_2 (r, CNST_LIMB(45), CNST_LIMB(0xfa4fa5), \ + CNST_LIMB(0x920), CNST_LIMB(0x1a442481)); \ + \ + /* 47.06% */ \ + PERFSQR_MOD_1 (r, CNST_LIMB(17), CNST_LIMB(0xf0f0f1), \ + CNST_LIMB(0x1a317)); \ + \ + /* 46.15% */ \ + PERFSQR_MOD_1 (r, CNST_LIMB(13), CNST_LIMB(0xec4ec5), \ + CNST_LIMB(0x9e5)); \ + \ + /* 42.86% */ \ + PERFSQR_MOD_1 (r, CNST_LIMB( 7), CNST_LIMB(0xdb6db7), \ + CNST_LIMB(0x69)); \ + } while (0) + +/* Grand total sq_res_0x100 and PERFSQR_MOD_TEST, 99.25% non-squares. */ + +/* helper for tests/mpz/t-perfsqr.c */ +#define PERFSQR_DIVISORS { 256, 45, 17, 13, 7, } +#endif /* 32bit */ + +#if GMP_LIMB_BITS == 64 && GMP_NAIL_BITS == 0 +/* Non-zero bit indicates a quadratic residue mod 0x100. + This test identifies 82.81% as non-squares (212/256). */ +static const mp_limb_t +sq_res_0x100[4] = { + CNST_LIMB(0x202021202030213), + CNST_LIMB(0x202021202020213), + CNST_LIMB(0x202021202030212), + CNST_LIMB(0x202021202020212), +}; + +/* 2^48-1 = 3^2 * 5 * 7 * 13 * 17 * 97 ... */ +#define PERFSQR_MOD_BITS 49 + +/* This test identifies 97.81% as non-squares. */ +#define PERFSQR_MOD_TEST(up, usize) \ + do { \ + mp_limb_t r; \ + PERFSQR_MOD_34 (r, up, usize); \ + \ + /* 69.23% */ \ + PERFSQR_MOD_2 (r, CNST_LIMB(91), CNST_LIMB(0xfd2fd2fd2fd3), \ + CNST_LIMB(0x2191240), CNST_LIMB(0x8850a206953820e1)); \ + \ + /* 68.24% */ \ + PERFSQR_MOD_2 (r, CNST_LIMB(85), CNST_LIMB(0xfcfcfcfcfcfd), \ + CNST_LIMB(0x82158), CNST_LIMB(0x10b48c4b4206a105)); \ + \ + /* 55.56% */ \ + PERFSQR_MOD_1 (r, CNST_LIMB( 9), CNST_LIMB(0xe38e38e38e39), \ + CNST_LIMB(0x93)); \ + \ + /* 49.48% */ \ + PERFSQR_MOD_2 (r, CNST_LIMB(97), CNST_LIMB(0xfd5c5f02a3a1), \ + CNST_LIMB(0x1eb628b47), CNST_LIMB(0x6067981b8b451b5f)); \ + } while (0) + +/* Grand total sq_res_0x100 and PERFSQR_MOD_TEST, 99.62% non-squares. */ + +/* helper for tests/mpz/t-perfsqr.c */ +#define PERFSQR_DIVISORS { 256, 91, 85, 9, 97, } +#endif /* 64bit */ diff --git a/mpz/fac_ui.h b/mpz/fac_ui.h new file mode 100644 index 00000000..a1b84cc0 --- /dev/null +++ b/mpz/fac_ui.h @@ -0,0 +1,29 @@ +/* This file is automatically generated by gen-fac_ui.c */ + +#if GMP_NUMB_BITS == 32 && GMP_LIMB_BITS == 32 +/* This table is 0!,1!,2!,3!,...,n! where n! has <= GMP_NUMB_BITS bits */ +#define ONE_LIMB_FACTORIAL_TABLE CNST_LIMB(0x1),CNST_LIMB(0x1),CNST_LIMB(0x2),CNST_LIMB(0x6),CNST_LIMB(0x18),CNST_LIMB(0x78),CNST_LIMB(0x2d0),CNST_LIMB(0x13b0),CNST_LIMB(0x9d80),CNST_LIMB(0x58980),CNST_LIMB(0x375f00),CNST_LIMB(0x2611500),CNST_LIMB(0x1c8cfc00) + +/* is 2^(GMP_LIMB_BITS+1)/exp(1) */ +#define FAC2OVERE CNST_LIMB(0xbc5c254b) + +/* FACMULn is largest odd x such that x*(x+2)*...*(x+2(n-1))<=2^GMP_NUMB_BITS-1 */ + +#define FACMUL2 CNST_LIMB(0xffff) +#define FACMUL3 CNST_LIMB(0x657) +#define FACMUL4 CNST_LIMB(0xfd) +#endif /* 32bit */ + +#if GMP_NUMB_BITS == 64 && GMP_LIMB_BITS == 64 +/* This table is 0!,1!,2!,3!,...,n! where n! has <= GMP_NUMB_BITS bits */ +#define ONE_LIMB_FACTORIAL_TABLE CNST_LIMB(0x1),CNST_LIMB(0x1),CNST_LIMB(0x2),CNST_LIMB(0x6),CNST_LIMB(0x18),CNST_LIMB(0x78),CNST_LIMB(0x2d0),CNST_LIMB(0x13b0),CNST_LIMB(0x9d80),CNST_LIMB(0x58980),CNST_LIMB(0x375f00),CNST_LIMB(0x2611500),CNST_LIMB(0x1c8cfc00),CNST_LIMB(0x17328cc00),CNST_LIMB(0x144c3b2800),CNST_LIMB(0x13077775800),CNST_LIMB(0x130777758000),CNST_LIMB(0x1437eeecd8000),CNST_LIMB(0x16beecca730000),CNST_LIMB(0x1b02b9306890000),CNST_LIMB(0x21c3677c82b40000) + +/* is 2^(GMP_LIMB_BITS+1)/exp(1) */ +#define FAC2OVERE CNST_LIMB(0xbc5c254b96be9524) + +/* FACMULn is largest odd x such that x*(x+2)*...*(x+2(n-1))<=2^GMP_NUMB_BITS-1 */ + +#define FACMUL2 CNST_LIMB(0xffffffff) +#define FACMUL3 CNST_LIMB(0x285143) +#define FACMUL4 CNST_LIMB(0xfffd) +#endif /* 64bit */