itersolve: Iterative Methods

View source: R/itersolve.R

itersolveR Documentation

Iterative Methods

Description

Iterative solutions of systems of linear equations.

Usage

itersolve(A, b, x0 = NULL, nmax = 1000, tol = .Machine$double.eps^(0.5),
            method = c("Gauss-Seidel", "Jacobi", "Richardson"))

Arguments

A

numerical matrix, square and non-singular.

b

numerical vector or column vector.

x0

starting solution for iteration; defaults to null vector.

nmax

maximum number of iterations.

tol

relative tolerance.

method

iterative method, Gauss-Seidel, Jacobi, or Richardson.

Details

Iterative methods are based on splitting the matrix A=(P-A)-A with a so-called ‘preconditioner’ matrix P. The methods differ in how to choose this preconditioner.

Value

Returns a list with components x the solution, iter the number of iterations, and method the name of the method applied.

Note

Richardson's method allows to specify a ‘preconditioner’; this has not been implemented yet.

References

Quarteroni, A., and F. Saleri (2006). Scientific Computing with MATLAB and Octave. Springer-Verlag, Berlin Heidelberg.

See Also

qrSolve

Examples

N <- 10
A <- Diag(rep(3,N)) + Diag(rep(-2, N-1), k=-1) + Diag(rep(-1, N-1), k=1)
b <- A %*% rep(1, N)
x0 <- rep(0, N)

itersolve(A, b, tol = 1e-8, method = "Gauss-Seidel")
# [1]  1  1  1  1  1  1  1  1  1  1
# [1]  87
itersolve(A, b, x0 = 1:10, tol = 1e-8, method = "Jacobi")
# [1]  1  1  1  1  1  1  1  1  1  1
# [1]  177

pracma documentation built on March 19, 2024, 3:05 a.m.