Repository navigation
Preserve imaginary sign in complex tan overflow handling - #1434
Draft
agourakis82 wants to merge 1 commit into
Draft
agourakis82 wants to merge 1 commit into
agourakis82 wants to merge 1 commit into
Conversation
When sinh(2*imag(z)) overflows, retain its sign in the saturated imaginary result instead of returning +1 unconditionally. Add mixed-lane finite-input regressions for float and double, including both signs, maximum finite imaginary magnitudes and ordinary controls. Validated with C++23: native arm64 complete CMake suite and focused ASan/UBSan; native GCC13 SSE2 and AVX2 before/after tests in Slurm17825. Other complex functions, fast-math and real signed-zero discrepancies remain outside this change. Assisted-by: OpenAI Codex
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For complex inputs with a sufficiently large negative imaginary part,
xsimd::tanreturns an imaginary component of +1 instead of -1. For example,tan(complex<float>(1, -45))andtan(complex<double>(1, -356))both produce(0, +1)on the unchanged base, whilestd::tanproduces(0, -1).The overflow handling detects
isinf(sinh(2 * imag(z)))but selects +1 for either sign. Usecopysignto retain the overflowing value's sign. The denominator-zero handling and the fast-math path are unchanged.Add float/double regression tests with mixed SIMD lanes, both imaginary signs, zero/nonzero real parts, maximum finite imaginary magnitudes and ordinary finite controls. The tests check finite results and both component values against a C++23 scalar reference.
Validation on base
ebe9991plus this patch:This addresses only the imaginary saturation-sign cases in #1432 and should not close the issue. The original reproducer also exposes real-component signed-zero differences, which remain outside this patch. The remaining tan pole cases, other complex functions and fast-math behavior are not addressed here. This is independent of the finite-real-axis sqrt correction in #1433.
AI assistance supported investigation, implementation and validation. A local model review was attempted but did not return within the bounded review window; the results above are executable checks, not model approval.