diff options
author | Carlos O'Donell <carlos@redhat.com> | 2013-04-11 08:52:18 -0400 |
---|---|---|
committer | Carlos O'Donell <carlos@redhat.com> | 2013-04-11 08:52:18 -0400 |
commit | aba5e333d4bde2710d9e91dfbc660bd881aef1f7 (patch) | |
tree | c2bdb3555b7befa68c110058bee97ef18610369c /sysdeps | |
parent | 4f682b2ae941b9bacde6015799b7ae77301a6d87 (diff) | |
download | glibc-aba5e333d4bde2710d9e91dfbc660bd881aef1f7.zip glibc-aba5e333d4bde2710d9e91dfbc660bd881aef1f7.tar.gz glibc-aba5e333d4bde2710d9e91dfbc660bd881aef1f7.tar.bz2 |
libm-test.inc: Fix tests where cos(PI/2) != 0.
The value of PI is never exactly PI in any floating point representation,
and the value of PI/2 is never PI/2. It is wrong to expect cos(M_PI_2l)
to return 0, instead it will return an answer that is non-zero because
M_PI_2l doesn't round to exactly PI/2 in the type used.
That is to say that the correct answer is to do the following:
* Take PI or PI/2.
* Round to the floating point representation.
* Take the rounded value and compute an infinite precision cos or sin.
* Use the rounded result of the infinite precision cos or sin as the
answer to the test.
I used printf to do the type rounding, and Wolfram's Alpha to do the
infinite precision cos calculations.
The following changes bring x86-64 and x86 to 1/2 ulp for two tests.
It shows that the x86 cos implementation is quite good, and that
our test are flawed.
Unfortunately given that the rounding errors are type dependent we
need to fix this for each type. No regressions on x86-64 or x86.
---
2013-04-11 Carlos O'Donell <carlos@redhat.com>
* math/libm-test.inc (cos_test): Fix PI/2 test.
(sincos_test): Likewise.
* sysdeps/x86_64/fpu/libm-test-ulps: Regenerate.
* sysdeps/i386/fpu/libm-test-ulps: Regenerate.
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/i386/fpu/libm-test-ulps | 14 | ||||
-rw-r--r-- | sysdeps/x86_64/fpu/libm-test-ulps | 14 |
2 files changed, 0 insertions, 28 deletions
diff --git a/sysdeps/i386/fpu/libm-test-ulps b/sysdeps/i386/fpu/libm-test-ulps index 4de455c..fecaa94 100644 --- a/sysdeps/i386/fpu/libm-test-ulps +++ b/sysdeps/i386/fpu/libm-test-ulps @@ -4149,13 +4149,6 @@ idouble: 2 ifloat: 1 ildouble: 1 ldouble: 1 -Test "cos (pi/2) == 0": -double: 1 -float: 1 -idouble: 1 -ifloat: 1 -ildouble: 1 -ldouble: 1 # cos_downward Test "cos_downward (1) == 0.5403023058681397174009366074429766037323": @@ -5513,13 +5506,6 @@ idouble: 1 ifloat: 1 ildouble: 1 ldouble: 1 -Test "sincos (pi/2, &sin_res, &cos_res) puts 0 in cos_res": -double: 1 -float: 1 -idouble: 1 -ifloat: 1 -ildouble: 1 -ldouble: 1 # sinh Test "sinh (0.75) == 0.822316731935829980703661634446913849": diff --git a/sysdeps/x86_64/fpu/libm-test-ulps b/sysdeps/x86_64/fpu/libm-test-ulps index 28f4bfc..9c9c473 100644 --- a/sysdeps/x86_64/fpu/libm-test-ulps +++ b/sysdeps/x86_64/fpu/libm-test-ulps @@ -4717,13 +4717,6 @@ idouble: 2 ifloat: 1 ildouble: 1 ldouble: 1 -Test "cos (pi/2) == 0": -double: 1 -float: 1 -idouble: 1 -ifloat: 1 -ildouble: 1 -ldouble: 1 # cos_downward Test "cos_downward (1) == 0.5403023058681397174009366074429766037323": @@ -5984,13 +5977,6 @@ idouble: 1 ifloat: 1 ildouble: 1 ldouble: 1 -Test "sincos (pi/2, &sin_res, &cos_res) puts 0 in cos_res": -double: 1 -float: 1 -idouble: 1 -ifloat: 1 -ildouble: 1 -ldouble: 1 Test "sincos (pi/6, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in cos_res": float: 1 ifloat: 1 |