| amgcl_solve | R Documentation |
Solve Ax = b with AMG-preconditioned conjugate gradients or BiCGStab,
either by constructing a solver for one call or reusing an existing solver.
amgcl_solve(A, b, solver = c("cg", "bicgstab"), tol = 1e-8,
maxiter = 1000L, threads = 1L)
A |
A nonempty, square |
b |
A finite real numeric right-hand-side vector, including an integer vector, of length equal to the matrix dimension. A one-column base numeric matrix or one-column double-precision Matrix object with the same number of rows is also accepted and converted to a vector. Multiple columns, arrays with more than two dimensions, and logical or complex inputs are rejected. |
solver |
|
tol |
Finite positive tolerance for AMGCL's relative residual
estimate. Must be omitted when |
maxiter |
Positive integer iteration limit. Must be omitted when
|
threads |
Positive integer requested thread count for this call,
defaulting to one. Capped by the capacity reported by
|
Every solve starts from a zero initial guess. Inspect converged and
residual before using a result. CG requires a symmetric positive
definite matrix; convergence does not validate that assumption. See
amgcl_setup for matrix requirements, the direct coarse LU
preconditioner used for systems with at most 64 rows, and setup errors.
When A is a matrix, threads controls both setup and solving.
When it is a reusable solver, threads controls this solve only; the
setup thread count is not retained. OpenMP settings are restored after each
operation. See amgcl_setup for thread and object-lifetime
details.
A list with components:
Numeric solution vector.
Number of iterations reported by AMGCL.
AMGCL's final relative residual estimate.
Independently computed Euclidean residual norm divided
by the Euclidean norm of b. For a zero right-hand side, the
absolute residual norm is returned.
Logical; whether the independently computed
residual is at most tol.
Effective requested thread cap after applying build and capacity limits. This is not a measurement of the worker count used inside each parallel region.
amgcl_setup, amgcl_info
A <- methods::as(Matrix::bandSparse(10, k = c(-1, 0, 1),
diagonals = list(rep(-1, 9), rep(3, 10), rep(-1, 9))), "dgCMatrix")
result <- amgcl_solve(A, rep(1, 10))
result$x
result$residual
# Symmetric sparse storage and a one-column Matrix right-hand side.
S <- Matrix::bandSparse(10, k = c(0, 1),
diagonals = list(rep(3, 10), rep(-1, 9)), symmetric = TRUE)
rhs <- S %*% rep(1, 10)
amgcl_solve(S, rhs)$x
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.