[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-gsl] GSL and MPFR

From: Paul Zimmermann
Subject: Re: [Help-gsl] GSL and MPFR
Date: Wed, 21 Jan 2009 22:35:21 +0100

> Date: Wed, 21 Jan 2009 21:27:45 +0000
> From: Brian Gough <address@hidden>
> At Wed, 21 Jan 2009 21:45:41 +0100,
> Paul Zimmermann wrote:
> > why do you think it would be a major rewrite? What I had in mind was an
> > optional option of configure, say --with-mpfr=..., for users who prefer
> > accuracy and portability to speed.
> Can you give me an example of how that would work?  I was assuming
> that using the mpfr_t type was a signicant change from using doubles.
> -- 
> Brian Gough

of course, here is a simple wrapper for the exp function (for example):

#include <mpfr.h>
double exp_using_mpfr (double x)
  double y;
  mpfr_t z;

  mpfr_init2 (z, 53);           /* IEEE 754 double precision */
  mpfr_set_d (z, x, GMP_RNDN);  /* exact */
  mpfr_exp (z, z, GMP_RNDN);    /* z <- exp(z) correctly rounded to nearest */
  y = mpfr_get_d (z, GMP_RNDN); /* exact */
  mpfr_clear (z);
  return y;

You can also pre-allocate z and pass it to the function, to save the init
and clear.

Feel free to ask if you have further questions,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]