[Gmp-commit] /var/hg/gmp: 2 new changesets
mercurial at gmplib.org
mercurial at gmplib.org
Sun Dec 8 20:59:09 UTC 2019
details: /var/hg/gmp/rev/c0d407af48fb
changeset: 17989:c0d407af48fb
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Sun Dec 08 21:57:25 2019 +0100
description:
mpz/powm.c: Full normalisation when e=1 & b<0...
details: /var/hg/gmp/rev/8fb9e39a9d04
changeset: 17990:8fb9e39a9d04
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Sun Dec 08 21:58:59 2019 +0100
description:
tests/mpz/t-powm.c: Trigger the just removed bug.
diffstat:
mpz/powm.c | 2 +-
tests/mpz/t-powm.c | 23 +++++++++++++++++++++++
2 files changed, 24 insertions(+), 1 deletions(-)
diffs (45 lines):
diff -r 2109bbf292bd -r 8fb9e39a9d04 mpz/powm.c
--- a/mpz/powm.c Thu Dec 05 07:44:46 2019 +0100
+++ b/mpz/powm.c Sun Dec 08 21:58:59 2019 +0100
@@ -138,7 +138,7 @@
{
mpn_sub (rp, mp, n, bp, bn);
rn = n;
- rn -= (rp[rn - 1] == 0);
+ MPN_NORMALIZE_NOT_ZERO (rp, rn);
}
else
{
diff -r 2109bbf292bd -r 8fb9e39a9d04 tests/mpz/t-powm.c
--- a/tests/mpz/t-powm.c Thu Dec 05 07:44:46 2019 +0100
+++ b/tests/mpz/t-powm.c Sun Dec 08 21:58:59 2019 +0100
@@ -71,6 +71,29 @@
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));
for (i = 0; i < reps || ! allsizes_seen (allsizes); i++)
More information about the gmp-commit
mailing list