cg | R Documentation |
The function solves a symmetric positive definite system by constructing conjugate directions. Similar to Lanczos, R is matrix containing Krylov orthogonal vectors (non-normalized), P is a matrix of conjugate directions, and H is a tridiagonal matrix with Lanczos coefficients.
cg(A, b, x = rnorm(length(b)), m = length(b), tol = 1e-07)
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 produces the first residual r = b - Ax. 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. |
A = matrix(rnorm(100^2), 100) A = t(A)%*%A b = rnorm(100) res = cg(A, b, 80) plot(solve(A, b), t="l") lines(res$x, col="red")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.