Learn R Programming

pcg (version 1.1)

pcg: Preconditioned Conjugate Gradient algorithm for solving Ax=b

Description

The function solves linear system of equations Ax=b by Preconditioned Conjugate Gradient algorithm. Here matrix A must be real symmetric and positive definite. This can also be used to minimize the quadractic function (x'Ax)/2-bx.

Usage

pcg(A, b, M, maxiter = 1e+05, tol = 1e-06)

Arguments

A
A is real symmetric positive definite matrix of order n x n.
b
b is a vector of order n x 1.
M
Optionally a suitable preconditioner matrix specified by user
maxiter
Maximum number of iterations
tol
Tolerance for convergence of the solution

Value

References

Barrett, R., M. Berry, T. F. Chan, et al., (1994). Templates for the Solution of Linear Systems: Building Blocks for Iterative Methods, SIAM, Philadelphia.

Examples

Run this code
A=matrix(rnorm(100*100,mean=10,sd=2),100,100)
A=t(A)%*%A
b=rnorm(100)
pcg(A,b)

Run the code above in your browser using DataLab