gmres

Function gmres 

Source
pub fn gmres<T, F>(
    apply_a: F,
    b: &T,
    x0: &T,
    options: &GmresOptions,
) -> Result<GmresResult<T>>
where T: TensorLike, F: Fn(&T) -> Result<T>,
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 TensorLike 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 implementing TensorLike
  • F - A function that applies the linear operator: F(x) = A x

§Arguments

  • apply_a - Function that applies the linear operator A to a tensor
  • b - Right-hand side tensor
  • x0 - Initial guess
  • options - Solver options

§Returns

A GmresResult containing the solution and convergence information.

§Errors

Returns an error if:

  • Vector space operations (add, sub, scale, inner_product) fail
  • The linear operator application fails