Back to Sparse Matrices

gmres

Generalized minimum residual method

Syntax

x = gmres(A, b)
x = gmres(A, b, restart, tol, maxit)
[x, flag, relres, iter] = gmres(...)

Description

Solves the linear system Ax = b using the GMRES iterative method. Suitable for general (non-symmetric) sparse systems.

Parameters

NameDescription
ASparse coefficient matrix (n x n)
bRight-hand side vector
restart(optional)Restart parameter (default 20)
tol(optional)Convergence tolerance (default 1e-6)
maxit(optional)Maximum iterations

Returns

Solution vector x, or [x, flag, relres, iter]

Examples

Try It
>> A = speye(3); b = [1;2;3];
x = gmres(A, b)

See Also