Repository navigation
Preserve the imaginary zero sign in complex log1p - #1438
Draft
agourakis82 wants to merge 1 commit into
Draft
agourakis82 wants to merge 1 commit into
agourakis82 wants to merge 1 commit into
Conversation
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
log1p(-2 - 0i)returns+piinstead of-piin its imaginary component. The complex addition inu = 1 + zadds a positive imaginary zero to the input, losing the negative-zero side of the branch cut beforelog(u)is evaluated.Translate only the real component and copy the imaginary component unchanged. Preserve the existing small-input correction. Add mixed-lane float/double coverage on both sides of the cut, immediately below
-1, at the origin, and for nonzero-imaginary controls. The reference explicitly constructs(1 + real(z), imag(z))before scalarstd::logso it also preserves the zero sign.Validation (C++23):
94a8f71passes 12 cases / 2112 assertions (CPU-only Slurm20310), including infinite argument pairs and both zero signs at the endpoint z = -1. That endpoint remains outside this PR alone.log1p(-2 - 0i).Addresses the reported
log1pbranch-cut example in #1432. The exact endpointz = -1remains outside this fix: a separate reproducer confirms that existinglog(0 +/- 0i)inherits a NaN angle fromatan2(0, 0)on the baseline and candidate. New signed-zero assertions are excluded under fast-math. No claim of complete #1432 resolution, nonfinite coverage, exception freedom, full-suite or all-architecture validation.