cg: Solve linear systems using the conjugate gradients method
Description
Conjugate gradients (CG) method is an iterative algorithm for solving linear systems
with positive definite coefficient matrices.
Usage
cg(a, b, maxiter = 200, tol = 1e-7)
Value
a vector with the approximate solution, the iterations performed are returned
as the attribute 'iterations'.
Arguments
a
a symmetric positive definite matrix containing the coefficients of
the linear system.
b
a vector of right-hand sides of the linear system.
maxiter
the maximum number of iterations. Defaults to 200
tol
tolerance level for stopping iterations.
Warning
The underlying C code does not check for symmetry nor positive definitiveness.
References
Golub, G.H., Van Loan, C.F. (1996).
Matrix Computations, 3rd Edition.
John Hopkins University Press.
Hestenes, M.R., Stiefel, E. (1952).
Methods of conjugate gradients for solving linear equations.
Journal of Research of the National Bureau of Standards49, 409-436.