-
Notifications
You must be signed in to change notification settings - Fork 226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug in tgamma function for float128 #307
Comments
I will investigate this. |
On 1/18/20 1:21 PM, Christopher Kormanyos wrote:
I will investigate this.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#307?email_source=notifications&email_token=AAOYYX6GS3OXHJVAR3PWGUTQ6NCEHA5CNFSM4KIIUPM2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJJ6ZSY#issuecomment-575925451>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAOYYX4X3IJWYT4RIQMOLHDQ6NCEHANCNFSM4KIIUPMQ>.
I remember something very much like this in gcc in libquadmath.
They just pulled the latest from glibc for the whole lib.
IIRC there was a sign error in the gamma reflection code around line 200.
Good luck.
Ed
|
Yes. I can reproduce a suspicious (probably erroneous) sign on the result confirming the bug report. With the code below, it appears as though the result of tgamma(-3/2) has the wrong sign, in confirmation of the user's workaround. Test code:
Compiler:
Compiler with:
Result is:
Expected answers are:
The fix is unclear. We could potentially fix in |
Me too. I wonder if there is a range of compilers for which this occurs? |
It appears as though tgammaq in at least some versions of libquadmath is neglecting the oscillatory part of Gamma on the negative real axis. Thisw is easy to do if you just take expq(lgammaq) for the result but forget to oscillate.
The output is
Compare at WolframAlpha with
|
So should this bug be forwarded to libquadmath? |
Yes. I will also work out a proposal in Boost in a branch for a quicker fix until quadmath can be fixed. Then we can decide what we want to do. |
This appears to have been fixed at some point, using @ckormanyos code as above and gcc-9 I see:
I see the same output with gcc 7 and 8 on Ubuntu-19.10 even if I use One option for gcc prior to 9 might be to take the absolute value of |
I was thinking to apply that sign correction regardless of GCC version since I was not sure if it was possible or not to say that all GCC for all targets (PC, embedded, ARM, MIPS, etc.) match the fixed libquadmath with GCC 9. What do you think of this? |
Looks fine to me, can you add a simple test case to test_sf_import_c99.cpp as well? There's a couple of quick sanity checks in there already, we just need a couple of negative test values added. Thanks! |
The tests are running on the PR of branch i307. I added some relevant tests for tgamma for both positive and negative real values in the neighborhood of the origin. Let's make sure the tests cycle... Thanks folks for helping on this issue. Kind regards, Chris |
Oh... Another remark. |
Thanks a lot for fixing this :) |
Fixed in Multiprecision PR #185. |
Closed issue. Thanks folks. |
Hi,
As suggested in #303 I submit a separate bugreport here:
the tgamma function for float128 produces incorrect results for negative arguments. I had to implement a following workaround in my code:
The text was updated successfully, but these errors were encountered: