summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Enge <andreas.enge@inria.fr>2016-05-24 14:55:15 +0200
committerAndreas Enge <andreas.enge@inria.fr>2016-05-24 16:05:45 +0200
commitc05dc11ea88df618095f152adc1cdadbada8e626 (patch)
tree17fc537ad11f040cc0560c2706c21638b44e498f
parent4aea929e6f896b698c85c665990088b3d721b76e (diff)
downloadmpc-git-c05dc11ea88df618095f152adc1cdadbada8e626.tar.gz
rootofunity: Adapt to current mpc code and compilers.
* src/rootofunity.c: Replace mpc_div_2exp by mpc_div_2ui and GMP_RND* by MPFR_RND*. * tests/trootofunity.c: Correct a signedness warning.
-rw-r--r--src/rootofunity.c24
-rw-r--r--tests/trootofunity.c10
2 files changed, 17 insertions, 17 deletions
diff --git a/src/rootofunity.c b/src/rootofunity.c
index 92555ee..9cc236a 100644
--- a/src/rootofunity.c
+++ b/src/rootofunity.c
@@ -1,6 +1,6 @@
/* mpc_rootofunity -- primitive root of unity.
-Copyright (C) 2012 INRIA
+Copyright (C) 2012, 2016 INRIA
This file is part of GNU MPC.
@@ -40,16 +40,16 @@ mpc_rootofunity (mpc_ptr rop, unsigned long int n, mpc_rnd_t rnd)
inex_re = mpfr_set_si (mpc_realref (rop), (n == 3 ? -1 : 1),
MPC_RND_RE (rnd));
inex_im = mpfr_sqrt_ui (mpc_imagref (rop), 3, MPC_RND_IM (rnd));
- mpc_div_2exp (rop, rop, 1, MPC_RNDNN);
+ mpc_div_2ui (rop, rop, 1, MPC_RNDNN);
return MPC_INEX (inex_re, inex_im);
}
else if (n == 12) {
inex_re = mpfr_sqrt_ui (mpc_imagref (rop), 3, MPC_RND_IM (rnd));
inex_im = mpfr_set_ui (mpc_imagref (rop), 1, MPC_RND_RE (rnd));
- mpc_div_2exp (rop, rop, 1u, MPC_RNDNN);
+ mpc_div_2ui (rop, rop, 1u, MPC_RNDNN);
return MPC_INEX (inex_re, inex_im);
}
-
+
prec = MPC_MAX_PREC(rop);
mpfr_init2 (t, 2);
@@ -63,17 +63,17 @@ mpc_rootofunity (mpc_ptr rop, unsigned long int n, mpc_rnd_t rnd)
mpfr_set_prec (s, prec);
mpfr_set_prec (c, prec);
- mpfr_const_pi (t, GMP_RNDN); /* error 0.5 ulp */
- mpfr_mul_2ui (t, t, 1u, GMP_RNDN);
- mpfr_div_ui (t, t, n, GMP_RNDN); /* error 2*0.5+0.5=1.5 ulp */
- mpfr_sin_cos (s, c, t, GMP_RNDN);
+ mpfr_const_pi (t, MPFR_RNDN); /* error 0.5 ulp */
+ mpfr_mul_2ui (t, t, 1u, MPFR_RNDN);
+ mpfr_div_ui (t, t, n, MPFR_RNDN); /* error 2*0.5+0.5=1.5 ulp */
+ mpfr_sin_cos (s, c, t, MPFR_RNDN);
/* error (1.5*2^{Exp (t) - Exp (s resp.c)} + 0.5) ulp
<= 6.5 ulp for n>=3 */
}
- while ( !mpfr_can_round (c, prec - 3, GMP_RNDN, GMP_RNDZ,
- MPC_PREC_RE(rop) + (MPC_RND_RE(rnd) == GMP_RNDN))
- || !mpfr_can_round (s, prec - 3, GMP_RNDN, GMP_RNDZ,
- MPC_PREC_IM(rop) + (MPC_RND_IM(rnd) == GMP_RNDN)));
+ while ( !mpfr_can_round (c, prec - 3, MPFR_RNDN, MPFR_RNDZ,
+ MPC_PREC_RE(rop) + (MPC_RND_RE(rnd) == MPFR_RNDN))
+ || !mpfr_can_round (s, prec - 3, MPFR_RNDN, GMP_RNDZ,
+ MPC_PREC_IM(rop) + (MPC_RND_IM(rnd) == MPFR_RNDN)));
inex_re = mpfr_set (mpc_realref(rop), c, MPC_RND_RE(rnd));
inex_im = mpfr_set (mpc_imagref(rop), s, MPC_RND_IM(rnd));
diff --git a/tests/trootofunity.c b/tests/trootofunity.c
index 7ac1c3d..380de0f 100644
--- a/tests/trootofunity.c
+++ b/tests/trootofunity.c
@@ -1,6 +1,6 @@
-/* ttan -- test file for mpc_rootofunity.
+/* trootofunity -- test file for mpc_rootofunity.
-Copyright (C) 2012 INRIA
+Copyright (C) 2012, 2016 INRIA
This file is part of GNU MPC.
@@ -39,7 +39,7 @@ check (unsigned long int n)
mpc_pow_ui (zero, z, n, MPC_RNDNN);
mpc_sub_ui (zero, zero, 1u, MPC_RNDNN);
if (MPC_MAX (mpfr_get_exp (mpc_realref (zero)), mpfr_get_exp (mpc_imagref (zero)))
- > - (prec - n)) {
+ > - ((long int) prec - (long int) n)) {
fprintf (stderr, "rootofunity too imprecise for n=%lu\n", n);
MPC_OUT (z);
MPC_OUT (zero);
@@ -55,10 +55,10 @@ check (unsigned long int n)
int
main (void)
{
- int n;
+ unsigned long int n;
for (n = 1; n < 10000; n += 10)
check (n);
-
+
return 0;
}