Summary
Make the internal det_errbound() function public so consumers can build their own adaptive-precision logic.
Current State
det_sign_exact() internally uses det_errbound() to compute conservative absolute error bounds on det_direct(). These bounds determine whether the f64 fast filter can resolve the sign without falling through to exact Bareiss arithmetic. However, this function is private — consumers cannot access the error bounds directly.
The error bound constants are:
- D=2:
ERR_COEFF_2 = 3ε + 16ε²
- D=3:
ERR_COEFF_3 = 8ε + 64ε²
- D=4:
ERR_COEFF_4 = 12ε + 128ε²
- D≥5: No fast bound (returns
None)
Proposed Changes
Expose a public method on Matrix<D>:
pub fn det_errbound(&self) -> Option<f64>
Returns Some(bound) for D ≤ 4 such that |det_direct() - det_exact| ≤ bound, or None for D ≥ 5.
Benefits
- Consumer-side adaptive precision: Crates like delaunay currently implement their own ad-hoc adaptive tolerance logic (
adaptive_tolerance() based on infinity norm). Exposing rigorous Shewchuk-style error bounds would let them make mathematically grounded decisions about when f64 is sufficient vs. when exact arithmetic is needed.
- Insphere predicates: The insphere predicate needs the determinant sign of a (D+1)×(D+1) or (D+2)×(D+2) matrix. Consumers could use the error bound to decide whether to trust the f64 determinant or fall through to
det_sign_exact(), without reimplementing the bound computation.
- Zero implementation cost: The function already exists and is tested; this is purely an API visibility change.
Implementation Notes
- No feature gate needed — the bounds are pure f64 arithmetic, independent of the
exact feature
- Consider also exposing the per-dimension error coefficients as public constants (
ERR_COEFF_2, etc.) for documentation/testing purposes
- The return type
Option<f64> naturally communicates that bounds are unavailable for D ≥ 5
Co-Authored-By: Oz oz-agent@warp.dev
Summary
Make the internal
det_errbound()function public so consumers can build their own adaptive-precision logic.Current State
det_sign_exact()internally usesdet_errbound()to compute conservative absolute error bounds ondet_direct(). These bounds determine whether the f64 fast filter can resolve the sign without falling through to exact Bareiss arithmetic. However, this function is private — consumers cannot access the error bounds directly.The error bound constants are:
ERR_COEFF_2 = 3ε + 16ε²ERR_COEFF_3 = 8ε + 64ε²ERR_COEFF_4 = 12ε + 128ε²None)Proposed Changes
Expose a public method on
Matrix<D>:Returns
Some(bound)for D ≤ 4 such that|det_direct() - det_exact| ≤ bound, orNonefor D ≥ 5.Benefits
adaptive_tolerance()based on infinity norm). Exposing rigorous Shewchuk-style error bounds would let them make mathematically grounded decisions about when f64 is sufficient vs. when exact arithmetic is needed.det_sign_exact(), without reimplementing the bound computation.Implementation Notes
exactfeatureERR_COEFF_2, etc.) for documentation/testing purposesOption<f64>naturally communicates that bounds are unavailable for D ≥ 5Co-Authored-By: Oz oz-agent@warp.dev