[Gmp-commit] /var/hg/gmp: 5 new changesets

mercurial at gmplib.org mercurial at gmplib.org
Sun Oct 18 06:00:44 UTC 2020


details:   /var/hg/gmp/rev/c58cf807b574
changeset: 18098:c58cf807b574
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sun Oct 18 07:33:16 2020 +0200
description:
mini-gmp/mini-gmp.c: Use mpn_scan1 instead of mpz_scan1.

details:   /var/hg/gmp/rev/f14ef4c0494e
changeset: 18099:f14ef4c0494e
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sun Oct 18 07:35:43 2020 +0200
description:
mini-gmp/mini-gmp.c (mpn_set_str_bits): Reduce bramches and writes.

details:   /var/hg/gmp/rev/1df36426b5eb
changeset: 18100:1df36426b5eb
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sun Oct 18 07:43:00 2020 +0200
description:
mini-gmp/mini-gmp.c (mpz_gcdext): Delay mpz_setbit (t0, ...).

details:   /var/hg/gmp/rev/24be67ddb288
changeset: 18101:24be67ddb288
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sun Oct 18 08:00:05 2020 +0200
description:
doc/gmp.texi (Number sequences): Removed redundant words. (spotted by TonyMcC)

details:   /var/hg/gmp/rev/69a98c5738e8
changeset: 18102:69a98c5738e8
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sun Oct 18 08:00:15 2020 +0200
description:
ChangeLog

diffstat:

 ChangeLog           |  13 +++++++++++++
 doc/gmp.texi        |   4 ++--
 mini-gmp/ChangeLog  |   6 ++++++
 mini-gmp/mini-gmp.c |  42 ++++++++++++++++++++----------------------
 4 files changed, 41 insertions(+), 24 deletions(-)

diffs (147 lines):

diff -r 6043e6980dc9 -r 69a98c5738e8 ChangeLog
--- a/ChangeLog	Sat Oct 17 13:18:05 2020 +0200
+++ b/ChangeLog	Sun Oct 18 08:00:15 2020 +0200
@@ -1,3 +1,16 @@
+2020-10-17 Marco Bodrato <bodrato at mail.dm.unipi.it>
+
+	* bootstrap.c (mpz_invert_2exp): Simplify.
+	* mpz/stronglucas.c (mpz_oddjacobi_ui): New helper function.
+
+2020-10-14 Marco Bodrato <bodrato at mail.dm.unipi.it>
+
+	* doc/gmp.texi (Number sequences): Remove redundancie. (spotted: TonyMcC)
+
+2020-10-06  Niels Möller  <nisse at lysator.liu.se>
+
+	* Makefile.am: Better support for make check-mini-gmp on wine or cygwin.
+
 2020-05-17 Marco Bodrato <bodrato at mail.dm.unipi.it>
 
 	* mpq/cmp.c: Avoid overflow on int even for huge sizes.
diff -r 6043e6980dc9 -r 69a98c5738e8 doc/gmp.texi
--- a/doc/gmp.texi	Sat Oct 17 13:18:05 2020 +0200
+++ b/doc/gmp.texi	Sun Oct 18 08:00:15 2020 +0200
@@ -14,7 +14,7 @@
 This manual describes how to install and use the GNU multiple precision
 arithmetic library, version @value{VERSION}.
 
-Copyright 1991, 1993-2016, 2018 Free Software Foundation, Inc.
+Copyright 1991, 1993-2016, 2018-2020 Free Software Foundation, Inc.
 
 Permission is granted to copy, distribute and/or modify this document under
 the terms of the GNU Free Documentation License, Version 1.3 or any later
@@ -2538,7 +2538,7 @@
 @cindex Number sequences
 Functions like @code{mpz_fac_ui}, @code{mpz_fib_ui} and @code{mpz_bin_uiui}
 are designed for calculating isolated values.  If a range of values is wanted
-it's probably best to call to get a starting point and iterate from there.
+it's probably best to get a starting point and iterate from there.
 
 @item Text Input/Output
 @cindex Text input/output
diff -r 6043e6980dc9 -r 69a98c5738e8 mini-gmp/ChangeLog
--- a/mini-gmp/ChangeLog	Sat Oct 17 13:18:05 2020 +0200
+++ b/mini-gmp/ChangeLog	Sun Oct 18 08:00:15 2020 +0200
@@ -1,3 +1,9 @@
+2020-10-18 Marco Bodrato <bodrato at mail.dm.unipi.it>
+
+	* mini-gmp.c: Use mpn_scan1 instead of mpz_scan1.
+	(mpn_set_str_bits): Reduce bramches and writes.
+	(mpz_gcdext): Delay mpz_setbit (t0, ...).
+
 2020-10-06  Niels Möller  <nisse at lysator.liu.se>
 
 	* tests/run-tests: Better support for make check on wine or cygwin.
diff -r 6043e6980dc9 -r 69a98c5738e8 mini-gmp/mini-gmp.c
--- a/mini-gmp/mini-gmp.c	Sat Oct 17 13:18:05 2020 +0200
+++ b/mini-gmp/mini-gmp.c	Sun Oct 18 08:00:15 2020 +0200
@@ -1331,29 +1331,26 @@
 		  unsigned bits)
 {
   mp_size_t rn;
-  size_t j;
+  mp_limb_t limb;
   unsigned shift;
 
-  for (j = sn, rn = 0, shift = 0; j-- > 0; )
+  for (limb = 0, rn = 0, shift = 0; sn-- > 0; )
     {
-      if (shift == 0)
+      limb |= (mp_limb_t) sp[sn] << shift;
+      shift += bits;
+      if (shift >= GMP_LIMB_BITS)
 	{
-	  rp[rn++] = sp[j];
-	  shift += bits;
-	}
-      else
-	{
-	  rp[rn-1] |= (mp_limb_t) sp[j] << shift;
-	  shift += bits;
-	  if (shift >= GMP_LIMB_BITS)
-	    {
-	      shift -= GMP_LIMB_BITS;
-	      if (shift > 0)
-		rp[rn++] = (mp_limb_t) sp[j] >> (bits - shift);
-	    }
+	  shift -= GMP_LIMB_BITS;
+	  rp[rn++] = limb;
+	  /* Next line is correct also if shift == 0,
+	     bits == 8, and mp_limb_t == unsigned char. */
+	  limb = (unsigned int) sp[sn] >> (bits - shift);
 	}
     }
-  rn = mpn_normalized_size (rp, rn);
+  if (limb != 0)
+    rp[rn++] = limb;
+  else
+    rn = mpn_normalized_size (rp, rn);
   return rn;
 }
 
@@ -2723,7 +2720,7 @@
 
   assert (r->_mp_size > 0);
   /* Count trailing zeros, equivalent to mpn_scan1, because we know that there is a 1 */
-  shift = mpn_common_scan (r->_mp_d[0], 0, r->_mp_d, 0, 0);
+  shift = mpn_scan1 (r->_mp_d, 0);
   mpz_tdiv_q_2exp (r, r, shift);
 
   return shift;
@@ -2871,7 +2868,6 @@
    * s0 = 0,    s1 = 2^vz
    */
 
-  mpz_setbit (t0, uz);
   mpz_tdiv_qr (t1, tu, tu, tv);
   mpz_mul_2exp (t1, t1, uz);
 
@@ -2882,8 +2878,7 @@
     {
       mp_bitcnt_t shift;
       shift = mpz_make_odd (tu);
-      mpz_mul_2exp (t0, t0, shift);
-      mpz_mul_2exp (s0, s0, shift);
+      mpz_setbit (t0, uz + shift);
       power += shift;
 
       for (;;)
@@ -2921,6 +2916,8 @@
 	  power += shift;
 	}
     }
+  else
+    mpz_setbit (t0, uz);
 
   /* Now tv = odd part of gcd, and -s0 and t0 are corresponding
      cofactors. */
@@ -3604,7 +3601,8 @@
   /* Find q and k, where q is odd and n = 1 + 2**k * q.  */
   mpz_abs (nm1, n);
   nm1->_mp_d[0] -= 1;
-  k = mpz_scan1 (nm1, 0);
+  /* Count trailing zeros, equivalent to mpn_scan1, because we know that there is a 1 */
+  k = mpn_scan1 (nm1->_mp_d, 0);
   mpz_tdiv_q_2exp (q, nm1, k);
 
   /* BPSW test */



More information about the gmp-commit mailing list