23.12.2012 Views

MATLAB Function Reference Volume 1: A - E - Bad Request

MATLAB Function Reference Volume 1: A - E - Bad Request

MATLAB Function Reference Volume 1: A - E - Bad Request

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

2cgs<br />

Purpose Conjugate Gradients Squared method<br />

Syntax x = cgs(A,b)<br />

cgs(A,b,tol)<br />

cgs(A,b,tol,maxit)<br />

cgs(A,b,tol,maxit,M)<br />

cgs(A,b,tol,maxit,M1,M2)<br />

cgs(A,b,tol,maxit,M1,M2,x0)<br />

cgs(afun,b,tol,maxit,m1fun,m2fun,x0,p1,p2,...)<br />

[x,flag] = cgs(A,b,...)<br />

[x,flag,relres] = cgs(A,b,...)<br />

[x,flag,relres,iter] = cgs(A,b,...)<br />

[x,flag,relres,iter,resvec] = cgs(A,b,...)<br />

Description x = cgs(A,b) attempts to solve the system of linear equations A*x = b for x.<br />

The n-by-n coefficient matrix A must be square and the column vector b must<br />

have length n. A can be a function afun such that afun(x) returns A*x.<br />

If cgs converges, a message to that effect is displayed. If cgs fails to converge<br />

after the maximum number of iterations or halts for any reason, a warning<br />

message is printed displaying the relative residual norm(b-A*x)/norm(b) and<br />

the iteration number at which the method stopped or failed.<br />

cgs(A,b,tol) specifies the tolerance of the method, tol. Iftol is [], then cgs<br />

uses the default, 1e-6.<br />

cgs(A,b,tol,maxit) specifies the maximum number of iterations, maxit. If<br />

maxit is [] then cgs uses the default, min(n,20).<br />

cgs(A,b,tol,maxit,M) and cgs(A,b,tol,maxit,M1,M2) use the<br />

preconditioner M or M = M1*M2 and effectively solve the system<br />

inv(M)*A*x = inv(M)*b for x. If M is [] then cgs applies no preconditioner. M<br />

can be a function that returns M\x.<br />

cgs(A,b,tol,maxit,M1,M2,x0) specifies the initial guess x0. If x0 is [], then<br />

cgs uses the default, an all-zero vector.<br />

cgs<br />

2-235

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!