summaryrefslogtreecommitdiff
path: root/src/acos.c
diff options
context:
space:
mode:
authorenge <enge@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2011-11-04 18:39:52 +0000
committerenge <enge@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2011-11-04 18:39:52 +0000
commit5ad0bccecc2c0aafdc23571a491fccc31171c22c (patch)
treefbb979252a636e9fc3215e15e12be49ca6d35a95 /src/acos.c
parent18e9d42b59925987d8128096c4a7ea6d49721862 (diff)
downloadmpc-5ad0bccecc2c0aafdc23571a491fccc31171c22c.tar.gz
replaced MPC_RE by mpc_realref and MPC_IM by mpc_imagref everywhere
git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@1112 211d60ee-9f03-0410-a15a-8952a2c7a4e4
Diffstat (limited to 'src/acos.c')
-rw-r--r--src/acos.c100
1 files changed, 50 insertions, 50 deletions
diff --git a/src/acos.c b/src/acos.c
index 4b78735..2832125 100644
--- a/src/acos.c
+++ b/src/acos.c
@@ -1,6 +1,6 @@
/* mpc_acos -- arccosine of a complex number.
-Copyright (C) 2009, 2010 INRIA
+Copyright (C) 2009, 2010, 2011 INRIA
This file is part of GNU MPC.
@@ -36,38 +36,38 @@ mpc_acos (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd)
inex_im = 0;
/* special values */
- if (mpfr_nan_p (MPC_RE (op)) || mpfr_nan_p (MPC_IM (op)))
+ if (mpfr_nan_p (mpc_realref (op)) || mpfr_nan_p (mpc_imagref (op)))
{
- if (mpfr_inf_p (MPC_RE (op)) || mpfr_inf_p (MPC_IM (op)))
+ if (mpfr_inf_p (mpc_realref (op)) || mpfr_inf_p (mpc_imagref (op)))
{
- mpfr_set_inf (MPC_IM (rop), mpfr_signbit (MPC_IM (op)) ? +1 : -1);
- mpfr_set_nan (MPC_RE (rop));
+ mpfr_set_inf (mpc_imagref (rop), mpfr_signbit (mpc_imagref (op)) ? +1 : -1);
+ mpfr_set_nan (mpc_realref (rop));
}
- else if (mpfr_zero_p (MPC_RE (op)))
+ else if (mpfr_zero_p (mpc_realref (op)))
{
- inex_re = set_pi_over_2 (MPC_RE (rop), +1, MPC_RND_RE (rnd));
- mpfr_set_nan (MPC_IM (rop));
+ inex_re = set_pi_over_2 (mpc_realref (rop), +1, MPC_RND_RE (rnd));
+ mpfr_set_nan (mpc_imagref (rop));
}
else
{
- mpfr_set_nan (MPC_RE (rop));
- mpfr_set_nan (MPC_IM (rop));
+ mpfr_set_nan (mpc_realref (rop));
+ mpfr_set_nan (mpc_imagref (rop));
}
return MPC_INEX (inex_re, 0);
}
- if (mpfr_inf_p (MPC_RE (op)) || mpfr_inf_p (MPC_IM (op)))
+ if (mpfr_inf_p (mpc_realref (op)) || mpfr_inf_p (mpc_imagref (op)))
{
- if (mpfr_inf_p (MPC_RE (op)))
+ if (mpfr_inf_p (mpc_realref (op)))
{
- if (mpfr_inf_p (MPC_IM (op)))
+ if (mpfr_inf_p (mpc_imagref (op)))
{
- if (mpfr_sgn (MPC_RE (op)) > 0)
+ if (mpfr_sgn (mpc_realref (op)) > 0)
{
inex_re =
- set_pi_over_2 (MPC_RE (rop), +1, MPC_RND_RE (rnd));
- mpfr_div_2ui (MPC_RE (rop), MPC_RE (rop), 1, GMP_RNDN);
+ set_pi_over_2 (mpc_realref (rop), +1, MPC_RND_RE (rnd));
+ mpfr_div_2ui (mpc_realref (rop), mpc_realref (rop), 1, GMP_RNDN);
}
else
{
@@ -81,7 +81,7 @@ mpc_acos (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd)
mpfr_prec_t prec;
int ok;
mpfr_init (x);
- prec = mpfr_get_prec (MPC_RE (rop));
+ prec = mpfr_get_prec (mpc_realref (rop));
p = prec;
do
@@ -96,61 +96,61 @@ mpc_acos (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd)
} while (ok == 0);
inex_re =
- mpfr_div_2ui (MPC_RE (rop), x, 2, MPC_RND_RE (rnd));
+ mpfr_div_2ui (mpc_realref (rop), x, 2, MPC_RND_RE (rnd));
mpfr_clear (x);
}
}
else
{
- if (mpfr_sgn (MPC_RE (op)) > 0)
- mpfr_set_ui (MPC_RE (rop), 0, GMP_RNDN);
+ if (mpfr_sgn (mpc_realref (op)) > 0)
+ mpfr_set_ui (mpc_realref (rop), 0, GMP_RNDN);
else
- inex_re = mpfr_const_pi (MPC_RE (rop), MPC_RND_RE (rnd));
+ inex_re = mpfr_const_pi (mpc_realref (rop), MPC_RND_RE (rnd));
}
}
else
- inex_re = set_pi_over_2 (MPC_RE (rop), +1, MPC_RND_RE (rnd));
+ inex_re = set_pi_over_2 (mpc_realref (rop), +1, MPC_RND_RE (rnd));
- mpfr_set_inf (MPC_IM (rop), mpfr_signbit (MPC_IM (op)) ? +1 : -1);
+ mpfr_set_inf (mpc_imagref (rop), mpfr_signbit (mpc_imagref (op)) ? +1 : -1);
return MPC_INEX (inex_re, 0);
}
/* pure real argument */
- if (mpfr_zero_p (MPC_IM (op)))
+ if (mpfr_zero_p (mpc_imagref (op)))
{
int s_im;
- s_im = mpfr_signbit (MPC_IM (op));
+ s_im = mpfr_signbit (mpc_imagref (op));
- if (mpfr_cmp_ui (MPC_RE (op), 1) > 0)
+ if (mpfr_cmp_ui (mpc_realref (op), 1) > 0)
{
if (s_im)
- inex_im = mpfr_acosh (MPC_IM (rop), MPC_RE (op),
+ inex_im = mpfr_acosh (mpc_imagref (rop), mpc_realref (op),
MPC_RND_IM (rnd));
else
- inex_im = -mpfr_acosh (MPC_IM (rop), MPC_RE (op),
+ inex_im = -mpfr_acosh (mpc_imagref (rop), mpc_realref (op),
INV_RND (MPC_RND_IM (rnd)));
- mpfr_set_ui (MPC_RE (rop), 0, GMP_RNDN);
+ mpfr_set_ui (mpc_realref (rop), 0, GMP_RNDN);
}
- else if (mpfr_cmp_si (MPC_RE (op), -1) < 0)
+ else if (mpfr_cmp_si (mpc_realref (op), -1) < 0)
{
mpfr_t minus_op_re;
- minus_op_re[0] = MPC_RE (op)[0];
+ minus_op_re[0] = mpc_realref (op)[0];
MPFR_CHANGE_SIGN (minus_op_re);
if (s_im)
- inex_im = mpfr_acosh (MPC_IM (rop), minus_op_re,
+ inex_im = mpfr_acosh (mpc_imagref (rop), minus_op_re,
MPC_RND_IM (rnd));
else
- inex_im = -mpfr_acosh (MPC_IM (rop), minus_op_re,
+ inex_im = -mpfr_acosh (mpc_imagref (rop), minus_op_re,
INV_RND (MPC_RND_IM (rnd)));
- inex_re = mpfr_const_pi (MPC_RE (rop), MPC_RND_RE (rnd));
+ inex_re = mpfr_const_pi (mpc_realref (rop), MPC_RND_RE (rnd));
}
else
{
- inex_re = mpfr_acos (MPC_RE (rop), MPC_RE (op), MPC_RND_RE (rnd));
- mpfr_set_ui (MPC_IM (rop), 0, MPC_RND_IM (rnd));
+ inex_re = mpfr_acos (mpc_realref (rop), mpc_realref (op), MPC_RND_RE (rnd));
+ mpfr_set_ui (mpc_imagref (rop), 0, MPC_RND_IM (rnd));
}
if (!s_im)
@@ -160,10 +160,10 @@ mpc_acos (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd)
}
/* pure imaginary argument */
- if (mpfr_zero_p (MPC_RE (op)))
+ if (mpfr_zero_p (mpc_realref (op)))
{
- inex_re = set_pi_over_2 (MPC_RE (rop), +1, MPC_RND_RE (rnd));
- inex_im = -mpfr_asinh (MPC_IM (rop), MPC_IM (op),
+ inex_re = set_pi_over_2 (mpc_realref (rop), +1, MPC_RND_RE (rnd));
+ inex_im = -mpfr_asinh (mpc_imagref (rop), mpc_imagref (op),
INV_RND (MPC_RND_IM (rnd)));
mpc_conj (rop,rop, MPC_RNDNN);
@@ -171,8 +171,8 @@ mpc_acos (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd)
}
/* regular complex argument: acos(z) = Pi/2 - asin(z) */
- p_re = mpfr_get_prec (MPC_RE(rop));
- p_im = mpfr_get_prec (MPC_IM(rop));
+ p_re = mpfr_get_prec (mpc_realref(rop));
+ p_im = mpfr_get_prec (mpc_imagref(rop));
p = p_re;
mpc_init3 (z1, p, p_im); /* we round directly the imaginary part to p_im,
with rounding mode opposite to rnd_im */
@@ -181,7 +181,7 @@ mpc_acos (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd)
Im(z) > 0 and rnd_im = RNDZ, we want to round the Im(asin(z)) to -Inf
so that -Im(asin(z)) is rounded to zero */
if (rnd_im == GMP_RNDZ)
- rnd_im = mpfr_sgn (MPC_IM(op)) > 0 ? GMP_RNDD : GMP_RNDU;
+ rnd_im = mpfr_sgn (mpc_imagref(op)) > 0 ? GMP_RNDD : GMP_RNDU;
else
rnd_im = rnd_im == GMP_RNDU ? GMP_RNDD
: rnd_im == GMP_RNDD ? GMP_RNDU
@@ -192,30 +192,30 @@ mpc_acos (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd)
{
p += mpc_ceil_log2 (p) + 3;
- mpfr_set_prec (MPC_RE(z1), p);
+ mpfr_set_prec (mpc_realref(z1), p);
mpfr_set_prec (pi_over_2, p);
mpfr_const_pi (pi_over_2, GMP_RNDN);
mpfr_div_2exp (pi_over_2, pi_over_2, 1, GMP_RNDN); /* Pi/2 */
e1 = 1; /* Exp(pi_over_2) */
inex = mpc_asin (z1, op, rnd1); /* asin(z) */
- MPC_ASSERT (mpfr_sgn (MPC_IM(z1)) * mpfr_sgn (MPC_IM(op)) > 0);
+ MPC_ASSERT (mpfr_sgn (mpc_imagref(z1)) * mpfr_sgn (mpc_imagref(op)) > 0);
inex_im = MPC_INEX_IM(inex); /* inex_im is in {-1, 0, 1} */
- e2 = mpfr_get_exp (MPC_RE(z1));
- mpfr_sub (MPC_RE(z1), pi_over_2, MPC_RE(z1), GMP_RNDN);
- if (!mpfr_zero_p (MPC_RE(z1)))
+ e2 = mpfr_get_exp (mpc_realref(z1));
+ mpfr_sub (mpc_realref(z1), pi_over_2, mpc_realref(z1), GMP_RNDN);
+ if (!mpfr_zero_p (mpc_realref(z1)))
{
/* the error on x=Re(z1) is bounded by 1/2 ulp(x) + 2^(e1-p-1) +
2^(e2-p-1) */
e1 = e1 >= e2 ? e1 + 1 : e2 + 1;
/* the error on x is bounded by 1/2 ulp(x) + 2^(e1-p-1) */
- e1 -= mpfr_get_exp (MPC_RE(z1));
+ e1 -= mpfr_get_exp (mpc_realref(z1));
/* the error on x is bounded by 1/2 ulp(x) [1 + 2^e1] */
e1 = e1 <= 0 ? 0 : e1;
/* the error on x is bounded by 2^e1 * ulp(x) */
- mpfr_neg (MPC_IM(z1), MPC_IM(z1), GMP_RNDN); /* exact */
+ mpfr_neg (mpc_imagref(z1), mpc_imagref(z1), GMP_RNDN); /* exact */
inex_im = -inex_im;
- if (mpfr_can_round (MPC_RE(z1), p - e1, GMP_RNDN, GMP_RNDZ,
+ if (mpfr_can_round (mpc_realref(z1), p - e1, GMP_RNDN, GMP_RNDZ,
p_re + (MPC_RND_RE(rnd) == GMP_RNDN)))
break;
}