Skip to main content

sparse_solve_ndarray_with_options

Function sparse_solve_ndarray_with_options 

Source
pub fn sparse_solve_ndarray_with_options(
    a: &CsrMatrix<f64>,
    b: &Array1<f64>,
    tol: f64,
    max_iter: usize,
) -> Result<Array1<f64>, SparseNdarrayError>
Expand description

Solve a sparse linear system with custom tolerance and max iterations.

§Arguments

  • a - Sparse CSR matrix (n x n), must be SPD
  • b - Right-hand side vector (length n)
  • tol - Convergence tolerance (relative to norm of b)
  • max_iter - Maximum number of CG iterations

§Returns

Solution vector x, or an error if the solver fails

§Errors

Returns SparseNdarrayError if:

  • Matrix is not square
  • Dimensions don’t match
  • CG solver does not converge within max_iter