Implementations of sqrtl and logl
Steve Kargl
sgk at troutmask.apl.washington.edu
Fri Dec 30 11:08:06 PST 2005
On Sat, Dec 31, 2005 at 05:26:12AM +1100, Peter Jeremy wrote:
> On Thu, 2005-Dec-29 14:46:26 -0800, Steve Kargl wrote:
> >I have implementations for sqrtl and logl, which can be added
> >to libm. In limited testing on AMD64 , I find
> >
> >troutmask:kargl[208] ./test_sqrt
> > float double long double
> >MRE: 8.953800e-08 1.664855e-16 1.084202e-19
> >DDP: 7.05 15.78 18.96
> >BDP: 23.41 52.42 63.00
> ...
> >MRE = maximum relative error between a value from my routine and
> > a value computed using GMP/MPFR with 64-bits of precision.
>
> Given that long double has 64 bits of precision, is testing it against
> a 64-bit test library adequate? And what is the accuracy of your test
> library?
>
MPFR uses GMP for its internals. I set MPFR to use 64-bit precision
and round-to-nearest. It is claimed that mpfr will give correctly
rounded FP values in the requested precision and rounding mode. I can
set MPFR to any precision and one of four rounding modes; however, the
runtime of the tests will go up.
I've changed my test program to use 128 bit precision. Here are the
results
troutmask:kargl[211] ./test_sqrt 100000000
float double long double
MRE: 8.953800e-08 1.664855e-16 1.084202e-19
DDP: 7.05 15.78 18.96
BDP: 23.41 52.42 63.00
MRE: 1.084202e-19
DDP: 18.96
BDP: 63.00
To gather the stats, I need to either convert my long double result
into a mpfr_t value or convert the MPFR sqrt value into a long double.
I've chosen the latter. Thus, the 128-bit MPFR value is correctly
rounded to a 64-bit long double.
I don't understand your second question. Are you referring to MPFR?.
epsilon is 2**(1 - p) where p is the precision.
--
Steve
More information about the freebsd-hackers
mailing list