Learn R Programming

sanic: Solving Ax = b Nimbly in C++

Routines for solving large systems of linear equations in R. Direct and iterative solvers from the Eigen C++ library are made available. Solvers include Cholesky, LU, QR, and Krylov subspace methods (Conjugate Gradient, BiCGSTAB). Both dense and sparse problems are supported.

Installation

sanic is available on CRAN. The development version can be installed from GitHub.

install.packages("sanic")
devtools::install_github("nk027/sanic")

Usage

To solve a linear system of equations, use the solve2() function for automatic dispatch to a specific solver or access the LU, QR, Cholesky or Conjugate Gradient solvers directly.

To solve an eigenproblem, use the eigen2() or svd2() functions, or the arnoldi() function.

Solvers

SolverFunctionNotesSparseReference
LU decompositionsolve_lu()Partial pivoting, full pivotingYes1, 2, 3
Householder QR decompositionsolve_qr()Column pivoting, full pivoting, no pivotingYes1, 2, 3, 4
Cholesky decompositionsolve_chol()LDLT for semidefinite problems, LLT for positive definite problemsYes1, 2 3, 4
Conjugate Gradient (CG)solve_cg()Biconjugate gradient stabilised (BiCGTAB) for square problems, least squares (LSCG) for rectangular problems, classic CG for symmetric positive definite problems, preconditionersAlways1, 2, 3

Eigenproblems

SolverFunctionNotesSparseReference
Spectral decompositioneigen2()Square and symmetric problemsNo1, 2
Singular value decompositionsvd2()Bidiagonal Divide and Conquer SVD for large and Jacobi SVD for small problemsNo1, 2
Arnoldi iterationarnoldi()Square problems using an iteratively constructed Hessenberg matrixAlways1
Lanczos algorithmlanczos()Symmetric problems using an iteratively constructed tridiagonal matrixAlways1

Copy Link

Version

Install

install.packages('sanic')

Monthly Downloads

205

Version

0.0.2

License

GPL-3 | file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Nikolas Kuschnig

Last Published

August 23rd, 2023

Functions in sanic (0.0.2)

solve_cg

Solve Systems of Equations Using Iterative Methods
eigen2

Spectral Decomposition
sparsify

Transform a Matrix to Be Sparse.
svd2

Singular Value Decomposition
sanic

Solving Ax = b Nimbly in C++
solve_chol

Solve Systems of Equations Using Direct Methods
solve2

Solve Systems of Equations
arnoldi

Krylov Subspace Spectral Decomposition