summaryrefslogtreecommitdiff
path: root/src/asinh.c
diff options
context:
space:
mode:
authorzimmerma <zimmerma@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2009-11-20 13:28:30 +0000
committerzimmerma <zimmerma@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2009-11-20 13:28:30 +0000
commitea0af5971c3e88793a5db1a4582d2059cabd2ec6 (patch)
tree30df40eb686497bbb6570cd24d4a15df10329407 /src/asinh.c
parent8666c83c0721d66466240a394bf53a52ad5c4cab (diff)
downloadmpc-ea0af5971c3e88793a5db1a4582d2059cabd2ec6.tar.gz
fixed bug reported by Geoff Bailey (acosh, asinh and atanh swap the precisions
of their inputs) git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@723 211d60ee-9f03-0410-a15a-8952a2c7a4e4
Diffstat (limited to 'src/asinh.c')
-rw-r--r--src/asinh.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/asinh.c b/src/asinh.c
index 4b67f9e..09c2ac7 100644
--- a/src/asinh.c
+++ b/src/asinh.c
@@ -1,6 +1,6 @@
/* mpc_asinh -- inverse hyperbolic sine of a complex number.
-Copyright (C) 2009 Philippe Th\'eveny
+Copyright (C) 2009 Philippe Th\'eveny, Paul Zimmermann
This file is part of the MPC Library.
@@ -26,21 +26,31 @@ mpc_asinh (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd)
{
/* asinh(op) = -i*asin(i*op) */
int inex;
- mpc_t z;
+ mpc_t z, a;
mpfr_t tmp;
+ /* z = i*op */
MPC_RE (z)[0] = MPC_IM (op)[0];
MPC_IM (z)[0] = MPC_RE (op)[0];
MPFR_CHANGE_SIGN (MPC_RE (z));
- inex = mpc_asin (rop, z,
+ /* Note reversal of precisions due to later multiplication by -i */
+ mpc_init3 (a, MPC_PREC_IM(rop), MPC_PREC_RE(rop));
+
+ inex = mpc_asin (a, z,
RNDC (INV_RND (MPC_RND_IM (rnd)), MPC_RND_RE (rnd)));
- /* change rop to -i*rop */
- tmp[0] = MPC_RE (rop)[0];
- MPC_RE (rop)[0] = MPC_IM (rop)[0];
- MPC_IM (rop)[0] = tmp[0];
- MPFR_CHANGE_SIGN (MPC_IM (rop));
+ /* if a = asin(i*op) = x+i*y, and we want y-i*x */
+
+ /* change a to -i*a */
+ tmp[0] = MPC_RE (a)[0];
+ MPC_RE (a)[0] = MPC_IM (a)[0];
+ MPC_IM (a)[0] = tmp[0];
+ MPFR_CHANGE_SIGN (MPC_IM (a));
+
+ mpc_set (rop, a, MPC_RNDNN); /* exact */
+
+ mpc_clear (a);
return MPC_INEX (MPC_INEX_IM (inex), -MPC_INEX_RE (inex));
}