Description Usage Arguments Details Value Warning References See Also Examples
Conjugate gradient method for solving system of linear equations Ax = b, where A is symmetric and positive definite, b is a column vector.
1 | cgsolve(A, b, tol = 1e-6, maxIter = 1000)
|
A |
matrix, symmetric and positive definite. |
b |
vector, with same dimension as number of rows of A. |
tol |
numeric, threshold for convergence, default is |
maxIter |
numeric, maximum iteration, default is |
The idea of conjugate gradient method is to find a set of mutually conjugate directions for the unconstrained problem
arg min_x f(x)
where f(x) = 0.5 b^T A b - bx + z and z is a constant. The problem is equivalent to solving Ax = b.
This function implements an iterative procedure to reduce the number of matrix-vector multiplications [1]. The conjugate gradient method improves memory efficiency and computational complexity, especially when A is relatively sparse.
Returns a vector representing solution x.
Users need to check that input matrix A is symmetric and positive definite before applying the function.
[1] Yousef Saad. Iterative methods for sparse linear systems. Vol. 82. siam, 2003.
1 2 3 4 5 6 |
[,1]
[1,] 0.09090909
[2,] 0.63636364
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.