Fix NaN lanes in the default SimdComplexField::simd_to_exp - #88
Open
marknefedov wants to merge 1 commit into
Open
Fix NaN lanes in the default SimdComplexField::simd_to_exp#88marknefedov wants to merge 1 commit into
marknefedov wants to merge 1 commit into
Conversation
The default implementation tested whether the modulus was zero on all lanes at once, so mixed zero/nonzero inputs took the division path and computed 0 / 0 on the zero lanes. The resulting NaNs propagated through simd_signum. The zero test is now lane-wise: the division uses a safe modulus and the identity result is selected on the zero lanes. Reachable through num_complex::Complex over any SIMD type that does not override the default (the Wide* wrappers among them); includes a regression test for the mixed-lane and all-zero cases.
marknefedov
marked this pull request as ready for review
August 14, 2026 21:32
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.
The default
simd_to_exptests whether the modulus is zero with a whole-vectoris_zero. An input with mixed zero and nonzero lanes takes the division path and computes 0/0 on the zero lanes; the NaNs propagate throughsimd_signum.The zero test is now lane-wise: the division uses a safe modulus (1 on the zero lanes) and the identity result is selected for those lanes afterwards. All-zero and all-nonzero inputs behave exactly as before.
Reachable through
num_complex::Complexover any SIMD type that does not override the default, including theWide*wrappers. Includes a regression test for the mixed-lane and all-zero cases.