gmres [ITL Home] Programmers Guide
  Contents | Index |  Search 


Category:itl,algorithms Component type:function
Prototype
template < class Matrix, class Vector, class VectorB, class Preconditioner, class Iter, class Basis >
int gmres(const Matrix &A, Vector &x, const VectorB &b, const Preconditioner &M, int m, Iter& outer, Basis& KS) ;
Description
This solve the unsymmetric linear system Ax = b using restarted GMRES.

The algorithm can be chosen to perform the modified Gram-Schmidt orthogonalization or the classical Gram-Schmidt orthogonalization with one iterative refinement depending on the Basis. The latter usually has better performance in mordern architecture.

A return value of 0 indicates convergence within the maximum number of iterations (determined by the iter object). A return value of 1 indicates a failure to converge.

On instantiating Iteration object outer, the first parameter Vector w must be the precondtioned one, i.e., M.solve(b, w) where b is right side of linear system. See test_gmres.cc for example.

See: Y. Saad and M. Schulter. GMRES: A generalized minimum residual algorithm for solving nonsysmmetric linear systems, SIAM J. Sci. Statist. Comp. 7(1986), pp, 856-869

Definition
gmres.h
Preconditions
Complexity
Example
In gmres.cpp:
typedef matrix< Type, 
                rectangle<>, 
	        array< compressed<> >, 
                row_major >::type Matrix;
  Matrix A(5, 5);
  //SSOR preconditioner
  SSOR<Matrix> precond(A);
  SSOR<Matrix>::Precond p = precond();

  dense1D<Type> b2(A.ncols());
  solve(p, b, b2); //gmres needs teh preconditioned b to pass into iter object.
  //iteration
  noisy_iteration<double> iter(b2, max_iter, 1e-6);
  
  int restart = 10; //restart constant: 10
  classical_gram_schmidt<dense1D<Type> > KS(restart, size(x));

  //gmres algorithm
  gmres(A, x, b, p, restart, iter, KS); 

Notes
See also

[ITL Home] Copyright © 1998,1999 University of Notre Dame. All Rights Reserved.