math: gate transcendentals on snap, not real (allow non-real grids)#4
Merged
Conversation
A transcendental result is rounded onto the operand's grid, so the real requirement is `snap` (rounding permission), not `real` (double storage). - cmath.hpp: require_real → require_snap (has_flag(.., snap)) at all 22 sites. Backward compatible: `real` ⊃ round_nearest ⊃ snap, so existing code is unchanged. - New capability: transcendentals now work on any snap-capable grid — integer grids and non-dyadic grids (e.g. notch<1,100>) — not just `real` ones. - cmath_double.hpp: the double engine assumed `real` I/O (implicit bound→double, which is explicit for non-real). Add `dbl::store<Out>(double)` (direct store for `real`, rational-snap for non-real) and route every *_core + the inline sqrt/pow/pow_base/tan #else sites through it with explicit `static_cast<double>` inputs. Make cmath_double.hpp self-contained (include bound.hpp). - Tests: test_math_snap_grids.cpp pins exact special values on non-real integer and 1/100 grids (engine-agnostic). docs/math.md updated. Single header regen. Local: double 362/362, CORDIC 405/405. 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.
Phase 1 of the math-engine plan. A transcendental's result is rounded onto the operand's grid, so the genuine requirement is
snap(rounding permission), notreal(double-backed storage).require_real→require_snapat all 22cmath.hppsites. Backward compatible (real ⊃ round_nearest ⊃ snap).bnd::mathtranscendentals now work on any snap-capable grid — plain integer grids and non-dyadic grids (e.g.notch<1,100>), not justrealones. Computed by the engine, snapped via exact rational rounding.realI/O (the implicitbound→doubleisexplicit(!real)). Addeddbl::store<Out>(double)(direct forreal, rational-snap for non-real) and routed every*_core+ the inlinesqrt/pow/pow_base/tansites through it with explicitstatic_cast<double>inputs.cmath_double.hppis now self-contained.realgrids — no change needed.tests/test_math_snap_grids.cpp: exact special values on non-realinteger and 1/100 grids (engine-agnostic, no margins).docs/math.mdupdated. Single header regenerated.Local: double 362/362, CORDIC 405/405.
🤖 Generated with Claude Code