This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: simplify / mpfr_log2


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]