diff options
author | thevenyp <thevenyp@211d60ee-9f03-0410-a15a-8952a2c7a4e4> | 2008-10-21 12:51:45 +0000 |
---|---|---|
committer | thevenyp <thevenyp@211d60ee-9f03-0410-a15a-8952a2c7a4e4> | 2008-10-21 12:51:45 +0000 |
commit | bc62c194d13717100b90069bce89117caee30a87 (patch) | |
tree | 472f7f6b785b89595ff231cbe6f88361304d67b2 /tests/tsqr.c | |
parent | 9debaa88634b219e3eea98c483fdc5bdc383c320 (diff) | |
download | mpc-bc62c194d13717100b90069bce89117caee30a87.tar.gz |
src/sqr.c: Fix bug when reusing parameter and parameter value is pure real or pure imaginary but with a negative sign (-0).
tests/tsqr.c: add reuse bug found by Paul Zimmermann.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@264 211d60ee-9f03-0410-a15a-8952a2c7a4e4
Diffstat (limited to 'tests/tsqr.c')
-rw-r--r-- | tests/tsqr.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/tsqr.c b/tests/tsqr.c index b7303ee..75968a6 100644 --- a/tests/tsqr.c +++ b/tests/tsqr.c @@ -174,6 +174,29 @@ special (void) mpc_clear (z); } +void +bugs (void) +{ + mpc_t z1; + + /* reuse bug found by Paul Zimmermann 20081021 */ + mpc_init2 (z1, 2); + /* RE (z1^2) overflows, IM(z^2) = -0 */ + mpfr_set_str (MPC_RE (z1), "0.11", 2, GMP_RNDN); + mpfr_mul_2ui (MPC_RE (z1), MPC_RE (z1), mpfr_get_emax (), GMP_RNDN); + mpfr_set_ui (MPC_IM (z1), 0, GMP_RNDN); + mpc_conj (z1, z1, MPC_RNDNN); + mpc_sqr (z1, z1, MPC_RNDNN); + if (!mpfr_inf_p (MPC_RE (z1)) || mpfr_signbit (MPC_RE (z1)) + ||!mpfr_zero_p (MPC_IM (z1)) || !mpfr_signbit (MPC_IM (z1))) + { + printf ("Error: Regression, bug 20081021 reproduced\n"); + OUT (z1); + exit (1); + } + + mpc_clear (z1); +} int main (void) @@ -196,6 +219,8 @@ main (void) data_check (f, "sqr.dat"); tgeneric (f, 2, 1024, 1, 0); + bugs (); + test_end (); return 0; |