Skip to main content

sparse_solve_ndarray

Function sparse_solve_ndarray 

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

Solve a sparse linear system A * x = b using Conjugate Gradient.

This function solves the system using the CG iterative method, which requires A to be symmetric positive definite (SPD). For non-SPD matrices, consider using other solvers.

§Arguments

  • a - Sparse CSR matrix (n x n), must be SPD
  • b - Right-hand side vector (length n)

§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