diff options
author | thevenyp <thevenyp@211d60ee-9f03-0410-a15a-8952a2c7a4e4> | 2008-05-06 16:02:33 +0000 |
---|---|---|
committer | thevenyp <thevenyp@211d60ee-9f03-0410-a15a-8952a2c7a4e4> | 2008-05-06 16:02:33 +0000 |
commit | 3cac09a8f83c70d0c1674aca159de3c823ab6089 (patch) | |
tree | e264c7589e84ee9fdbc3fccad2277ff263351e46 /src/sinh.c | |
parent | 17127f9caa403a13b253159338c798706f3f77dd (diff) | |
download | mpc-3cac09a8f83c70d0c1674aca159de3c823ab6089.tar.gz |
Add hyperbolic sine function with tests.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@127 211d60ee-9f03-0410-a15a-8952a2c7a4e4
Diffstat (limited to 'src/sinh.c')
-rw-r--r-- | src/sinh.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/sinh.c b/src/sinh.c new file mode 100644 index 0000000..8d03d60 --- /dev/null +++ b/src/sinh.c @@ -0,0 +1,52 @@ +/* mpc_sinh -- hyperbolic sine of a complex number. + +Copyright (C) 2008 Philippe Th\'eveny, Andreas Enge + +This file is part of the MPC Library. + +The MPC Library is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at your +option) any later version. + +The MPC Library is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with the MPC Library; see the file COPYING.LIB. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +MA 02111-1307, USA. */ + +#include "mpfr.h" +#include "mpc.h" +#include "mpc-impl.h" + +void +mpc_sinh (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) +{ + /* sinh(op) = -i*sin(i*op) = conj(-i*sin(conj(-i*op))) */ + mpc_t z; + mpc_t sin_z; + mpc_rnd_t rnd_z; + + rnd_z = RNDC (MPC_RND_IM (rnd), MPC_RND_RE (rnd)); + + mpc_init3 (z, MPFR_PREC (MPC_IM (op)), MPFR_PREC (MPC_RE (op))); + mpc_init3 (sin_z, MPFR_PREC (MPC_IM (rop)), MPFR_PREC (MPC_RE (rop))); + + /* z := conj(-i * op), note that the real and imaginary precision + may differ. */ + mpfr_set (MPC_RE (z), MPC_IM (op), GMP_RNDN); /* exact */ + mpfr_set (MPC_IM (z), MPC_RE (op), GMP_RNDN); /* exact */ + + /* rop = conj(-i * sin(z)) */ + mpc_sin (sin_z, z, rnd_z); + + mpfr_set (MPC_RE (rop), MPC_IM (sin_z), GMP_RNDN); /* exact */ + mpfr_set (MPC_IM (rop), MPC_RE (sin_z), GMP_RNDN); /* exact */ + + mpc_clear (z); + mpc_clear (sin_z); +} |