This implements the classic GMRES(m) method for solving the system
The main advantage of the GMRES method is that it only requires calculations of multiplies by
Whereas m is traditionally a small number, e.g. 3 or 4, the additional constraint renders restarts difficult. If the constraint is important, then m must be chosen sufficiently large to solve to the desired accuracy within m iterations.
The implementation can be supplied a preconditioner routine. (This can be avoided if combined with timestepping; see the remarks at Arnoldi.
GMRES is likely to find it easier to solve
- The Fortran implementation requires the LAPACK package.
- The constraint
$||{\bf x}||<\delta$ may be ignored by supplying negative del. - In addition to scalar and array variables, the routine needs to be passed
- an external function that calculates dot products,
- an external subroutine that calculates the result of multiplication by
$A$ , - an external subroutine that replaces a given vector
${\bf x}$ with the solution${\bf x}'$ of the system$M{\bf x}'={\bf x}$ . This may simply be an empty subroutine if no preconditioner is required, i.e.$M=I$ .
- The functions above may require auxiliary data in addition to
${\bf x}$ or${\bf \delta x}$ . Place this data in a module and access via use mymodule in the function/subroutine, or (MATLAB) place inglobal
variables.
It is NOT necessary to edit this code for parallel (MPI) use:
- let each thread pass its subsection for the vector
${\bf x}$ , - make the dot product function mpi_allreduce the result of the dot product.
- to avoid multiple outputs to the terminal, set info=1 on rank 0 and info=0 for the other ranks.