-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
BUG: umath: Fix log1p for complex inputs. #24416
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
Conversation
It looks like the failures on Emscripten/Pyodide, musllinux_x86_64 and Cygwin are because the underlying complex log function If I run a C program that computes The unit test tolerances can be loosened a bit, but I'm tempted to make the tolerances of the tests platform-dependent. |
We can blocklist |
050dca3
to
29d09d5
Compare
After gh-24448 was merged, I expected all the tests to pass after I rebased, and in fact, the old failures no longer occur. The failure in the |
d3e5655
to
c4b94b6
Compare
Somehow these two lines
are causing The block of code where this happens, with my print-debugging included, is
The output captured in the test log is
The first output line is from a print earlier in the code, and the last two output lines are from prints that occur later. In the code shown, the first call of Those functions just assign NAN to memory locations. How could that result in FE_OVERFLOW being set? |
Of course, I search the web after my making my previous comment: https://stackoverflow.com/questions/69929589/is-it-considered-normal-that-f-nan-may-cause-raising-floating-point-exceptions TL;DR: On this particular test platform (Windows+clang), the |
b499e87
to
83fbe8a
Compare
Reimplement the complex log1p function. Use the log1p trick from Theorem 4 of Goldberg's paper "What every computer scientist should know about floating-point arithmetic". Include special handling of an input with imaginary part 0.0 to ensure the sign of the imaginary part of the result is correct and consistent with the complex log function. Closes numpygh-22609.
* Add utility functions npy_cmul@c@(z, w) and npy_cdiv@c@(z, w). * Use them in log1p for complex arithmetic.
With some compilers, NAN is expanded to an expression that is evaluated at runtime. That can cause various floating point exception flags to be set, including FE_OVERFLOW.
83fbe8a
to
ef231fc
Compare
Reimplement the complex log1p function. Use the log1p trick from Theorem 4 of Goldberg's paper "What every computer scientist should know about floating-point arithmetic". Include special handling of an input with imaginary part ±0.0 to ensure the sign of the imaginary part of the result is correct and consistent with the complex log function.
Closes gh-22609.