Repository navigation
Conversation
Handle zero imaginary components before the special-case and polar paths, returning the scalar exponential with the original imaginary zero. This preserves negative zero for zero and infinite real inputs and avoids a NaN imaginary component when a finite real exponential overflows. Remove the redundant imaginary-zero branches and cover signed zeros, infinities, NaN, and finite overflow and underflow at runtime and compile time for float, double, and real. AI-Assisted-By: Codex (GPT-6 Astra Medium)
Compute the logarithmic magnitude without forming a potentially overflowing or poorly rounded magnitude. Preserve small results near unit magnitude by accounting for cancellation in the squared norm. Use log1p at runtime and a bounded series during compile-time evaluation. Preserve the existing special-value and branch-cut handling. Add guarded regressions for large and subnormal inputs, near-unit cancellation, and calculation boundaries across floating-point types. 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.
Fix incorrect results in complex
expon the real axis and improve the range and accuracy of complexlog.For
exp, preserve the imaginary signed zero when the input lies on the real axis. Return the scalar exponential directly, avoiding a NaN imaginary component when a finite real exponential overflows.For
log, compute the logarithmic magnitude without first forming a magnitude that can overflow or lose subnormal precision. Near unit magnitude, compensate for rounding in the squared norm so cancellation does not erase small results or reverse their sign. Uselog1pat runtime and a bounded series during compile-time evaluation.The changes are split into separate exp and log commits. Regression tests retain the existing
mir_core_testguards and cover float, double, and real at runtime and compile time.Validation:
Upstream's current coverage build does not enable
mir_core_test, so it does not execute these guarded regressions. Local regression testing explicitly enabled them. The coverage-build correction is proposed separately in #94, and macOS CI fixes are proposed in #96.Extended-real compile-time range and precision remain limited by the underlying scalar log implementation in some configurations. This is tracked separately in dlang/phobos#11118.
AI-Assisted-By: Codex (GPT-6 Astra Medium)