Package 'pcg'

Title: Preconditioned Conjugate Gradient Algorithm for solving Ax=b
Description: The package solves linear system of equations Ax=b by using Preconditioned Conjugate Gradient Algorithm where A is real symmetric positive definite matrix. A suitable preconditioner matrix may be provided by user. This can also be used to minimize quadratic function (x'Ax)/2-bx for unknown x.
Authors: B N Mandal <[email protected]> and Jun Ma <[email protected]>
Maintainer: B N Mandal <[email protected]>
License: GPL (>= 2)
Version: 1.1
Built: 2025-01-23 05:25:20 UTC
Source: https://github.com/cran/pcg

Help Index


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

A vector of order n x 1

Note

The algorithm does not check for symmetricity and positive definiteness of matrix A. Please ensure these conditions yourself.

Author(s)

B N Mandal and Jun Ma

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

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