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

mercurial at gmplib.org mercurial at gmplib.org
Wed Mar 11 20:21:49 UTC 2020


details:   /var/hg/gmp/rev/0440482ab57c
changeset: 18051:0440482ab57c
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Wed Mar 11 21:03:12 2020 +0100
description:
mpn/generic/mul_fft.c (mpn_fft_mul_modF_K): Fully handle carry propagation in basecase multiplication

details:   /var/hg/gmp/rev/883419c85dae
changeset: 18052:883419c85dae
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Wed Mar 11 21:04:07 2020 +0100
description:
tests/mpz/t-bin.c: Use divexact

details:   /var/hg/gmp/rev/766a0d7bd89e
changeset: 18053:766a0d7bd89e
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Wed Mar 11 21:20:57 2020 +0100
description:
ChangeLog

diffstat:

 ChangeLog             |  11 +++++++++++
 mpn/generic/mul_fft.c |   9 ++++++---
 mpz/bin_ui.c          |   3 ++-
 mpz/cmp.c             |   4 ++--
 mpz/cmpabs.c          |   4 ++--
 tests/mpz/t-bin.c     |  14 +++++++-------
 6 files changed, 30 insertions(+), 15 deletions(-)

diffs (144 lines):

diff -r d302798cd0a2 -r 766a0d7bd89e ChangeLog
--- a/ChangeLog	Mon Mar 09 17:01:17 2020 +0100
+++ b/ChangeLog	Wed Mar 11 21:20:57 2020 +0100
@@ -1,3 +1,14 @@
+2020-03-10 Marco Bodrato <bodrato at mail.dm.unipi.it>
+
+	* mpn/generic/mulmod_bnm1.c (mpn_bc_mulmod_bnp1):
+	Simplify special cases.
+	* mpz/bin_ui.c (rek_raising_fac4): Reduce allocations.
+	(mpz_bin_ui): Siplify special cases.
+	* tests/mpz/t-bin.c: Use divexact.
+
+	* mpn/generic/mul_fft.c (mpn_fft_mul_modF_K):
+	Fully handle carry propagation in basecase multiplication.
+
 2020-02-12 Marco Bodrato <bodrato at mail.dm.unipi.it>
 
 	* mpz/cmp.c: Avoid overflow on int even for huge sizes.
diff -r d302798cd0a2 -r 766a0d7bd89e mpn/generic/mul_fft.c
--- a/mpn/generic/mul_fft.c	Mon Mar 09 17:01:17 2020 +0100
+++ b/mpn/generic/mul_fft.c	Wed Mar 11 21:20:57 2020 +0100
@@ -6,7 +6,7 @@
    SAFE TO REACH THEM THROUGH DOCUMENTED INTERFACES.  IN FACT, IT IS ALMOST
    GUARANTEED THAT THEY WILL CHANGE OR DISAPPEAR IN A FUTURE GNU MP RELEASE.
 
-Copyright 1998-2010, 2012, 2013, 2018 Free Software Foundation, Inc.
+Copyright 1998-2010, 2012, 2013, 2018, 2020 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -553,9 +553,12 @@
 	    cc += mpn_add_n (tpn, tpn, a, n) + a[n];
 	  if (cc != 0)
 	    {
-	      /* FIXME: use MPN_INCR_U here, since carry is not expected.  */
 	      cc = mpn_add_1 (tp, tp, n2, cc);
-	      ASSERT (cc == 0);
+	      /* If mpn_add_1 give a carry (cc != 0),
+		 the result (tp) is at most GMP_NUMB_MAX - 1,
+		 so the following addition can't overflow.
+	      */
+	      tp[0] += cc;
 	    }
 	  a[n] = mpn_sub_n (a, tp, tpn, n) && mpn_add_1 (a, a, n, CNST_LIMB(1));
 	}
diff -r d302798cd0a2 -r 766a0d7bd89e mpz/bin_ui.c
--- a/mpz/bin_ui.c	Mon Mar 09 17:01:17 2020 +0100
+++ b/mpz/bin_ui.c	Wed Mar 11 21:20:57 2020 +0100
@@ -1,6 +1,7 @@
 /* mpz_bin_ui(RESULT, N, K) -- Set RESULT to N over K.
 
-Copyright 1998-2002, 2012, 2013, 2015, 2017-2018 Free Software Foundation, Inc.
+Copyright 1998-2002, 2012, 2013, 2015, 2017-2018, 2020 Free Software
+Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
diff -r d302798cd0a2 -r 766a0d7bd89e mpz/cmp.c
--- a/mpz/cmp.c	Mon Mar 09 17:01:17 2020 +0100
+++ b/mpz/cmp.c	Wed Mar 11 21:20:57 2020 +0100
@@ -1,8 +1,8 @@
 /* mpz_cmp(u,v) -- Compare U, V.  Return positive, zero, or negative
    based on if U > V, U == V, or U < V.
 
-Copyright 1991, 1993, 1994, 1996, 2001, 2002, 2011 Free Software Foundation,
-Inc.
+Copyright 1991, 1993, 1994, 1996, 2001, 2002, 2011, 2020 Free Software
+Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
diff -r d302798cd0a2 -r 766a0d7bd89e mpz/cmpabs.c
--- a/mpz/cmpabs.c	Mon Mar 09 17:01:17 2020 +0100
+++ b/mpz/cmpabs.c	Wed Mar 11 21:20:57 2020 +0100
@@ -1,8 +1,8 @@
 /* mpz_cmpabs(u,v) -- Compare U, V.  Return positive, zero, or negative
    based on if U > V, U == V, or U < V.
 
-Copyright 1991, 1993, 1994, 1996, 1997, 2000-2002 Free Software Foundation,
-Inc.
+Copyright 1991, 1993, 1994, 1996, 1997, 2000-2002, 2020 Free Software
+Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
diff -r d302798cd0a2 -r 766a0d7bd89e tests/mpz/t-bin.c
--- a/tests/mpz/t-bin.c	Mon Mar 09 17:01:17 2020 +0100
+++ b/tests/mpz/t-bin.c	Wed Mar 11 21:20:57 2020 +0100
@@ -1,6 +1,6 @@
 /* Exercise mpz_bin_ui and mpz_bin_uiui.
 
-Copyright 2000, 2001, 2010, 2012, 2018 Free Software Foundation, Inc.
+Copyright 2000, 2001, 2010, 2012, 2018, 2020 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library test suite.
 
@@ -184,13 +184,13 @@
 	{
 	  n++; k++;
 	  mpz_mul_ui (want, want, n);
-	  mpz_fdiv_q_ui (want, want, k);
+	  mpz_divexact_ui (want, want, k);
 	}
       for (i = r >> 3; i > 0; i--)
 	{
 	  n++;
 	  mpz_mul_ui (want, want, n);
-	  mpz_fdiv_q_ui (want, want, n - k);
+	  mpz_divexact_ui (want, want, n - k);
 	}
 
       mpz_set_ui (n_z, n);
@@ -213,14 +213,14 @@
 	  k++;
 	  mpz_add_ui (n_z, n_z, 1);
 	  mpz_mul (want, want, n_z);
-	  mpz_tdiv_q_ui (want, want, k);
+	  mpz_divexact_ui (want, want, k);
 	}
       for (i = r >> 3; i > 0; i--)
 	{
 	  mpz_add_ui (n_z, n_z, 1);
 	  mpz_mul (want, want, n_z);
 	  mpz_sub_ui (tmp, n_z, k);
-	  mpz_tdiv_q (want, want, tmp);
+	  mpz_divexact (want, want, tmp);
 	}
 
       try_mpz_bin_ui (want, n_z, k);
@@ -257,12 +257,12 @@
 	{
 	  mpz_mul_ui (want, want, n - k);
 	  ++k;
-	  mpz_tdiv_q_ui (want, want, k);
+	  mpz_divexact_ui (want, want, k);
 	}
       for (i = r >> 3; i > 0; i--)
 	{
 	  mpz_mul_ui (want, want, n - k);
-	  mpz_tdiv_q_ui (want, want, n);
+	  mpz_divexact_ui (want, want, n);
 	  --n;
 	}
 


More information about the gmp-commit mailing list