[Gmp-commit] /home/hgfiles/gmp: Change all bit counts for bignums to use mp_b...

mercurial at gmplib.org mercurial at gmplib.org
Sun Dec 20 23:55:04 CET 2009


details:   /home/hgfiles/gmp/rev/8933a257b0c7
changeset: 13148:8933a257b0c7
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Sun Dec 20 23:54:57 2009 +0100
description:
Change all bit counts for bignums to use mp_bitcnt_t.  Update documentation.

diffstat:

 ChangeLog              |    2 +
 doc/gmp.texi           |  141 +++++++++++++++++++++++++-----------------------
 gmp-h.in               |   80 +++++++++++++-------------
 gmp-impl.h             |    2 +-
 gmpxx.h                |   86 ++++++++++++++--------------
 mpf/div_2exp.c         |    2 +-
 mpf/eq.c               |    2 +-
 mpf/get_dfl_prec.c     |    2 +-
 mpf/get_prc.c          |    2 +-
 mpf/init2.c            |    2 +-
 mpf/mul_2exp.c         |    2 +-
 mpf/set_dfl_prec.c     |    2 +-
 mpf/set_prc.c          |    2 +-
 mpf/set_prc_raw.c      |    2 +-
 mpf/urandomb.c         |    2 +-
 mpn/generic/get_str.c  |    6 +-
 mpn/generic/popham.c   |    4 +-
 mpn/generic/powlo.c    |   28 +++++----
 mpn/generic/powm.c     |    2 +-
 mpn/generic/powm_sec.c |    2 +-
 mpn/generic/random2.c  |    6 +-
 mpn/generic/scan0.c    |    5 +-
 mpn/generic/scan1.c    |    5 +-
 mpq/cmp.c              |    2 +-
 mpq/md_2exp.c          |    6 +-
 mpz/cfdiv_q_2exp.c     |    8 +-
 mpz/cfdiv_r_2exp.c     |    8 +-
 mpz/clrbit.c           |    2 +-
 mpz/combit.c           |    2 +-
 mpz/cong_2exp.c        |    5 +-
 mpz/divexact.c         |    2 +-
 mpz/divis_2exp.c       |    5 +-
 mpz/hamdist.c          |   10 +-
 mpz/init2.c            |    2 +-
 mpz/mul_2exp.c         |    2 +-
 mpz/n_pow_ui.c         |    2 +-
 mpz/nextprime.c        |    2 +-
 mpz/realloc2.c         |    2 +-
 mpz/remove.c           |    6 +-
 mpz/rrandomb.c         |    8 +-
 mpz/scan0.c            |   10 +-
 mpz/scan1.c            |   10 +-
 mpz/setbit.c           |    2 +-
 mpz/tdiv_q_2exp.c      |    2 +-
 mpz/tdiv_r_2exp.c      |    2 +-
 mpz/tstbit.c           |    4 +-
 mpz/urandomb.c         |    2 +-
 randlc2s.c             |    2 +-
 randlc2x.c             |    2 +-
 49 files changed, 254 insertions(+), 245 deletions(-)

diffs (truncated from 1871 to 300 lines):

diff -r 6e09fac92fc2 -r 8933a257b0c7 ChangeLog
--- a/ChangeLog	Sun Dec 20 23:13:41 2009 +0100
+++ b/ChangeLog	Sun Dec 20 23:54:57 2009 +0100
@@ -1,5 +1,7 @@
 2009-12-20  Torbjorn Granlund  <tege at gmplib.org>
 
+	* Change all bit counts for bignums to use mp_bitcnt_t.
+
 	* mpn/generic/bdivmod.c: File removed.  All references purged.
 
 	* mpn/generic/mul_fft.c (mpn_mul_fft_full): Disable.
diff -r 6e09fac92fc2 -r 8933a257b0c7 doc/gmp.texi
--- a/doc/gmp.texi	Sun Dec 20 23:13:41 2009 +0100
+++ b/doc/gmp.texi	Sun Dec 20 23:54:57 2009 +0100
@@ -1933,9 +1933,15 @@
 limb is 32 or 64 bits.  The C data type for a limb is @code{mp_limb_t}.
 
 @tindex @code{mp_size_t}
-Counts of limbs are represented in the C type @code{mp_size_t}.  Currently
-this is normally a @code{long}, but on some systems it's an @code{int} for
-efficiency.
+Counts of limbs of a multi-precision number represented in the C type
+ at code{mp_size_t}.  Currently this is normally a @code{long}, but on some
+systems it's an @code{int} for efficiency, and on some systems it will be
+ at code{long long} in the future.
+
+ at tindex @code{mp_bitcnt_t}
+Counts of bits of a multi-precision number are represented in the C type
+ at code{mp_bitcnt_t}.  Currently this is always an @code{unsigned long}, but on
+some systems it will be an @code{unsigned long long} in the future .
 
 @cindex Random state
 @tindex @code{gmp_randstate_t}
@@ -1946,7 +1952,7 @@
 gmp_randstate_t rstate;
 @end example
 
-Also, in general @code{unsigned long} is used for bit counts and ranges, and
+Also, in general @code{mp_bitcnt_t} is used for bit counts and ranges, and
 @code{size_t} is used for byte or character counts.
 
 
@@ -2997,7 +3003,7 @@
 values to 0.
 @end deftypefun
 
- at deftypefun void mpz_init2 (mpz_t @var{x}, unsigned long @var{n})
+ at deftypefun void mpz_init2 (mpz_t @var{x}, mp_bitcnt_t @var{n})
 Initialize @var{x}, with space for @var{n}-bit numbers, and set its value to 0.
 Calling this function instead of @code{mpz_init} or @code{mpz_inits} is never
 necessary; reallocation is handled automatically by GMP when needed.
@@ -3017,7 +3023,7 @@
 Free the space occupied by a NULL-terminated list of @code{mpz_t} variables.
 @end deftypefun
 
- at deftypefun void mpz_realloc2 (mpz_t @var{x}, unsigned long @var{n})
+ at deftypefun void mpz_realloc2 (mpz_t @var{x}, mp_bitcnt_t @var{n})
 Change the space allocated for @var{x} to @var{n} bits.  The value in @var{x}
 is preserved if it fits, or is set to 0 if not.
 
@@ -3235,7 +3241,7 @@
 Set @var{rop} to @math{@var{rop} - @var{op1} @GMPtimes{} @var{op2}}.
 @end deftypefun
 
- at deftypefun void mpz_mul_2exp (mpz_t @var{rop}, mpz_t @var{op1}, unsigned long int @var{op2})
+ at deftypefun void mpz_mul_2exp (mpz_t @var{rop}, mpz_t @var{op1}, mp_bitcnt_t @var{op2})
 @cindex Bit shift left
 Set @var{rop} to @m{@var{op1} \times 2^{op2}, @var{op1} times 2 raised to
 @var{op2}}.  This operation can also be defined as a left shift by @var{op2}
@@ -3276,8 +3282,8 @@
 @deftypefunx {unsigned long int} mpz_cdiv_qr_ui (mpz_t @var{q}, mpz_t @var{r}, @w{mpz_t @var{n}}, @w{unsigned long int @var{d}})
 @deftypefunx {unsigned long int} mpz_cdiv_ui (mpz_t @var{n}, @w{unsigned long int @var{d}})
 @maybepagebreak
- at deftypefunx void mpz_cdiv_q_2exp (mpz_t @var{q}, mpz_t @var{n}, @w{unsigned long int @var{b}})
- at deftypefunx void mpz_cdiv_r_2exp (mpz_t @var{r}, mpz_t @var{n}, @w{unsigned long int @var{b}})
+ at deftypefunx void mpz_cdiv_q_2exp (mpz_t @var{q}, mpz_t @var{n}, @w{mp_bitcnt_t @var{b}})
+ at deftypefunx void mpz_cdiv_r_2exp (mpz_t @var{r}, mpz_t @var{n}, @w{mp_bitcnt_t @var{b}})
 @end deftypefun
 
 @deftypefun void mpz_fdiv_q (mpz_t @var{q}, mpz_t @var{n}, mpz_t @var{d})
@@ -3289,8 +3295,8 @@
 @deftypefunx {unsigned long int} mpz_fdiv_qr_ui (mpz_t @var{q}, mpz_t @var{r}, @w{mpz_t @var{n}}, @w{unsigned long int @var{d}})
 @deftypefunx {unsigned long int} mpz_fdiv_ui (mpz_t @var{n}, @w{unsigned long int @var{d}})
 @maybepagebreak
- at deftypefunx void mpz_fdiv_q_2exp (mpz_t @var{q}, mpz_t @var{n}, @w{unsigned long int @var{b}})
- at deftypefunx void mpz_fdiv_r_2exp (mpz_t @var{r}, mpz_t @var{n}, @w{unsigned long int @var{b}})
+ at deftypefunx void mpz_fdiv_q_2exp (mpz_t @var{q}, mpz_t @var{n}, @w{mp_bitcnt_t @var{b}})
+ at deftypefunx void mpz_fdiv_r_2exp (mpz_t @var{r}, mpz_t @var{n}, @w{mp_bitcnt_t @var{b}})
 @end deftypefun
 
 @deftypefun void mpz_tdiv_q (mpz_t @var{q}, mpz_t @var{n}, mpz_t @var{d})
@@ -3302,8 +3308,8 @@
 @deftypefunx {unsigned long int} mpz_tdiv_qr_ui (mpz_t @var{q}, mpz_t @var{r}, @w{mpz_t @var{n}}, @w{unsigned long int @var{d}})
 @deftypefunx {unsigned long int} mpz_tdiv_ui (mpz_t @var{n}, @w{unsigned long int @var{d}})
 @maybepagebreak
- at deftypefunx void mpz_tdiv_q_2exp (mpz_t @var{q}, mpz_t @var{n}, @w{unsigned long int @var{b}})
- at deftypefunx void mpz_tdiv_r_2exp (mpz_t @var{r}, mpz_t @var{n}, @w{unsigned long int @var{b}})
+ at deftypefunx void mpz_tdiv_q_2exp (mpz_t @var{q}, mpz_t @var{n}, @w{mp_bitcnt_t @var{b}})
+ at deftypefunx void mpz_tdiv_r_2exp (mpz_t @var{r}, mpz_t @var{n}, @w{mp_bitcnt_t @var{b}})
 @cindex Bit shift right
 
 @sp 1
@@ -3374,7 +3380,7 @@
 
 @deftypefun int mpz_divisible_p (mpz_t @var{n}, mpz_t @var{d})
 @deftypefunx int mpz_divisible_ui_p (mpz_t @var{n}, unsigned long int @var{d})
- at deftypefunx int mpz_divisible_2exp_p (mpz_t @var{n}, unsigned long int @var{b})
+ at deftypefunx int mpz_divisible_2exp_p (mpz_t @var{n}, mp_bitcnt_t @var{b})
 @cindex Divisibility functions
 Return non-zero if @var{n} is exactly divisible by @var{d}, or in the case of
 @code{mpz_divisible_2exp_p} by @m{2^b,2^@var{b}}.
@@ -3387,7 +3393,7 @@
 
 @deftypefun int mpz_congruent_p (mpz_t @var{n}, mpz_t @var{c}, mpz_t @var{d})
 @deftypefunx int mpz_congruent_ui_p (mpz_t @var{n}, unsigned long int @var{c}, unsigned long int @var{d})
- at deftypefunx int mpz_congruent_2exp_p (mpz_t @var{n}, mpz_t @var{c}, unsigned long int @var{b})
+ at deftypefunx int mpz_congruent_2exp_p (mpz_t @var{n}, mpz_t @var{c}, mp_bitcnt_t @var{b})
 @cindex Divisibility functions
 @cindex Congruence functions
 Return non-zero if @var{n} is congruent to @var{c} modulo @var{d}, or in the
@@ -3609,7 +3615,7 @@
 @file{demos/qcn.c} which uses @code{mpz_kronecker_ui}.
 @end deftypefun
 
- at deftypefun {unsigned long int} mpz_remove (mpz_t @var{rop}, mpz_t @var{op}, mpz_t @var{f})
+ at deftypefun {mp_bitcnt_t} mpz_remove (mpz_t @var{rop}, mpz_t @var{op}, mpz_t @var{f})
 @cindex Remove factor functions
 @cindex Factor removal functions
 Remove all occurrences of the factor @var{f} from @var{op} and store the
@@ -3735,24 +3741,23 @@
 Set @var{rop} to the one's complement of @var{op}.
 @end deftypefun
 
- at deftypefun {unsigned long int} mpz_popcount (mpz_t @var{op})
-If @math{@var{op}@ge{}0}, return the population count of @var{op}, which is
-the number of 1 bits in the binary representation.  If @math{@var{op}<0}, the
-number of 1s is infinite, and the return value is @var{ULONG_MAX}, the largest
-possible @code{unsigned long}.
- at end deftypefun
-
- at deftypefun {unsigned long int} mpz_hamdist (mpz_t @var{op1}, mpz_t @var{op2})
-If @var{op1} and @var{op2} are both @math{@ge{}0} or both @math{<0}, return
-the hamming distance between the two operands, which is the number of bit
-positions where @var{op1} and @var{op2} have different bit values.  If one
-operand is @math{@ge{}0} and the other @math{<0} then the number of bits
-different is infinite, and the return value is @var{ULONG_MAX}, the largest
-possible @code{unsigned long}.
- at end deftypefun
-
- at deftypefun {unsigned long int} mpz_scan0 (mpz_t @var{op}, unsigned long int @var{starting_bit})
- at deftypefunx {unsigned long int} mpz_scan1 (mpz_t @var{op}, unsigned long int @var{starting_bit})
+ at deftypefun {mp_bitcnt_t} mpz_popcount (mpz_t @var{op})
+If @math{@var{op}@ge{}0}, return the population count of @var{op}, which is the
+number of 1 bits in the binary representation.  If @math{@var{op}<0}, the
+number of 1s is infinite, and the return value is the largest possible
+ at code{mp_bitcnt_t}.
+ at end deftypefun
+
+ at deftypefun {mp_bitcnt_t} mpz_hamdist (mpz_t @var{op1}, mpz_t @var{op2})
+If @var{op1} and @var{op2} are both @math{@ge{}0} or both @math{<0}, return the
+hamming distance between the two operands, which is the number of bit positions
+where @var{op1} and @var{op2} have different bit values.  If one operand is
+ at math{@ge{}0} and the other @math{<0} then the number of bits different is
+infinite, and the return value is the largest possible @code{mp_bitcnt_t}.
+ at end deftypefun
+
+ at deftypefun {mp_bitcnt_t} mpz_scan0 (mpz_t @var{op}, mp_bitcnt_t @var{starting_bit})
+ at deftypefunx {mp_bitcnt_t} mpz_scan1 (mpz_t @var{op}, mp_bitcnt_t @var{starting_bit})
 @cindex Bit scanning functions
 @cindex Scan bit functions
 Scan @var{op}, starting from bit @var{starting_bit}, towards more significant
@@ -3762,24 +3767,24 @@
 If the bit at @var{starting_bit} is already what's sought, then
 @var{starting_bit} is returned.
 
-If there's no bit found, then @var{ULONG_MAX} is returned.  This will happen
-in @code{mpz_scan0} past the end of a negative number, or @code{mpz_scan1}
-past the end of a nonnegative number.
- at end deftypefun
-
- at deftypefun void mpz_setbit (mpz_t @var{rop}, unsigned long int @var{bit_index})
+If there's no bit found, then the largest possible @code{mp_bitcnt_t} is
+returned.  This will happen in @code{mpz_scan0} past the end of a negative
+number, or @code{mpz_scan1} past the end of a nonnegative number.
+ at end deftypefun
+
+ at deftypefun void mpz_setbit (mpz_t @var{rop}, mp_bitcnt_t @var{bit_index})
 Set bit @var{bit_index} in @var{rop}.
 @end deftypefun
 
- at deftypefun void mpz_clrbit (mpz_t @var{rop}, unsigned long int @var{bit_index})
+ at deftypefun void mpz_clrbit (mpz_t @var{rop}, mp_bitcnt_t @var{bit_index})
 Clear bit @var{bit_index} in @var{rop}.
 @end deftypefun
 
- at deftypefun void mpz_combit (mpz_t @var{rop}, unsigned long int @var{bit_index})
+ at deftypefun void mpz_combit (mpz_t @var{rop}, mp_bitcnt_t @var{bit_index})
 Complement bit @var{bit_index} in @var{rop}.
 @end deftypefun
 
- at deftypefun int mpz_tstbit (mpz_t @var{op}, unsigned long int @var{bit_index})
+ at deftypefun int mpz_tstbit (mpz_t @var{op}, mp_bitcnt_t @var{bit_index})
 Test bit @var{bit_index} in @var{op} and return 0 or 1 accordingly.
 @end deftypefun
 
@@ -3866,7 +3871,7 @@
 Functions} for more information on how to use and not to use random
 number functions.
 
- at deftypefun void mpz_urandomb (mpz_t @var{rop}, gmp_randstate_t @var{state}, unsigned long int @var{n})
+ at deftypefun void mpz_urandomb (mpz_t @var{rop}, gmp_randstate_t @var{state}, mp_bitcnt_t @var{n})
 Generate a uniformly distributed random integer in the range 0 to @m{2^n-1,
 2^@var{n}@minus{}1}, inclusive.
 
@@ -3884,7 +3889,7 @@
 before invoking this function.
 @end deftypefun
 
- at deftypefun void mpz_rrandomb (mpz_t @var{rop}, gmp_randstate_t @var{state}, unsigned long int @var{n})
+ at deftypefun void mpz_rrandomb (mpz_t @var{rop}, gmp_randstate_t @var{state}, mp_bitcnt_t @var{n})
 Generate a random integer with long strings of zeros and ones in the
 binary representation.  Useful for testing functions and algorithms,
 since this kind of random numbers have proven to be more likely to
@@ -4302,7 +4307,7 @@
 Set @var{product} to @math{@var{multiplier} @GMPtimes{} @var{multiplicand}}.
 @end deftypefun
 
- at deftypefun void mpq_mul_2exp (mpq_t @var{rop}, mpq_t @var{op1}, unsigned long int @var{op2})
+ at deftypefun void mpq_mul_2exp (mpq_t @var{rop}, mpq_t @var{op1}, mp_bitcnt_t @var{op2})
 Set @var{rop} to @m{@var{op1} \times 2^{op2}, @var{op1} times 2 raised to
 @var{op2}}.
 @end deftypefun
@@ -4312,7 +4317,7 @@
 Set @var{quotient} to @var{dividend}/@var{divisor}.
 @end deftypefun
 
- at deftypefun void mpq_div_2exp (mpq_t @var{rop}, mpq_t @var{op1}, unsigned long int @var{op2})
+ at deftypefun void mpq_div_2exp (mpq_t @var{rop}, mpq_t @var{op1}, mp_bitcnt_t @var{op2})
 Set @var{rop} to @m{@var{op1}/2^{op2}, @var{op1} divided by 2 raised to
 @var{op2}}.
 @end deftypefun
@@ -4524,13 +4529,13 @@
 @cindex Float initialization functions
 @cindex Initialization functions
 
- at deftypefun void mpf_set_default_prec (unsigned long int @var{prec})
+ at deftypefun void mpf_set_default_prec (mp_bitcnt_t @var{prec})
 Set the default precision to be @strong{at least} @var{prec} bits.  All
 subsequent calls to @code{mpf_init} will use this precision, but previously
 initialized variables are unaffected.
 @end deftypefun
 
- at deftypefun {unsigned long int} mpf_get_default_prec (void)
+ at deftypefun {mp_bitcnt_t} mpf_get_default_prec (void)
 Return the default precision actually used.
 @end deftypefun
 
@@ -4545,7 +4550,7 @@
 established by a call to @code{mpf_set_default_prec}.
 @end deftypefun
 
- at deftypefun void mpf_init2 (mpf_t @var{x}, unsigned long int @var{prec})
+ at deftypefun void mpf_init2 (mpf_t @var{x}, mp_bitcnt_t @var{prec})
 Initialize @var{x} to 0 and set its precision to be @strong{at least}
 @var{prec} bits.  Normally, a variable should be initialized once only or at
 least be cleared, using @code{mpf_clear}, between initializations.
@@ -4586,11 +4591,11 @@
 iterative algorithms like Newton-Raphson, making the computation precision
 closely match the actual accurate part of the numbers.
 
- at deftypefun {unsigned long int} mpf_get_prec (mpf_t @var{op})
+ at deftypefun {mp_bitcnt_t} mpf_get_prec (mpf_t @var{op})
 Return the current precision of @var{op}, in bits.
 @end deftypefun
 
- at deftypefun void mpf_set_prec (mpf_t @var{rop}, unsigned long int @var{prec})
+ at deftypefun void mpf_set_prec (mpf_t @var{rop}, mp_bitcnt_t @var{prec})
 Set the precision of @var{rop} to be @strong{at least} @var{prec} bits.  The
 value in @var{rop} will be truncated to the new precision.
 
@@ -4598,7 +4603,7 @@
 a tight loop.
 @end deftypefun
 
- at deftypefun void mpf_set_prec_raw (mpf_t @var{rop}, unsigned long int @var{prec})
+ at deftypefun void mpf_set_prec_raw (mpf_t @var{rop}, mp_bitcnt_t @var{prec})
 Set the precision of @var{rop} to be @strong{at least} @var{prec} bits,
 without changing the memory allocated.
 
@@ -4851,12 +4856,12 @@
 Set @var{rop} to the absolute value of @var{op}.
 @end deftypefun
 
- at deftypefun void mpf_mul_2exp (mpf_t @var{rop}, mpf_t @var{op1}, unsigned long int @var{op2})
+ at deftypefun void mpf_mul_2exp (mpf_t @var{rop}, mpf_t @var{op1}, mp_bitcnt_t @var{op2})
 Set @var{rop} to @m{@var{op1} \times 2^{op2}, @var{op1} times 2 raised to
 @var{op2}}.
 @end deftypefun
 
- at deftypefun void mpf_div_2exp (mpf_t @var{rop}, mpf_t @var{op1}, unsigned long int @var{op2})


More information about the gmp-commit mailing list