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

mercurial at gmplib.org mercurial at gmplib.org
Sat Feb 26 09:49:41 CET 2022


details:   /var/hg/gmp/rev/bad5f1c64385
changeset: 18314:bad5f1c64385
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sat Feb 26 09:44:22 2022 +0100
description:
mpn/generic/strongfibo.c: revert last change

details:   /var/hg/gmp/rev/cf303403e643
changeset: 18315:cf303403e643
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sat Feb 26 09:46:52 2022 +0100
description:
tests/mpn/t-sqrmod_bknp1.c: Better coverage

diffstat:

 mpn/generic/strongfibo.c   |   3 +--
 tests/mpn/t-sqrmod_bknp1.c |  30 +++++++++++++++++++++++-------
 2 files changed, 24 insertions(+), 9 deletions(-)

diffs (55 lines):

diff -r 5d04c39fb073 -r cf303403e643 mpn/generic/strongfibo.c
--- a/mpn/generic/strongfibo.c	Mon Feb 21 23:59:46 2022 +0100
+++ b/mpn/generic/strongfibo.c	Sat Feb 26 09:46:52 2022 +0100
@@ -38,8 +38,7 @@
 #include "gmp-impl.h"
 
 
-#if HAVE_NATIVE_mpn_rsblsh1_n || HAVE_NATIVE_mpn_sublsh1_n
-#else
+#if ! HAVE_NATIVE_mpn_rsblsh1_n && ! HAVE_NATIVE_mpn_sublsh1_n
 /* Stores |{ap,n}-{bp,n}| in {rp,n},
    returns the sign of {ap,n}-{bp,n}. */
 static int
diff -r 5d04c39fb073 -r cf303403e643 tests/mpn/t-sqrmod_bknp1.c
--- a/tests/mpn/t-sqrmod_bknp1.c	Mon Feb 21 23:59:46 2022 +0100
+++ b/tests/mpn/t-sqrmod_bknp1.c	Sat Feb 26 09:46:52 2022 +0100
@@ -130,15 +130,31 @@
 	+ gmp_urandomm_ui (rands, SIZE_LOG + 1 - size_min);
 
       k = supported_k[test % numberof (supported_k)];
-      n = MIN_N
-	+ gmp_urandomm_ui (rands, (1L << size_range) + 1 - MIN_N);
-      rn = k * n;
-      if ((GMP_NUMB_MAX % k != 0) && (rn % 3 == 0))
-	n = rn / (k = 3);
+      if (test < numberof (supported_k))
+	{
+	  n = 1;
+	  rn = k;
+	  ap [rn] = 0;
+	  mp_limb_t x = GMP_NUMB_MAX / k + 1;
+	  ap [0] = x;
+	  for (int i = 1; i < k; i += 2)
+	    {
+	      ap [i] = - x;
+	      ap [i + 1] = x - 1;
+	    }
+	}
+      else
+	{
+	  n = MIN_N
+	    + gmp_urandomm_ui (rands, (1L << size_range) + 1 - MIN_N);
+	  rn = k * n;
+	  if ((GMP_NUMB_MAX % k != 0) && (rn % 3 == 0))
+	    n = rn / (k = 3);
 
-      mpn_random2 (ap, rn + 1);
+	  mpn_random2 (ap, rn + 1);
 
-      ap [rn] &= 1;
+	  ap [rn] &= 1;
+	}
 
       mpn_random2 (pp-1, rn + 3);
       p_before = pp[-1];


More information about the gmp-commit mailing list