diff options
author | Joseph Myers <joseph@codesourcery.com> | 2015-06-25 21:46:02 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2015-06-25 21:46:02 +0000 |
commit | a8e2112ae3e57fae592d84af2936a61d6239a248 (patch) | |
tree | c9a07fad850af11667fffc681b0c5d96c9fe7e3a /sysdeps/ieee754/flt-32/e_jnf.c | |
parent | 037e4b993fe03d33055f92dddf7242abd9f6d1de (diff) | |
download | glibc-a8e2112ae3e57fae592d84af2936a61d6239a248.tar.gz glibc-a8e2112ae3e57fae592d84af2936a61d6239a248.tar.xz glibc-a8e2112ae3e57fae592d84af2936a61d6239a248.zip |
Use round-to-nearest internally in jn, test with ALL_RM_TEST (bug 18602).
Some existing jn tests, if run in non-default rounding modes, produce errors above those accepted in glibc, which causes problems for moving tests of jn to use ALL_RM_TEST. This patch makes jn set rounding to-nearest internally, as was done for yn some time ago, then computes the appropriate underflowing value for results that underflowed to zero in to-nearest, and moves the tests to ALL_RM_TEST. It does nothing about the general inaccuracy of Bessel function implementations in glibc, though it should make jn more accurate on average in non-default rounding modes through reduced error accumulation. The recomputation of results that underflowed to zero should as a side-effect fix some cases of bug 16559, where jn just used an exact zero, but that is *not* the goal of this patch and other cases of that bug remain unfixed. (Most of the changes in the patch are reindentation to add new scopes for SET_RESTORE_ROUND*.) Tested for x86_64, x86, powerpc and mips64. [BZ #16559] [BZ #18602] * sysdeps/ieee754/dbl-64/e_jn.c (__ieee754_jn): Set round-to-nearest internally then recompute results that underflowed to zero in the original rounding mode. * sysdeps/ieee754/flt-32/e_jnf.c (__ieee754_jnf): Likewise. * sysdeps/ieee754/ldbl-128/e_jnl.c (__ieee754_jnl): Likewise. * sysdeps/ieee754/ldbl-128ibm/e_jnl.c (__ieee754_jnl): Likewise. * sysdeps/ieee754/ldbl-96/e_jnl.c (__ieee754_jnl): Likewise * math/libm-test.inc (jn_test): Use ALL_RM_TEST. * sysdeps/i386/fpu/libm-test-ulps: Update. * sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
Diffstat (limited to 'sysdeps/ieee754/flt-32/e_jnf.c')
-rw-r--r-- | sysdeps/ieee754/flt-32/e_jnf.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sysdeps/ieee754/flt-32/e_jnf.c b/sysdeps/ieee754/flt-32/e_jnf.c index dc4b371bc1..ec5a81b653 100644 --- a/sysdeps/ieee754/flt-32/e_jnf.c +++ b/sysdeps/ieee754/flt-32/e_jnf.c @@ -27,6 +27,8 @@ static const float zero = 0.0000000000e+00; float __ieee754_jnf(int n, float x) { + float ret; + { int32_t i,hx,ix, sgn; float a, b, temp, di; float z, w; @@ -47,8 +49,9 @@ __ieee754_jnf(int n, float x) if(n==1) return(__ieee754_j1f(x)); sgn = (n&1)&(hx>>31); /* even n -- 0, odd n -- sign(x) */ x = fabsf(x); + SET_RESTORE_ROUNDF (FE_TONEAREST); if(__builtin_expect(ix==0||ix>=0x7f800000, 0)) /* if x is 0 or inf */ - b = zero; + return sgn == 1 ? -zero : zero; else if((float)n<=x) { /* Safe to use J(n+1,x)=2n/x *J(n,x)-J(n-1,x) */ a = __ieee754_j0f(x); @@ -163,7 +166,11 @@ __ieee754_jnf(int n, float x) b = (t * w / a); } } - if(sgn==1) return -b; else return b; + if(sgn==1) ret = -b; else ret = b; + } + if (ret == 0) + ret = __copysignf (FLT_MIN, ret) * FLT_MIN; + return ret; } strong_alias (__ieee754_jnf, __jnf_finite) |