pub fn conjugate_gradient(
a: &SparseMatrix,
b: &[f64],
initial: Option<&[f64]>,
options: ConjugateGradientOptions,
) -> NumericResult<ConjugateGradientSolution>Expand description
Solve A x = b for a symmetric positive definite sparse A by the
Jacobi-preconditioned conjugate-gradient method, starting from
initial (zero when None).
A run that exhausts its budget still returns its last iterate and
residual with Status::BudgetExhausted; call
ConjugateGradientSolution::converged to refuse it. A zero b returns
the exact zero solution without iterating.
ยงErrors
NumericError::DimensionMismatchfor a non-square matrix or a wrongly sizedborinitial.NumericError::NonFiniteInputfor a non-finiteborinitial,NumericError::InvalidArgumentfor a negative or non-finite tolerance.NumericError::NotSymmetricfor an asymmetric matrix.NumericError::NotPositiveDefinitewhen a diagonal entry is not positive (pivotis its row) or when the iteration meets a directionpwithp^T A p <= 0, which provesAis not positive definite (pivotis the iteration).