pub fn gmres<T, F>(
apply_a: F,
b: &T,
x0: &T,
options: &GmresOptions,
) -> Result<GmresResult<T>, KrylovError>Expand description
Solve A x = b using GMRES (Generalized Minimal Residual Method).
This implements the restarted GMRES algorithm that works with abstract tensor types
through the TensorVectorSpace trait’s vector space operations.
§Algorithm
GMRES builds an orthonormal basis for the Krylov subspace
K_m = span{r_0, A r_0, A^2 r_0, ..., A^{m-1} r_0} and finds the
solution that minimizes ||b - A x|| over this subspace.
§Type Parameters
T- A tensor type implementingTensorVectorSpaceF- A function that applies the linear operator:F(x) = A x
§Arguments
apply_a- Function that applies the linear operator A to a tensorb- Right-hand side tensorx0- Initial guessoptions- Solver options
§Returns
A GmresResult containing the solution and convergence information.
§Errors
Returns an error when max_iter needs a Krylov workspace whose capacity
overflows or cannot be allocated (a KrylovError::InvalidOptions), when the operator and vectors have
incompatible shapes, when the affine coefficients are all zero (a
KrylovError::NoAffineCoefficient for affine solves), or when an
underlying tensor or backend operation fails (a KrylovError::Operation).
Non-convergence is reported through the result’s converged flag and does
not produce an error.
A right-hand side whose norm is not finite, which would make every relative
residual zero, is a KrylovError::NumericalBreakdown.