sp_solve_sym | R Documentation |
Solve Ax=b where A is a symmetric SFBM, and b is a vector.
sp_solve_sym(
A,
b,
add_to_diag = rep(0, ncol(A)),
tol = 1e-10,
maxiter = 10 * ncol(A)
)
A |
A symmetric SFBM. |
b |
A vector. |
add_to_diag |
Vector (or single value) to virtually add to
the diagonal of |
tol |
Tolerance for convergence. Default is |
maxiter |
Maximum number of iterations for convergence. |
The vector x, solution of Ax=b.
N <- 100
spmat <- Matrix::rsparsematrix(N, N, 0.01, symmetric = TRUE)
X <- bigsparser::as_SFBM(as(spmat, "dgCMatrix"))
b <- runif(N)
test <- tryCatch(as.vector(Matrix::solve(spmat, b)), error = function(e) print(e))
test2 <- tryCatch(sp_solve_sym(X, b), error = function(e) print(e))
test3 <- as.vector(Matrix::solve(spmat + Matrix::Diagonal(N, 1:N), b))
test4 <- sp_solve_sym(X, b, add_to_diag = 1:N)
all.equal(test3, test4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.