math: expose explicit engine namespaces cordic:: and dbl::#6
Merged
Conversation
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>
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 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::fnstays an alias for the build default.bnd::math::cordic::fnbnd::math::dbl::fndoubleBND_MATH_NO_FPbnd::math::fncordicunderBND_MATH_FIXED/BND_MATH_NO_FP, elsedblThe 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*_implcores;dbl::wraps the*_corecores (plus the inlinetan/signed-sqrt/pow_base/powdouble logic).dbl::is gated behind!BND_MATH_NO_FP: under the FP-free build adbl::call is a compile error;cordic::always works.Proof
tests/test_math_engines.cppinstantiates 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 throughexpectedunder both, and that the unqualified name matches the build's default engine bit-for-bit.Verification
single_header_nofp_smoke); amalgamation regenerated, drift check green🤖 Generated with Claude Code