simplify / mpfr_log2

Steve Kargl sgk@troutmask.apl.washington.edu
Tue Sep 7 17:55:00 GMT 2004


On Tue, Sep 07, 2004 at 02:08:42PM +0200, Patrick Pelissier wrote:
> Hello,
> 
>  I have seen you use quite often this kind of code in simplify.c:
> 
>   mpfr_set_ui (i2, 2, GFC_RND_MODE); 
>   mpfr_log (ln2, i2, GFC_RND_MODE); /* log(2) */
>   mpfr_abs (absv, x->value.real, GFC_RND_MODE); /* |x| */
>   mpfr_log (lnx, absv, GFC_RND_MODE); /* ln(|x|) */
>   mpfr_div (lnx, lnx, ln2, GFC_RND_MODE); /* ln(|x|)/ln(2) */
> 
>  It may be a good idea to use instead:
> 
>   mpfr_abs (lnx, x->value.real, GFC_RND_MODE);
>   mpfr_log2 (lnx, lnx, GFC_RND_MODE);
> 
>  It should be faster and more precise to compute the log in base 2 of |x|.
> 

You're probably right.  When I converted from GMP to MPFR,
I simply replaced the GMP functions with the appropriate
MPFR functions and I replaced homegrown functions with 
equivalent MPFR functions.  One such homegrown functions
was logrithm().  If you have a copyright assignment for
GCC with the FSF, any patches would be gladly accepted.

-- 
Steve



More information about the Fortran mailing list