Skip to content

math: expose explicit engine namespaces cordic:: and dbl::#6

Merged
NiceAndPeter merged 1 commit into
mainfrom
math-engine-namespaces
Jun 22, 2026
Merged

math: expose explicit engine namespaces cordic:: and dbl::#6
NiceAndPeter merged 1 commit into
mainfrom
math-engine-namespaces

Conversation

@NiceAndPeter

Copy link
Copy Markdown
Owner

Phase 3 of the math-engine plan — explicit engine namespaces

Surface both math engines by name so a single binary can mix them per call site, while the unqualified bnd::math::fn stays an alias for the build default.

Namespace Engine Availability
bnd::math::cordic::fn integer / CORDIC always (constexpr, FPU-free)
bnd::math::dbl::fn double unless BND_MATH_NO_FP
bnd::math::fn the default cordic under BND_MATH_FIXED/BND_MATH_NO_FP, else dbl

The qualified entry points carry the same signatures, domains, auto-deduced output grids, and domain static_asserts as the unqualified API — only the compute backend differs.

No new math, additive, low-risk

  • cordic:: wraps the always-compiled *_impl cores; dbl:: wraps the *_core cores (plus the inline tan/signed-sqrt/pow_base/pow double logic).
  • dbl:: is gated behind !BND_MATH_NO_FP: under the FP-free build a dbl:: call is a compile error; cordic:: always works.
  • The existing public functions are untouched — zero regression risk; the namespaces are purely additive.

Proof

tests/test_math_engines.cpp instantiates both namespaces in one TU (templates only compile when used — the core proof), checks they agree on algebraically-exact inputs (sqrt(4), cos(0), …), that poles still error through expected under both, and that the unqualified name matches the build's default engine bit-for-bit.

Verification

  • default 401/401, CORDIC 442/442
  • all single-header smokes build (incl. single_header_nofp_smoke); amalgamation regenerated, drift check green

🤖 Generated with Claude Code

Surface both math engines by name so a single binary can mix them per call
site, while the unqualified bnd::math::fn stays an alias for the build default:

  bnd::math::cordic::fn  integer/CORDIC — ALWAYS present, constexpr, FPU-free
  bnd::math::dbl::fn     double engine  — present unless BND_MATH_NO_FP
  bnd::math::fn          the selected default (cordic under FIXED/NO_FP, else dbl)

The qualified entry points carry the same signatures, domains, auto-deduced
output grids, and domain static_asserts as the unqualified API — only the
backend differs. No new math: cordic:: wraps the always-compiled *_impl cores;
dbl:: wraps the *_core cores (and the inline tan/sqrt-signed/pow_base/pow double
logic). dbl:: is gated behind !BND_MATH_NO_FP, so under the FP-free build a dbl::
call is a compile error while cordic:: keeps working.

The existing public functions are untouched (zero regression risk); the engine
namespaces are purely additive.

New test_math_engines.cpp instantiates BOTH namespaces in one TU (templates only
compile when used) — the core proof of the feature — and checks they agree on
algebraically-exact inputs and that the unqualified name matches the default.

Verified: default 401/401, CORDIC 442/442, all single-header smokes build.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@NiceAndPeter NiceAndPeter merged commit 1875505 into main Jun 22, 2026
16 checks passed
@NiceAndPeter NiceAndPeter deleted the math-engine-namespaces branch June 22, 2026 18:38
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