Commit dc21f03
peng.li24
fix: 0 ULP for all APIs — 5 edge-case corrections
log f32 (AVX-512): add NaN passthrough after integer bit-ops strip NaN pattern
- _mm512_cmp_ps_mask(x, x, _CMP_UNORD_Q) detects NaN; blend back original x
log f32 (scalar): npy_logf(-0.0) returned NaN instead of -inf
- zero check (bits & 0x7fffffff == 0) must precede sign-bit check
- -0.0 has bits=0x80000000 → sign bit was triggering NaN path first
sin f32 (AVX-512): sin(±0.0) returned +0.0 instead of preserving sign
- fma(sp, r, r) with r=±0 yields +0.0 by IEEE 754 RN rule
- _mm512_cmp_ps_mask(x, zero, _CMP_EQ_OQ) catches both ±0; blend back x
sign(): sign(NaN) returned 0.0 instead of NaN
- ordered comparisons (>, <) with NaN always return false → T(0-0)=0
- fix: std::isnan guard before comparison expression
unwrap(): two fixes
- NaN propagation: when dd=NaN, set cum_correct=NaN so all subsequent
outputs become NaN (matching numpy's cumsum-of-corrections behavior)
- f32 precision: replaced floor(a/b)*b with std::fmod+sign-correction
to match numpy's np.mod exactly (fmod is internally more precise)
All 548 tests pass. ULP scanner confirms 0 ULP on 131k+ random values
plus special cases (±0, ±inf, NaN) for every API.1 parent 32cd98a commit dc21f03
3 files changed
Lines changed: 26 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
| 279 | + | |
279 | 280 | | |
280 | 281 | | |
281 | 282 | | |
282 | 283 | | |
283 | 284 | | |
| 285 | + | |
284 | 286 | | |
285 | 287 | | |
286 | 288 | | |
| 289 | + | |
287 | 290 | | |
288 | 291 | | |
289 | 292 | | |
| |||
348 | 351 | | |
349 | 352 | | |
350 | 353 | | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
351 | 359 | | |
352 | 360 | | |
353 | 361 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
211 | | - | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
212 | 214 | | |
213 | 215 | | |
214 | 216 | | |
| |||
848 | 850 | | |
849 | 851 | | |
850 | 852 | | |
851 | | - | |
852 | | - | |
853 | | - | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
854 | 861 | | |
855 | | - | |
| 862 | + | |
| 863 | + | |
856 | 864 | | |
857 | 865 | | |
858 | 866 | | |
859 | 867 | | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
860 | 871 | | |
861 | | - | |
862 | 872 | | |
863 | 873 | | |
864 | 874 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| 108 | + | |
| 109 | + | |
108 | 110 | | |
109 | 111 | | |
110 | | - | |
111 | | - | |
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| |||
0 commit comments