This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: simplify / mpfr_log2
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: Patrick Pelissier <Patrick dot Pelissier at loria dot fr>
- Cc: fortran at sources dot redhat dot com
- Date: Tue, 7 Sep 2004 10:55:02 -0700
- Subject: Re: simplify / mpfr_log2
- References: <20040907120842.GB26605@latour.loria.fr>
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