[Gmp-commit] /var/hg/gmp: more mp_bitcnt_t...

mercurial at gmplib.org mercurial at gmplib.org
Sat Jan 28 21:33:15 CET 2012


details:   /var/hg/gmp/rev/fbcd89f7a6ad
changeset: 14587:fbcd89f7a6ad
user:      Marc Glisse <marc.glisse at inria.fr>
date:      Sat Jan 28 21:33:12 2012 +0100
description:
more mp_bitcnt_t...

diffstat:

 ChangeLog    |   5 +++++
 doc/gmp.texi |   2 +-
 gmpxx.h      |  21 +++++++++++----------
 3 files changed, 17 insertions(+), 11 deletions(-)

diffs (99 lines):

diff -r 00d74c41fcf0 -r fbcd89f7a6ad ChangeLog
--- a/ChangeLog	Thu Jan 26 22:56:48 2012 +0100
+++ b/ChangeLog	Sat Jan 28 21:33:12 2012 +0100
@@ -1,3 +1,8 @@
+2012-01-28  Marc Glisse  <marc.glisse at inria.fr>
+
+	* doc/gmp.texi (gmp_randclass::get_z_bits): Use mp_bitcnt_t.
+	* gmpxx.h: Replace unsigned long with mp_bitcnt_t.
+
 2012-01-26 Marco Bodrato <bodrato at mail.dm.unipi.it>
 
 	* tests/mpz/t-fac_ui.c: Increase default test cases.
diff -r 00d74c41fcf0 -r fbcd89f7a6ad doc/gmp.texi
--- a/doc/gmp.texi	Thu Jan 26 22:56:48 2012 +0100
+++ b/doc/gmp.texi	Sat Jan 28 21:33:12 2012 +0100
@@ -6845,7 +6845,7 @@
 to choose a good seed.
 @end deftypefun
 
- at deftypefun mpz_class gmp_randclass::get_z_bits (unsigned long @var{bits})
+ at deftypefun mpz_class gmp_randclass::get_z_bits (mp_bitcnt_t @var{bits})
 @deftypefunx mpz_class gmp_randclass::get_z_bits (mpz_class @var{bits})
 Generate a random integer with a specified number of bits.
 @end deftypefun
diff -r 00d74c41fcf0 -r fbcd89f7a6ad gmpxx.h
--- a/gmpxx.h	Thu Jan 26 22:56:48 2012 +0100
+++ b/gmpxx.h	Sat Jan 28 21:33:12 2012 +0100
@@ -1223,7 +1223,7 @@
 
 struct __gmp_rand_function
 {
-  static void eval(mpz_ptr z, gmp_randstate_t s, unsigned long int l)
+  static void eval(mpz_ptr z, gmp_randstate_t s, mp_bitcnt_t l)
   { mpz_urandomb(z, s, l); }
   static void eval(mpz_ptr z, gmp_randstate_t s, mpz_srcptr w)
   { mpz_urandomm(z, s, w); }
@@ -3029,9 +3029,9 @@
 {
 private:
   __gmp_randstate_struct *state;
-  unsigned long int bits;
+  mp_bitcnt_t bits;
 public:
-  __gmp_expr(gmp_randstate_t s, unsigned long int l) : state(s), bits(l) { }
+  __gmp_expr(gmp_randstate_t s, mp_bitcnt_t l) : state(s), bits(l) { }
   void eval(mpz_ptr z) const { __gmp_rand_function::eval(z, state, bits); }
   mp_bitcnt_t get_prec() const { return mpf_get_default_prec(); }
 };
@@ -3054,9 +3054,9 @@
 {
 private:
   __gmp_randstate_struct *state;
-  unsigned long int bits;
+  mp_bitcnt_t bits;
 public:
-  __gmp_expr(gmp_randstate_t s, unsigned long int l) : state(s), bits(l) { }
+  __gmp_expr(gmp_randstate_t s, mp_bitcnt_t l) : state(s), bits(l) { }
   void eval(mpf_ptr f, mp_bitcnt_t prec) const
   { __gmp_rand_function::eval(f, state, (bits>0) ? get_prec() : prec); }
   mp_bitcnt_t get_prec() const
@@ -3070,8 +3070,8 @@
 
 extern "C" {
   typedef void __gmp_randinit_default_t (gmp_randstate_t);
-  typedef void __gmp_randinit_lc_2exp_t (gmp_randstate_t, mpz_srcptr, unsigned long int, unsigned long int);
-  typedef int __gmp_randinit_lc_2exp_size_t (gmp_randstate_t, unsigned long int);
+  typedef void __gmp_randinit_lc_2exp_t (gmp_randstate_t, mpz_srcptr, unsigned long int, mp_bitcnt_t);
+  typedef int __gmp_randinit_lc_2exp_size_t (gmp_randstate_t, mp_bitcnt_t);
 }
 
 class gmp_randclass
@@ -3100,12 +3100,12 @@
 
   // gmp_randinit_lc_2exp
   gmp_randclass(__gmp_randinit_lc_2exp_t* f,
-		mpz_class z, unsigned long int l1, unsigned long int l2)
+		mpz_class z, unsigned long int l1, mp_bitcnt_t l2)
   { f(state, z.get_mpz_t(), l1, l2); }
 
   // gmp_randinit_lc_2exp_size
   gmp_randclass(__gmp_randinit_lc_2exp_size_t* f,
-		unsigned long int size)
+		mp_bitcnt_t size)
   {
     if (f (state, size) == 0)
       throw std::length_error ("gmp_randinit_lc_2exp_size");
@@ -3119,10 +3119,11 @@
   void seed(const mpz_class &z) { gmp_randseed(state, z.get_mpz_t()); }
 
   // get random number
-  __gmp_expr<mpz_t, __gmp_urandomb_value> get_z_bits(unsigned long int l)
+  __gmp_expr<mpz_t, __gmp_urandomb_value> get_z_bits(mp_bitcnt_t l)
   { return __gmp_expr<mpz_t, __gmp_urandomb_value>(state, l); }
   __gmp_expr<mpz_t, __gmp_urandomb_value> get_z_bits(const mpz_class &z)
   { return get_z_bits(z.get_ui()); }
+  // FIXME: z.get_bitcnt_t() ?
 
   __gmp_expr<mpz_t, __gmp_urandomm_value> get_z_range(const mpz_class &z)
   { return __gmp_expr<mpz_t, __gmp_urandomm_value>(state, z); }


More information about the gmp-commit mailing list