itersolve.RdIterative solutions of systems of linear equations.
itersolve(A, b, x0 = NULL, nmax = 1000, tol = .Machine$double.eps^(0.5),
method = c("Gauss-Seidel", "Jacobi", "Richardson"))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.
Returns a list with components x the solution, iter the
number of iterations, and method the name of the method applied.
Quarteroni, A., and F. Saleri (2006). Scientific Computing with MATLAB and Octave. Springer-Verlag, Berlin Heidelberg.
Richardson's method allows to specify a `preconditioner'; this has not been implemented yet.
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")
#> $x
#> [1] 1 1 1 1 1 1 1 1 1 1
#>
#> $iter
#> [1] 87
#>
#> $method
#> [1] "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")
#> $x
#> [1] 1 1 1 1 1 1 1 1 1 1
#>
#> $iter
#> [1] 177
#>
#> $method
#> [1] "Jacobi"
#>
# [1] 1 1 1 1 1 1 1 1 1 1
# [1] 177