v1.10.0 — C++ Engine Audit & Hardening
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::LDLTreplaceshessian.inverse();cwiseMax(0)preventsNaNSEsOBN_MDLPmonotonicity direction —is_monotonic()/enforce_monotonicity()now auto-detect ascending vs descending trend (Welford slope); previously hardcoded ascending caused unnecessary merges on negative correlationsOBC_DPbacktracking OOB — Guard beforestatic_cast<size_t>(prev_j); invalid index raises descriptive error instead of UBOBN_DPpush-before-validate — Target validation now fires beforetarget_vec.push_back()OBN_MDLPlog2(0) — Guard for single-bin MDL costNumericalBinconstructor —countalways derived fromcount_pos + count_neg; invariant enforced at construction time
Performance
OBC_DPDP outer loop removed — Deterministic DP was wrapped in a redundant 1000-iteration loop; up to 1000× speedupOBC_DP::ensure_max_prebins()— O(m² log m) full re-sort per merge → O(m) binary-search insertionOBN_MDLP::apply_mdl_merging()— O(k³) full-vector copy per candidate → O(k²) analytical MDL deltaOBN_BB::quantile()— O(n_prebins × n log n) per-call sorts → single sort inprebinning()OBN_DPcorrelation — Naive Pearson (catastrophic cancellation) → Welford's online algorithm
CRAN / ODR Safety
safe_math.h—constexpr→inlinefor 6 math functions (SOLARIS/Studio compat)chi_square_utils.h— Namespace-scopeconstmap →staticlocal function (one copy per process)entropy_utils.h— 81 KBENTROPY_LUTper-TU → sharedstaticlocal instanceOBC_CM_v5— DuplicateChiSquareCacheclass removed; uses shared header- 35
.cppfiles — Duplicateusing namespace Rcppbefore#includeheaders removed
Code Quality
- Dead commented-out code blocks removed (
OBC_DP) - Variable shadowing fixed (
OBN_DP:total_count→rare_total) [[Rcpp::plugins(cpp11)]]standardised across all files- Auto monotonicity detection implemented for categorical DP (
"auto"trend)