Skip to content

math: gate transcendentals on snap, not real (allow non-real grids)#4

Merged
NiceAndPeter merged 1 commit into
mainfrom
math-snap-gate
Jun 21, 2026
Merged

math: gate transcendentals on snap, not real (allow non-real grids)#4
NiceAndPeter merged 1 commit into
mainfrom
math-snap-gate

Conversation

@NiceAndPeter

Copy link
Copy Markdown
Owner

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), not real (double-backed storage).

  • require_realrequire_snap at all 22 cmath.hpp sites. Backward compatible (real ⊃ round_nearest ⊃ snap).
  • New capability: bnd::math transcendentals now work on any snap-capable grid — plain integer grids and non-dyadic grids (e.g. notch<1,100>), not just real ones. Computed by the engine, snapped via exact rational rounding.
  • The double engine assumed real I/O (the implicit bound→double is explicit(!real)). Added dbl::store<Out>(double) (direct for real, rational-snap for non-real) and routed every *_core + the inline sqrt/pow/pow_base/tan sites through it with explicit static_cast<double> inputs. cmath_double.hpp is now self-contained.
  • CORDIC engine already supported non-real grids — no change needed.
  • tests/test_math_snap_grids.cpp: exact special values on non-real integer and 1/100 grids (engine-agnostic, no margins). docs/math.md updated. Single header regenerated.

Local: double 362/362, CORDIC 405/405.

🤖 Generated with Claude Code

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>
@NiceAndPeter NiceAndPeter merged commit e91e98e into main Jun 21, 2026
16 checks passed
@NiceAndPeter NiceAndPeter deleted the math-snap-gate branch June 21, 2026 17:36
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