Skip to content

cgs

sparse · scripts/sparse/cgs.m

x = cgs (A, b, tol, maxit, M1, M2, x0)
[x, flag, relres, iter, resvec] = cgs (...)

Conjugate gradients squared for A*x = b with a general square A.  A is a
matrix or a function handle returning A*x; the preconditioner is
M = M1*M2 (matrices or handles returning M\x).
flag: 0 converged, 1 maxit reached, 2 preconditioner failure,
3 stagnation, 4 breakdown.