Skip to main content

solve_single_entry_neumann

Function solve_single_entry_neumann 

Source
pub fn solve_single_entry_neumann(
    matrix: &dyn Matrix,
    b: &[Precision],
    target: usize,
    max_terms: usize,
    tolerance: Precision,
) -> Result<Precision>
Expand description

Compute x[i] = e_iᵀ A⁻¹ b to within tolerance using closure-restricted Neumann iteration, without materialising the full solution vector.

§Parameters

  • matrix: a square, strictly diagonally dominant matrix A (with a non-zero diagonal at row target).
  • b: the right-hand side. b.len() must equal matrix.rows().
  • target: the row index i whose solution entry to compute.
  • max_terms: maximum number of Neumann terms. Picks the depth of the row-graph closure; pick ⌈log_{1/ρ}(‖b‖∞ / tolerance)⌉ for a strict ε bound, where ρ is the spectral radius of D⁻¹O.
  • tolerance: early-exit threshold on per-term contribution to x[i].

§Returns

Ok(x_i_estimate) — the truncated Neumann approximation to x[target].

§Errors

§Examples

let b = vec![1.0, 2.0, 3.0, 4.0];
// Compute only x[2], skipping x[0], x[1], x[3].
let x2 = solve_single_entry_neumann(a, &b, 2, /*max_terms=*/ 16, /*tol=*/ 1e-10).unwrap();