tests: pin exact golden values for deterministic math#3
Merged
Conversation
…margins) The library advertises bit-exact determinism, but several transcendental tests asserted only accuracy-vs-std within a tolerance (`fabs(lib - ref) < tol`), which does not verify reproducibility. Replace the fixed-input margins with exact `==` against the library's own output, turning them into determinism/regression locks that the multi-arch CI matrix (x64 + ARM, GCC/Clang/MSVC/AppleClang) now verifies. - test_cmath_double.cpp: sin_core, real-arith compose, sqrt(9), sin/cos(47°), sin(180°) → exact hex-float / exact constants (drop the unused std oracle + sv). - test_coverage_corners.cpp: d_cbrt / d_atan2 axis cases → exact golden doubles. - test_storage_flags.cpp: atan/atan2 on a real grid → exact grid values (verified bit-identical on BOTH the double and CORDIC engines). Kept margins only where they remain meaningful: range sweeps vs std (accuracy of the approximation) and the random-input fuzz harness (no fixed golden). Local: double 352/352, CORDIC 395/395. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…grids New tests/test_determinism.cpp pins the exact (==) output of asin, acos, sinh, cosh, tanh, log10, hypot, pow — plus added corner cases for sqrt, cbrt, atan, atan2, sin, cos, tan — across a VARIETY of grids (notch 1/256…1/65536, different intervals, real storage) and domain corners (0, ±1, edges, axes, quadrants), and the sqrt error path. ~110 exact assertions; values captured from the library and verified bit-identical on BOTH engines except one coarse-grid sinh (per-engine #ifdef). Locks bit-exact determinism, now checked across the x64+ARM × GCC/Clang/ MSVC/AppleClang matrix. Local: double 361/361, CORDIC 404/404. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ue-identical State explicitly that the double and integer/CORDIC engines, while each bit-reproducible per engine, can differ by up to one output notch on some transcendental inputs (table-maker's dilemma — worked sinh(4) example), so switching engines is NOT value-preserving: golden/record-replay data is valid within one engine only. Corrects math.md's "interchangeable" / "value does not depend on the engine" claims; adds a per-engine caveat to determinism.md's TL;DR and a new subsection. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Per the determinism guarantee, fixed-input transcendental tests now assert the library's exact output (
==) instead of accuracy-within-a-margin (fabs(lib - std) < tol). A tolerance verifies accuracy, not the bit-exact reproducibility the library advertises; exact golden pins turn these into determinism/regression locks that the multi-arch matrix (x64 + ARM64 Linux, macOS ARM, MSVC x64 + ARM) verifies.test_cmath_double.cpp:sin_core, real-arithmetic compose,sqrt(9),sin/cos(47°),sin(180°)→ exact.test_coverage_corners.cpp:d_cbrt/d_atan2axis cases → exact golden doubles.test_storage_flags.cpp:atan/atan2on a real grid → exact grid values (bit-identical on both the double and CORDIC engines — confirmed locally).Kept margins only where they stay meaningful: range sweeps vs std (approximation accuracy) and the random-input fuzz harness (no fixed golden).
Local: double 352/352, CORDIC 395/395. This PR's cross-platform run is the real determinism check — if any golden pin fails on another compiler/arch, that's a genuine determinism finding to fix in the library.
🤖 Generated with Claude Code