pcg: Preconditioned Conjugate Gradient algorithm

View source: R/cg.precond.R

pcgR Documentation

Preconditioned Conjugate Gradient algorithm

Description

The function solve a symmetric positive definite system by left preconditioning the system Ax = b. The Preconditoined CG algorithm is implemented using the (preconditioner) M inner product.

Usage

pcg(
  A,
  b,
  x = rnorm(length(b)),
  m = length(b),
  tol = 1e-07,
  diag.comp = "aj",
  alpha = 1,
  L
)

Arguments

A

A symmetric positive definite matrix for the system Ax = b. No default value.

b

A right hand side vector in Ax = b. No default value.

x

An initial guess which is produces the first residual r. Default is a random vector.

m

Maximum number of iterations to be run. Default is length(b).

tol

The relative tolerance for residual norms. Default is 1e-7.

diag.comp

A type of diagonal compensation for IC(0) preconditioning. Default is "aj".

alpha

The scale of diagonal compensation. Default is 1.

L

The preconditioner to supply. If missing, the IC(0) is above parameters is computed.

Examples

A = matrix(rnorm(100^2), 100)
A = t(A)%*%A
b = rnorm(100)
res = pcg(A, b)
plot(solve(A, b), t="l")
lines(res$x, col="red")

abylayzhumekenov/lanczos documentation built on April 27, 2022, 9:54 a.m.