Skip to content

Fix NaN lanes in the default SimdComplexField::simd_to_exp - #88

Open
marknefedov wants to merge 1 commit into
dimforge:masterfrom
marknefedov:fix-simd-to-exp-nan
Open

Fix NaN lanes in the default SimdComplexField::simd_to_exp#88
marknefedov wants to merge 1 commit into
dimforge:masterfrom
marknefedov:fix-simd-to-exp-nan

Conversation

@marknefedov

@marknefedov marknefedov commented Aug 14, 2026

Copy link
Copy Markdown

The default simd_to_exp tests whether the modulus is zero with a whole-vector is_zero. An input with mixed zero and nonzero lanes takes the division path and computes 0/0 on the zero lanes; the NaNs propagate through simd_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::Complex over any SIMD type that does not override the default, including the Wide* wrappers. Includes a regression test for the mixed-lane and all-zero cases.

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
marknefedov marked this pull request as ready for review August 14, 2026 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant