libmpc/backport-0003-Fix-bug-in-bug-fix-of-mpc_pow_fr.patch
2023-05-05 10:22:42 +08:00

41 lines
1.4 KiB
Diff

From 04ac91353e83962bfa99c4097b736a0efee4fea0 Mon Sep 17 00:00:00 2001
From: Andreas Enge <andreas.enge@inria.fr>
Date: Wed, 30 Nov 2022 14:54:38 +0100
Subject: [PATCH] Fix bug in bug fix of mpc_pow_fr.
This is a follow-up to commit f04c4ccf618dfb01fe6d878f602006a643f13071
* src/pow.c (mpc_pow): Correct a typo.
* tests/pow_fr.dat: Add a test.
---
src/pow.c | 2 +-
tests/pow_fr.dat | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/pow.c b/src/pow.c
index 2bab8b8..f436942 100644
--- a/src/pow.c
+++ b/src/pow.c
@@ -830,7 +830,7 @@ mpc_pow (mpc_ptr z, mpc_srcptr x, mpc_srcptr y, mpc_rnd_t rnd)
if (ramified)
ret = MPC_INEX (
mpfr_set_ui (mpc_realref (z), 0, MPFR_RNDN),
- mpfr_set (mpc_imagref(z), mpc_imagref(u), MPC_RND_RE(rnd)));
+ mpfr_set (mpc_imagref(z), mpc_imagref(u), MPC_RND_IM(rnd)));
else
{
ret = mpfr_set (mpc_imagref(z), mpc_imagref(u), MPC_RND_IM(rnd));
diff --git a/tests/pow_fr.dat b/tests/pow_fr.dat
index 632c39a..14cd82c 100644
--- a/tests/pow_fr.dat
+++ b/tests/pow_fr.dat
@@ -78,3 +78,5 @@
- 0 2 -0x3p-29 2 +0 2 0x1.8p-8 2 -0x1.8p-8 2 4 N N
0 - 2 +0 2 0x1p-14 2 0x1.8p-8 2 0x1.8p-8 2 2 N N
0 + 2 +0 2 -0x1p-14 2 0x1.8p-8 2 -0x1.8p-8 2 2 N N
+# issue revealed by random tests (with GMP_CHECK_RANDOMIZE=1670627686)
+0 + 2 +0 2 -0x3p-18 2 -0x3p6 2 -0x3p6 2 -2 N Z
--
2.33.0