FUNCTION REFERENCE

pcg

Preconditioned conjugate gradients for a symmetric positive definite system.

Preconditioned conjugate gradients for a symmetric positive definite system.

Syntax

x = pcg(A, b)

Syntax

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

A, M1 and M2 are dense or sparse matrices or function handles (afun(x) returns A*x, mfun(x) returns M\x). Defaults: tol 1e-6, maxit min(n,20). flag is 0 (converged), 1 (maxit reached), 2 (ill-conditioned preconditioner), 3 (stagnation) or 4 (breakdown). With one output it prints MATLAB's convergence message.

Example

[x, flag] = pcg([4 1; 1 3], [1; 2])   % x = [0.0909; 0.6364], flag = 0

Differences from MATLAB: Real dense or sparse matrices and real-valued function handles; complex systems are unsupported. A sparse A is used through sparse products (same values as full(A)); a sparse M1 or M2 is solved by substitution when triangular (same values as full) and otherwise factorized once per call by sparse LU. Singular dense preconditioners return flag 2 without MATLAB's singular-matrix warning.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.