Skip to content

v1.10.0 — C++ Engine Audit & Hardening

Choose a tag to compare

@evandeilton evandeilton released this 17 May 16:41
· 6 commits to main since this release

C++ Engine — Comprehensive Audit & Hardening

Full static audit of the C++ engine covering all 36 binning algorithms. Zero public R API changes — fully backward compatible.

Bug Fixes

  • OB_LogisticRegression — Threshold-based singularity guard; Eigen::LDLT replaces hessian.inverse(); cwiseMax(0) prevents NaN SEs
  • OBN_MDLP monotonicity directionis_monotonic() / enforce_monotonicity() now auto-detect ascending vs descending trend (Welford slope); previously hardcoded ascending caused unnecessary merges on negative correlations
  • OBC_DP backtracking OOB — Guard before static_cast<size_t>(prev_j); invalid index raises descriptive error instead of UB
  • OBN_DP push-before-validate — Target validation now fires before target_vec.push_back()
  • OBN_MDLP log2(0) — Guard for single-bin MDL cost
  • NumericalBin constructorcount always derived from count_pos + count_neg; invariant enforced at construction time

Performance

  • OBC_DP DP outer loop removed — Deterministic DP was wrapped in a redundant 1000-iteration loop; up to 1000× speedup
  • OBC_DP::ensure_max_prebins() — O(m² log m) full re-sort per merge → O(m) binary-search insertion
  • OBN_MDLP::apply_mdl_merging() — O(k³) full-vector copy per candidate → O(k²) analytical MDL delta
  • OBN_BB::quantile() — O(n_prebins × n log n) per-call sorts → single sort in prebinning()
  • OBN_DP correlation — Naive Pearson (catastrophic cancellation) → Welford's online algorithm

CRAN / ODR Safety

  • safe_math.hconstexprinline for 6 math functions (SOLARIS/Studio compat)
  • chi_square_utils.h — Namespace-scope const map → static local function (one copy per process)
  • entropy_utils.h — 81 KB ENTROPY_LUT per-TU → shared static local instance
  • OBC_CM_v5 — Duplicate ChiSquareCache class removed; uses shared header
  • 35 .cpp files — Duplicate using namespace Rcpp before #include headers removed

Code Quality

  • Dead commented-out code blocks removed (OBC_DP)
  • Variable shadowing fixed (OBN_DP: total_countrare_total)
  • [[Rcpp::plugins(cpp11)]] standardised across all files
  • Auto monotonicity detection implemented for categorical DP ("auto" trend)