Skip to main content

delta_below_solve_threshold

Function delta_below_solve_threshold 

Source
pub fn delta_below_solve_threshold(
    coherence: Precision,
    min_diag: Precision,
    delta_values: &[Precision],
    tolerance: Precision,
) -> bool
Expand description

Fast-path coherence-gated event filter. Returns true iff the supplied delta is small enough that, given the matrix’s (coherence, min_diag) pair, the induced change in x is guaranteed below tolerance — so a downstream solve can safely be skipped.

This is the “no event, no work” gate from the ADR-001 thesis. Cost is O(|δ|) — independent of n, independent of nnz(A). The (coherence, min_diag) pair is computed once per matrix at build time and reused across every event.

Returns false when:

  • tolerance <= 0 (gate disabled)
  • coherence <= 0 (not strict-DD — bound doesn’t hold; can’t skip)
  • min_diag <= 0
  • the bound ‖δ‖_∞ / (min_diag · coherence) exceeds tolerance (meaningful change may have happened — don’t skip)

§Examples

// Cache once.
let c = coherence_score(a);
let min_diag = (0..a.rows())
    .map(|i| a.get(i, i).unwrap_or(0.0).abs())
    .filter(|x| *x > 0.0)
    .fold(f64::INFINITY, |a, b| a.min(b));

// O(|delta|) check per event.
let tolerance = 1e-6;
for delta in deltas {
    if delta_below_solve_threshold(c, min_diag, &delta, tolerance) {
        // Skip the solve; the world didn't meaningfully change.
        continue;
    }
    // Otherwise: dispatch to solve_on_change_sublinear / contrastive / …
}