Navigation

Operators and Keywords

Function List:

C++ API

: x = qmr (A, b, rtol, maxit, M1, M2, x0)
: x = qmr (A, b, rtol, maxit, P)
: [x, flag, relres, iter, resvec] = qmr (A, b, …)

Solve A x = b using the Quasi-Minimal Residual iterative method (without look-ahead).

  • - rtol is the relative tolerance, if not given or set to [] the default value 1e-6 is used.
  • - maxit the maximum number of outer iterations, if not given or set to [] the default value min (20, numel (b)) is used.
  • - x0 the initial guess, if not given or set to [] the default value zeros (size (b)) is used.

A can be passed as a matrix or as a function handle or inline function f such that f(x, "notransp") = A*x and f(x, "transp") = A'*x.

The preconditioner P is given as P = M1 * M2. Both M1 and M2 can be passed as a matrix or as a function handle or inline function g such that g(x, "notransp") = M1 \ x or g(x, "notransp") = M2 \ x and g(x, "transp") = M1' \ x or g(x, "transp") = M2' \ x.

If called with more than one output parameter

  • - flag indicates the exit status:
    • - 0: iteration converged to the within the chosen tolerance
    • - 1: the maximum number of iterations was reached before convergence
    • - 3: the algorithm reached stagnation

    (the value 2 is unused but skipped for compatibility).

  • - relres is the final value of the relative residual.
  • - iter is the number of iterations performed.
  • - resvec is a vector containing the residual norms at each iteration.

References:

  1. R. Freund and N. Nachtigal, QMR: a quasi-minimal residual method for non-Hermitian linear systems, Numerische Mathematik, 1991, 60, pp. 315-339.
  2. R. Barrett, M. Berry, T. Chan, J. Demmel, J. Donato, J. Dongarra, V. Eijkhour, R. Pozo, C. Romine, and H. van der Vorst, Templates for the solution of linear systems: Building blocks for iterative methods, SIAM, 2nd ed., 1994.

See also: bicg, bicgstab, cgs, gmres, pcg.

Demonstration 1

The following code

 % Solve system of A*x=b
 A = [5 -1 3;-1 2 -2;3 -2 3];
 b = [7;-1;4];
 [x, flag, relres, iter, resvec] = qmr (A, b)

Produces the following output

x =

   1.00000
   1.00000
   1.00000

flag = 0
relres =    1.2545e-14
iter =  3
resvec =

   8.1240e+00
   1.5301e+00
   5.8757e-02
   1.0192e-13

Package: octave