Preconditioned conjugate gradient method for solving system of linear equations Ax = b, where A is symmetric and positive definite, b is a column vector.
pcgsolve(A, b, preconditioner = "Jacobi", tol = 1e-6, maxIter = 1000)
matrix, symmetric and positive definite.
vector, with same dimension as number of rows of A.
string, method for preconditioning: "Jacobi"
(default), "SSOR"
, or "ICC"
.
numeric, threshold for convergence, default is 1e-6
.
numeric, maximum iteration, default is 1000
.
Returns a vector representing solution x.
Jacobi
: The Jacobi preconditioner is the diagonal of the matrix A, with an assumption that all diagonal elements are non-zero.
SSOR
: The symmetric successive over-relaxation preconditioner, implemented as \(M = (D+L) D^{-1} (D+L)^T\). [1]
ICC
: The incomplete Cholesky factorization preconditioner. [2]
Users need to check that input matrix A is symmetric and positive definite before applying the function.
When the condition number for \(A\) is large, the conjugate gradient (CG) method may fail to converge in a reasonable number of iterations. The Preconditioned Conjugate Gradient (PCG) Method applies a precondition matrix \(C\) and approaches the problem by solving: $${C}^{-1} A x = {C}^{-1} b$$ where the symmetric and positive-definite matrix \(C\) approximates \(A\) and \({C}^{-1} A \) improves the condition number of \(A\).
Common choices for the preconditioner include: Jacobi preconditioning, symmetric successive over-relaxation (SSOR), and incomplete Cholesky factorization [2].
[1] David Young. <U+201C>Iterative methods for solving partial difference equations of elliptic type<U+201D>. In: Transactions of the American Mathematical Society 76.1 (1954), pp. 92<U+2013>111.
[2] David S Kershaw. <U+201C>The incomplete Cholesky<U+2014>conjugate gradient method for the iter- ative solution of systems of linear equations<U+201D>. In: Journal of computational physics 26.1 (1978), pp. 43<U+2013>65.
# NOT RUN {
test_A <- matrix(c(4,1,1,3), ncol = 2)
test_b <- matrix(1:2, ncol = 1)
pcgsolve(test_A, test_b, "ICC")
# }
Run the code above in your browser using DataLab