[Gmp-commit] /var/hg/gmp: 3 new changesets
mercurial at gmplib.org
mercurial at gmplib.org
Mon Dec 9 08:55:56 UTC 2019
details: /var/hg/gmp/rev/c29f74d4f396
changeset: 17991:c29f74d4f396
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Mon Dec 09 09:44:10 2019 +0100
description:
tests/mpz/t-powm.c: Randomised new test.
details: /var/hg/gmp/rev/2587578dd78d
changeset: 17992:2587578dd78d
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Mon Dec 09 09:54:55 2019 +0100
description:
ChangeLog
details: /var/hg/gmp/rev/505381b71d95
changeset: 17993:505381b71d95
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Mon Dec 09 09:55:16 2019 +0100
description:
Copyright year
diffstat:
ChangeLog | 7 +++++-
mini-gmp/ChangeLog | 4 +++
mpz/powm.c | 2 +-
tests/mpz/t-powm.c | 56 +++++++++++++++++++++++++++++------------------------
4 files changed, 42 insertions(+), 27 deletions(-)
diffs (130 lines):
diff -r 8fb9e39a9d04 -r 505381b71d95 ChangeLog
--- a/ChangeLog Sun Dec 08 21:58:59 2019 +0100
+++ b/ChangeLog Mon Dec 09 09:55:16 2019 +0100
@@ -1,3 +1,8 @@
+2019-12-08 Marco Bodrato <bodrato at mail.dm.unipi.it>
+
+ * mpz/powm.c: Full normalisation when e=1 & b<0.
+ * tests/mpz/t-powm.c: More tests for the e=1 case.
+
2019-11-24 Niels Möller <nisse at lysator.liu.se>
* mpn/generic/gcdext_1.c [USE_ZEROTAB]: Delete code variant for
@@ -17,7 +22,7 @@
2019-11-09 Marco Bodrato <bodrato at mail.dm.unipi.it>
- * tune/speed.c (routine_t): Add R flago to mpz_powm
+ * tune/speed.c (routine_t): Add R flag to mpz_powm
* tune/speed.h (SPEED_ROUTINE_MPZ_POWM): Use R flag as the base.
2019-10-02 Torbjörn Granlund <tg at gmplib.org>
diff -r 8fb9e39a9d04 -r 505381b71d95 mini-gmp/ChangeLog
--- a/mini-gmp/ChangeLog Sun Dec 08 21:58:59 2019 +0100
+++ b/mini-gmp/ChangeLog Mon Dec 09 09:55:16 2019 +0100
@@ -1,3 +1,7 @@
+2019-12-04 Marco Bodrato <bodrato at mail.dm.unipi.it>
+
+ * mini-gmp/mini-gmp.c (mpn_invert_3by2): Remove shortcuts.
+
2019-11-19 Marco Bodrato <bodrato at mail.dm.unipi.it>
* mini-gmp/mini-gmp.c (mpn_invert_3by2): Shortcut for short limbs.
diff -r 8fb9e39a9d04 -r 505381b71d95 mpz/powm.c
--- a/mpz/powm.c Sun Dec 08 21:58:59 2019 +0100
+++ b/mpz/powm.c Mon Dec 09 09:55:16 2019 +0100
@@ -3,7 +3,7 @@
Contributed to the GNU project by Torbjorn Granlund.
Copyright 1991, 1993, 1994, 1996, 1997, 2000-2002, 2005, 2008, 2009,
-2011, 2012, 2015 Free Software Foundation, Inc.
+2011, 2012, 2015, 2019 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
diff -r 8fb9e39a9d04 -r 505381b71d95 tests/mpz/t-powm.c
--- a/tests/mpz/t-powm.c Sun Dec 08 21:58:59 2019 +0100
+++ b/tests/mpz/t-powm.c Mon Dec 09 09:55:16 2019 +0100
@@ -1,7 +1,7 @@
/* Test mpz_powm, mpz_mul, mpz_mod, mpz_mod_ui, mpz_div_ui.
-Copyright 1991, 1993, 1994, 1996, 1999-2001, 2009, 2012 Free Software
-Foundation, Inc.
+Copyright 1991, 1993, 1994, 1996, 1999-2001, 2009, 2012, 2019 Free
+Software Foundation, Inc.
This file is part of the GNU MP Library test suite.
@@ -71,36 +71,41 @@
mpz_init (exp2);
mpz_init (base2);
- mpz_set_ui (exp, 1);
- mpz_set_ui (mod, 1);
- mpz_setbit (mod, 10 * GMP_NUMB_BITS);
- mpz_ui_sub (base, 3, mod);
- mpz_powm (r1, base, exp, mod);
- MPZ_CHECK_FORMAT (r1);
- mpz_powm_sec (r2, base, exp, mod);
- MPZ_CHECK_FORMAT (r2);
-
- if (mpz_cmp_ui (r1, 3) != 0 || mpz_cmp_ui (r2, 3) != 0)
- {
- fprintf (stderr, "\nIncorrect results in first test for operands:\n", i);
- debug_mp (base, -16);
- debug_mp (exp, -16);
- debug_mp (mod, -16);
- fprintf (stderr, "mpz_powm result:\n");
- debug_mp (r1, -16);
- fprintf (stderr, "mpz_powm_sec result:\n");
- debug_mp (r2, -16);
- fprintf (stderr, "reference result: 3\n");
- abort ();
- }
-
memset (allsizes, 0, (1 << (SIZEM + 2 - 1)) * sizeof (int));
+ reps += reps >> 3;
for (i = 0; i < reps || ! allsizes_seen (allsizes); i++)
{
mpz_urandomb (bs, rands, 32);
size_range = mpz_get_ui (bs) % SIZEM + 2;
+ if ((i & 7) == 0)
+ {
+ mpz_set_ui (exp, 1);
+
+ do /* Loop until mathematically well-defined. */
+ {
+ mpz_urandomb (bs, rands, size_range / 2 + 2);
+ base_size = mpz_get_ui (bs);
+ mpz_rrandomb (base, rands, base_size);
+ }
+ while (mpz_cmp_ui (base, 0) == 0);
+
+ mpz_urandomb (bs, rands, size_range / 2);
+ mod_size = mpz_get_ui (bs);
+ mod_size = MIN (mod_size, base_size);
+ mpz_rrandomb (mod, rands, mod_size);
+
+ mpz_urandomb (bs, rands, size_range);
+ mod_size = mpz_get_ui (bs) + base_size + 2;
+ if ((i & 8) == 0)
+ mod_size += (GMP_NUMB_BITS - mod_size) % GMP_NUMB_BITS;
+ mpz_setbit (mod, mod_size);
+
+ mpz_sub (base, base, mod);
+ }
+ else
+ {
do /* Loop until mathematically well-defined. */
{
mpz_urandomb (bs, rands, size_range);
@@ -129,6 +134,7 @@
mpz_neg (base, base);
/* printf ("%ld %ld %ld\n", SIZ (base), SIZ (exp), SIZ (mod)); */
+ }
mpz_set_ui (r2, 1);
mpz_mod (base2, base, mod);
More information about the gmp-commit
mailing list