summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Zimmermann <Paul.Zimmermann@inria.fr>2018-06-13 18:30:04 +0200
committerPaul Zimmermann <Paul.Zimmermann@inria.fr>2018-06-13 18:30:04 +0200
commite9438ddfc68d8952c02d2a1ed53d13a1d8960b3f (patch)
tree25cdae494089af9a20f23f3714abea530705e87b
parent44751a0256d8aca8ce1f0118c65841d55d2d8e45 (diff)
downloadmpc-git-e9438ddfc68d8952c02d2a1ed53d13a1d8960b3f.tar.gz
fixed a bug in mpc_dot (thanks Trevor Spiteri for identifying it)
(also fixed a bug in the tests)
-rw-r--r--src/dot.c2
-rw-r--r--tests/tdot.c8
2 files changed, 5 insertions, 5 deletions
diff --git a/src/dot.c b/src/dot.c
index 7c61018..6f655c0 100644
--- a/src/dot.c
+++ b/src/dot.c
@@ -53,7 +53,7 @@ mpc_dot (mpc_ptr res, const mpc_ptr *x, const mpc_ptr *y,
mpfr_mul (z[i], mpc_realref (x[i]), mpc_realref (y[i]), MPFR_RNDZ);
/* idem for z[n+i]: we allocate with prec_x_im + prec_y_max bits */
mpfr_init2 (z[n+i], prec_x_im + prec_y_max);
- mpfr_set_prec (z[i], prec_x_im + prec_y_im);
+ mpfr_set_prec (z[n+i], prec_x_im + prec_y_im);
mpfr_mul (z[n+i], mpc_imagref (x[i]), mpc_imagref (y[i]), MPFR_RNDZ);
mpfr_neg (z[n+i], z[n+i], MPFR_RNDZ);
}
diff --git a/tests/tdot.c b/tests/tdot.c
index cfd54cd..c6d1f39 100644
--- a/tests/tdot.c
+++ b/tests/tdot.c
@@ -38,10 +38,10 @@ check_special (void)
/* dot product of empty vectors is 0 */
inex = mpc_dot (res, t, t, 0, MPC_RNDNN);
MPC_ASSERT (inex == 0);
- MPC_ASSERT (mpfr_regular_p (mpc_realref (res)));
- MPC_ASSERT (mpfr_regular_p (mpc_imagref (res)));
- MPC_ASSERT (mpfr_cmp_ui (mpc_realref (res), 0) == 0);
- MPC_ASSERT (mpfr_cmp_ui (mpc_imagref (res), 0) == 0);
+ MPC_ASSERT (mpfr_zero_p (mpc_realref (res)));
+ MPC_ASSERT (mpfr_zero_p (mpc_imagref (res)));
+ MPC_ASSERT (mpfr_signbit (mpc_realref (res)) == 0);
+ MPC_ASSERT (mpfr_signbit (mpc_imagref (res)) == 0);
/* (1,2)*(1,2) = (-3,4) */
inex = mpc_dot (res, t, t, 1, MPC_RNDNN);
MPC_ASSERT (inex == 0);