# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
#' Conjugate Gradient solver for Sparse Matrices.
#'
#' Using the iterative Conjugate Gradient Solver from the Eigen C++ library
#' it solves a linear system `A * x = b`. Currently, it uses a diagonal
#' preconditioner.
#'
#' @param A Sparse double matrix of class \linkS4class{dgCMatrix}.
#' @param b Numeric vector with length equal to number of rows of \code{A}.
#' @param x0 Numeric vector with same length as \code{b}. If no initial guess
#' is known a vector of zeros with length of \code{b} can be passed.
#' @param maxiter Integer scalar that sets the maximum number of iterations
#' allowed by the solver. Default is 10,000.
#' @param tol Sets the tolerance threshold (upper bound to the relative
#' residual error) used by the stopping criteria.
#' @return \code{sparse_cg} returns a list with several components:
#' \item{coefficients}{a vector with the estimated coefficients}
#' \item{itr}{a scalar denoting the number of iterations at convergence}
#' \item{err}{a scalar denoting the relative error at convergance}
#' @seealso See \href{http://www.eigen.tuxfamily.org/}{Eigen Library} for more
#' documentation on solver used and other available solvers.
#' @export
sparse_cg <- function(A, b, x0, maxiter = 10000L, tol = 1e-6) {
.Call('_tstevR_sparse_cg', PACKAGE = 'tstevR', A, b, x0, maxiter, tol)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.