[Mpfi-commits] r354 - trunk/mpfi/src

ptheveny at users.gforge.inria.fr ptheveny at users.gforge.inria.fr
Lun 28 Juin 14:36:31 CEST 2010


Author: ptheveny
Date: 2010-06-28 14:36:31 +0200 (Mon, 28 Jun 2010)
New Revision: 354

Modified:
   trunk/mpfi/src/coth.c
Log:
Simplify code of mpfi_coth: mpfr_coth does not return NaN on numbers.

Modified: trunk/mpfi/src/coth.c
===================================================================
--- trunk/mpfi/src/coth.c	2010-06-28 11:26:11 UTC (rev 353)
+++ trunk/mpfi/src/coth.c	2010-06-28 12:36:31 UTC (rev 354)
@@ -31,29 +31,26 @@
 mpfi_coth (mpfi_ptr a, mpfi_srcptr b)
 {
   mpfr_t tmp;
-  int inexact_left, inexact_right, inexact=0;
+  int inexact_left, inexact_right;
+  int inexact = 0;
 
-  if ( MPFI_NAN_P (b) ) {
+  if (MPFI_NAN_P (b)) {
     mpfr_set_nan (&(a->left));
     mpfr_set_nan (&(a->right));
     MPFR_RET_NAN;
   }
 
-  if ( MPFI_HAS_ZERO (b) ) {
+  if (MPFI_HAS_ZERO (b)) {
     mpfr_set_inf (&(a->left), -1);
     mpfr_set_inf (&(a->right), 1);
     return 0;
   }
-  else {
-    mpfr_init2 (tmp, mpfi_get_prec (a));
-    inexact_left = mpfr_coth (tmp, &(b->right), MPFI_RNDD);
-    inexact_right = mpfr_coth (&(a->right), &(b->left), MPFI_RNDU);
-    inexact_left |= mpfr_set (&(a->left), tmp, MPFI_RNDD);
-    mpfr_clear (tmp);
-  }
 
-  if ( MPFI_NAN_P (a) )
-    MPFR_RET_NAN;
+  mpfr_init2 (tmp, mpfr_get_prec (&(a->left)));
+  inexact_left = mpfr_coth (tmp, &(b->right), MPFI_RNDD);
+  inexact_right = mpfr_coth (&(a->right), &(b->left), MPFI_RNDU);
+  mpfr_set (&(a->left), tmp, MPFI_RNDD); /* exact */
+  mpfr_clear (tmp);
 
   if (inexact_left)
     inexact += 1;




More information about the Mpfi-commits mailing list