summaryrefslogtreecommitdiff
path: root/src/sin.c
diff options
context:
space:
mode:
authorzimmerma <zimmerma@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2010-06-28 10:31:03 +0000
committerzimmerma <zimmerma@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2010-06-28 10:31:03 +0000
commit307b49227ec2fe81c3677b7bfb4643e84256306e (patch)
tree9ef6f85d4499c09f2348d2cd3cff9b6560d245aa /src/sin.c
parente801bd135f4cf1b510d4e2bb2e7daf83e17cda50 (diff)
downloadmpc-307b49227ec2fe81c3677b7bfb4643e84256306e.tar.gz
partial fix for problems with huge exponents reported by Chris Saunders
(http://lists.gforge.inria.fr/pipermail/mpc-discuss/2010-June/000750.html) More work is needed for tan (detect when Im(result) is very near -1 or 1) and tanh. git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@795 211d60ee-9f03-0410-a15a-8952a2c7a4e4
Diffstat (limited to 'src/sin.c')
-rw-r--r--src/sin.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/sin.c b/src/sin.c
index ba1276d..3fd72e2 100644
--- a/src/sin.c
+++ b/src/sin.c
@@ -1,6 +1,6 @@
/* mpc_sin -- sine of a complex number.
-Copyright (C) 2007, 2009 Paul Zimmermann, Philippe Th\'eveny
+Copyright (C) 2007, 2009, 2010 Paul Zimmermann, Philippe Th\'eveny
This file is part of the MPC Library.
@@ -28,6 +28,7 @@ mpc_sin (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd)
mpfr_prec_t prec;
int ok = 0;
int inex_re, inex_im;
+ mp_exp_t emin, emax;
/* special values */
if (!mpfr_number_p (MPC_RE (op)) || !mpfr_number_p (MPC_IM (op)))
@@ -135,6 +136,10 @@ mpc_sin (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd)
mpfr_init2 (y, 2);
mpfr_init2 (z, 2);
+ emin = mpfr_get_emin ();
+ emax = mpfr_get_emax ();
+ mpfr_set_emin (mpfr_get_emin_min ());
+ mpfr_set_emax (mpfr_get_emax_max ());
do
{
prec += mpc_ceil_log2 (prec) + 5;
@@ -165,5 +170,11 @@ mpc_sin (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd)
mpfr_clear (y);
mpfr_clear (z);
+ mpfr_set_emin (emin);
+ mpfr_set_emax (emax);
+
+ inex_re = mpfr_check_range (MPC_RE(rop), inex_re, MPC_RND_RE(rnd));
+ inex_im = mpfr_check_range (MPC_IM(rop), inex_im, MPC_RND_IM(rnd));
+
return MPC_INEX (inex_re, inex_im);
}