summaryrefslogtreecommitdiff
path: root/acosh.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2003-05-22 21:39:40 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2003-05-22 21:39:40 +0000
commit44b4dd94bb98c8d9e7850ae401232bd1b2ea3028 (patch)
tree9670f0ef8017d42ad2a2062dc08c63c022e450c8 /acosh.c
parent2f3cb289a102043a22bd32c5950db37199fb3fd2 (diff)
downloadmpfr-44b4dd94bb98c8d9e7850ae401232bd1b2ea3028.tar.gz
Macros MPFR_EXP_INVALID (invalid exponent value) and MPFR_EXP_CHECK
added. Code update to use MPFR_GET_EXP and MPFR_SET_EXP instead of MPFR_EXP to allow more bug detection related to special values. Macros MPFR_SET_NAN, MPFR_SET_INF, MPFR_SET_ZERO and MPFR_INIT set the exponent of the number to MPFR_EXP_INVALID if MPFR_EXP_CHECK is defined. Compile with -DMPFR_EXP_CHECK and make check to see the potential problems; currently, 40 of 76 tests fail. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2301 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'acosh.c')
-rw-r--r--acosh.c48
1 files changed, 25 insertions, 23 deletions
diff --git a/acosh.c b/acosh.c
index 5f0c8476e..5a1c83404 100644
--- a/acosh.c
+++ b/acosh.c
@@ -1,6 +1,6 @@
/* mpfr_acosh -- inverse hyperbolic cosine
-Copyright 2001, 2002 Free Software Foundation.
+Copyright 2001, 2002, 2003 Free Software Foundation.
This file is part of the MPFR Library.
@@ -85,28 +85,30 @@ mpfr_acosh (mpfr_ptr y, mpfr_srcptr x , mp_rnd_t rnd_mode)
mpfr_save_emin_emax ();
/* First computation of acosh */
- do {
-
- /* reactualisation of the precision */
- mpfr_set_prec (t, Nt);
- mpfr_set_prec (te, Nt);
- mpfr_set_prec (ti, Nt);
-
- /* compute acosh */
- mpfr_mul (te, x, x, GMP_RNDD); /* x^2 */
- mpfr_sub_ui (ti, te, 1, GMP_RNDD); /* x^2-1 */
- mpfr_sqrt (t, ti, GMP_RNDN); /* sqrt(x^2-1) */
- mpfr_add (t, t, x, GMP_RNDN); /* sqrt(x^2-1)+x */
- mpfr_log (t, t, GMP_RNDN); /* ln(sqrt(x^2-1)+x)*/
-
- /* estimation of the error -- see algorithms.ps */
- err = Nt - (-1 + 2 * MAX(2 + MAX(2 - MPFR_EXP(t),
- 1 + MPFR_EXP(te) - MPFR_EXP(ti) - MPFR_EXP(t)), 0));
-
- /* actualisation of the precision */
- Nt += 10;
-
- } while ((err < 0) || !mpfr_can_round (t, err, GMP_RNDN, rnd_mode, Ny));
+ do
+ {
+ /* reactualisation of the precision */
+ mpfr_set_prec (t, Nt);
+ mpfr_set_prec (te, Nt);
+ mpfr_set_prec (ti, Nt);
+
+ /* compute acosh */
+ mpfr_mul (te, x, x, GMP_RNDD); /* x^2 */
+ mpfr_sub_ui (ti, te, 1, GMP_RNDD); /* x^2-1 */
+ mpfr_sqrt (t, ti, GMP_RNDN); /* sqrt(x^2-1) */
+ mpfr_add (t, t, x, GMP_RNDN); /* sqrt(x^2-1)+x */
+ mpfr_log (t, t, GMP_RNDN); /* ln(sqrt(x^2-1)+x)*/
+
+ /* error estimate -- see algorithms.ps */
+ err = Nt - (-1 + 2 * MAX(2 + MAX(2 - MPFR_GET_EXP (t),
+ 1 + MPFR_GET_EXP (te)
+ - MPFR_GET_EXP (ti)
+ - MPFR_GET_EXP (t)), 0));
+
+ /* actualisation of the precision */
+ Nt += 10;
+ }
+ while ((err < 0) || !mpfr_can_round (t, err, GMP_RNDN, rnd_mode, Ny));
inexact = mpfr_set (y, t, rnd_mode);