Skip to main content

cg_solve

Function cg_solve 

Source
pub fn cg_solve<F>(
    a_op: F,
    b: &[f64],
    x0: &[f64],
    tol: f64,
    max_iter: usize,
) -> Vec<f64>
where F: Fn(&[f64]) -> Vec<f64>,
Expand description

Conjugate gradient solver

Solves Ax = b where A is a linear operator represented by a closure.

§Arguments

  • a_op - Closure that computes A*x
  • b - Right-hand side vector
  • x0 - Initial guess
  • tol - Convergence tolerance
  • max_iter - Maximum iterations

§Returns

Solution vector x