Skip to main content

solve_on_change_sublinear_auto

Function solve_on_change_sublinear_auto 

Source
pub fn solve_on_change_sublinear_auto(
    matrix: &dyn Matrix,
    prev_solution: &[Precision],
    b_new: &[Precision],
    delta: &SparseDelta,
    tolerance: Precision,
) -> Result<Vec<(usize, Precision)>>
Expand description

Magic-number-free sibling of solve_on_change_sublinear. Takes only (matrix, prev, b_new, delta, tolerance) and auto-tunes both closure_depth and max_terms from the matrix’s coherence margin via crate::coherence::optimal_neumann_terms.

The kth Neumann iterate touches rows up to k hops away from the seeds; the closure must cover at least that radius. So closure_depth == max_terms is the tight choice — wider wastes work, narrower under-covers the support of the iterate.

Caller’s contract collapses to: “here’s tolerance, give me back what changed”. Suitable for downstream code that doesn’t want to reason about ρ ≤ 1 - c at every call site.

§Behaviour

  • On a strict-DD matrix: auto-tunes from coherence_score(matrix) and dispatches to solve_on_change_sublinear.
  • On a non-strict-DD matrix (coherence ≤ 0): returns SolverError::Incoherent. The Neumann-envelope bound doesn’t hold there, so auto-tuning would silently lie. Caller must fall back to a full solve or to the hand-tuned API.
  • Empty delta short-circuits to an empty result without consuming coherence — the “no event, no work” path is preserved.

§Complexity

Same as solve_on_change_sublinear: SubLinear in n for sparse DD matrices. Adds one O(nnz(A)) coherence-score pass per call — callers running many events should compute coherence once and use the manual API instead.