lanczos: Lanczos algorithm

View source: R/lanczos.R

lanczosR Documentation

Lanczos algorithm

Description

The function solves a symmetric positive definite system by factoring the matrix into A=VHV^T form. Here, V is matrix containing Krylov orthogonal vectors, and H is a tridiagonal matrix with Lanczos coefficients.

Usage

lanczos(A, b, x = rnorm(length(b)), m = length(b), tol = 1e-07)

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 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.

Examples

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

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