Repository navigation
Conversation
Complex sqrt lost the imaginary sign of zero and selected the wrong side of the negative-real branch cut for inputs such as (-4, -0). Infinite imaginary components also entered the finite calculation, producing NaN instead of an infinite imaginary result. Preserve the input imaginary zero and use copysign when constructing roots with negative real inputs. Handle infinities and NaNs explicitly before the finite calculation, while retaining the scaled formula for ordinary inputs. Document the principal-root convention and add runtime and CTFE regressions across float, double, and real, covering branch-cut signs, nonfinite values, and extreme finite magnitudes. AI-Assisted-By: Codex (GPT-6 Astra Medium)
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.
Correct complex square roots at signed-zero branch cuts and for
nonfinite inputs. For example, sqrt(-4 - 0i) now returns +0 - 2i,
and sqrt(1 + ∞i) returns ∞ + ∞i instead of ∞ + NaNi.
Preserve the imaginary sign of zero and use copysign when constructing
roots with negative real inputs. Handle infinities and NaNs explicitly
while retaining the scaled formula for ordinary finite inputs.
Document the principal-root convention and add runtime and CTFE
regressions across float, double, and real. Tests cover branch-cut
signs, nonfinite values, extreme finite magnitudes, and ordinary
numerical accuracy.
Validation:
The regressions retain the existing mir_core_test guard convention.
They ran locally, but the current CI coverage configuration omits that
version identifier. PR #94 contains the configuration fix needed for
CI to run these guarded tests. The sqrt implementation is otherwise
independent of that PR.
AI-Assisted-By: Codex (GPT-6 Astra Medium)