Repository navigation
Avoid NaN real components in complex tanh after overflow - #1435
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 the denominator cosh(2*real(z)) + cos(2*imag(z)) overflows, return the correctly signed saturated real component instead of the inf/inf quotient. Keep the ordinary finite path, imaginary formula and fast-math path unchanged. Add mixed-lane float/double regression tests. Validate unchanged-base failure and corrected results in C++23 on arm64, SSE2 and AVX2, focused ASan/UBSan and the complete arm64 CMake suite. Signed-zero discrepancies and floating-point exception behavior remain outside this fix. 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.
Complex
tanhcan return a NaN real component for finite inputs oncecosh(2 * real(z))overflows. The existing formula dividessinh(2 * real(z))by that denominator, producing an infinity/infinity quotient. The issue #1432 examples(356, 0)and(-400, 1)for double, and(45, 0)and(-100, 2)for float, reproduce this failure.When the denominator is infinite, select the correctly signed saturated real component. Keep the ordinary finite path, imaginary-component formula and fast-math path unchanged. A NaN denominator is not treated as an overflow saturation case.
Add mixed-lane float/double tests with both real signs, maximum finite real magnitude, zero/nonzero imaginary parts and ordinary finite controls. They check finite classification and component values against C++23
std::tanhwith floating-point tolerances; they do not assert zero sign bits.Validation from upstream
ebe9991:This addresses only the
tanhreal-overflow cases in #1432 and should not close that issue. Imaginary signed-zero/underflow behavior, floating-point exception flags, pole cases, fast-math and the remaining complex functions are outside this change. The branch starts from upstream master independently of #1433 and #1434.AI assistance supported investigation, implementation and native validation.