Routines for solving large systems of linear equations inR. Direct and iterative solvers from theEigenC++ library are made available. Solvers includeCholesky, LU, QR, and Krylov subspace methods (Conjugate Gradient,BiCGSTAB). Both dense and sparse problems are supported.
sanic is available onCRAN. Thedevelopment version can be installed from GitHub.
install.packages("sanic")devtools::install_github("nk027/sanic")To solve a linear system of equations, use thesolve2()function for automatic dispatch to a specific solver or access the LU,QR, Cholesky or Conjugate Gradient solvers directly.
To solve an eigenproblem, use theeigen2() orsvd2() functions, or thearnoldi()function.
| Solver | Function | Notes | Sparse | Reference |
|---|---|---|---|---|
| LU decomposition | solve_lu() | Partial pivoting, full pivoting | Yes | 1,2,3 |
| Householder QR decomposition | solve_qr() | Column pivoting, full pivoting, no pivoting | Yes | 1,2,3,4 |
| Cholesky decomposition | solve_chol() | LDLT for semidefinite problems, LLT for positive definiteproblems | Yes | 1,23,4 |
| Conjugate Gradient (CG) | solve_cg() | Biconjugate gradient stabilised (BiCGTAB) for square problems, leastsquares (LSCG) for rectangular problems, classic CG for symmetricpositive definite problems, preconditioners | Always | 1,2,3 |
| Solver | Function | Notes | Sparse | Reference |
|---|---|---|---|---|
| Spectral decomposition | eigen2() | Square and symmetric problems | No | 1,2 |
| Singular value decomposition | svd2() | Bidiagonal Divide and Conquer SVD for large and Jacobi SVD for smallproblems | No | 1,2 |
| Arnoldi iteration | arnoldi() | Square problems using an iteratively constructed Hessenbergmatrix | Always | 1 |
| Lanczos algorithm | lanczos() | Symmetric problems using an iteratively constructed tridiagonalmatrix | Always | 1 |