| Title: | The 'PRIMME' Eigensolver as a Compiled Engine for 'linop' |
|---|---|
| Description: | Bindings to the PReconditioned Iterative MultiMethod Eigensolver library 'PRIMME' (Stathopoulos and McCombs 2010, <doi:10.1145/1731022.1731031>; Wu, Romero and Stathopoulos 2017, <doi:10.1137/16M1082214>) for a few eigenvalues and eigenvectors of a Hermitian operator and a few singular values and vectors of a rectangular one, both given only by their action. The source of 'PRIMME' 3.2.3 is included in the package and linked against the Basic Linear Algebra Subprograms ('BLAS') and Linear Algebra Package ('LAPACK') that R itself uses. The package is the engine behind method = "primme" in the 'linop' package and exposes no interface of its own beyond the two calls 'linop' makes. |
| Authors: | Gilles Colling [aut, cre] (ORCID: <https://orcid.org/0000-0003-3070-6066>), Andreas Stathopoulos [ctb, cph] (PRIMME library), Eloy Romero [ctb, cph] (PRIMME library), Lingfei Wu [ctb, cph] (PRIMME library), College of William & Mary [cph] (PRIMME library) |
| Maintainer: | Gilles Colling <[email protected]> |
| License: | BSD_3_clause + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-11-17 13:43:14 UTC |
| Source: | https://github.com/gcol33/linop.primme |
Calls 'dprimme()' or 'zprimme()' with the default method, on an operator given by its action on a block of columns.
primme_eigsh( apply, n, k, which = "LA", tol = 1e-10, maxit = 10000L, ncv = NULL, min_restart = NULL, block = NULL, locking = NULL, v0 = NULL, complex = FALSE, seed = 1L, norm = 0, floor = 4, preset = "PRIMME_DEFAULT_MIN_MATVECS", convtest = NULL )primme_eigsh( apply, n, k, which = "LA", tol = 1e-10, maxit = 10000L, ncv = NULL, min_restart = NULL, block = NULL, locking = NULL, v0 = NULL, complex = FALSE, seed = 1L, norm = 0, floor = 4, preset = "PRIMME_DEFAULT_MIN_MATVECS", convtest = NULL )
apply |
A function taking an 'n x b' matrix and returning the operator applied to it. |
n |
The order of the operator. |
k |
How many eigenpairs. |
which |
'"LA"', '"SA"' (largest, smallest algebraic), '"LM"' or '"SM"' (largest, smallest magnitude). |
tol |
PRIMME's 'eps'. A pair is converged when its residual norm is at most 'tol' times the estimate of '||A||' and at most 'tol' times the magnitude of its value, each plus the arithmetic floor 'floor * .Machine$double.eps * (||A|| + |value|)', the second waived where that magnitude is below 'floor * .Machine$double.eps' times the estimate of ‘||A||'. These are the backward-error and residual bounds of ’linop”s eigenpair certificate. PRIMME refuses a 'tol' below machine epsilon. |
maxit |
PRIMME's 'maxMatvecs', the budget of single-column applies. |
ncv |
PRIMME's 'maxBasisSize', or 'NULL' for its default. |
min_restart |
PRIMME's 'minRestartSize', or 'NULL' for its default. |
block |
PRIMME's 'maxBlockSize', or 'NULL' for its default. |
locking |
PRIMME's 'locking', 'TRUE' or 'FALSE', or 'NULL' for its default. |
v0 |
An initial guess of length 'n', or 'NULL'. |
complex |
Whether the operator is complex. |
seed |
Seed for PRIMME's own random initial vectors. |
norm |
An estimate of '||A||' for the convergence test, or '0' for PRIMME to estimate it. |
floor |
'c' in the arithmetic floor of the convergence test. |
preset |
The name of a PRIMME preset method, such as '"PRIMME_DEFAULT_MIN_MATVECS"' (GD+k), '"PRIMME_DEFAULT_MIN_TIME"' (JDQMR), '"PRIMME_Arnoldi"' or '"PRIMME_DYNAMIC"'. The default is GD+k rather than PRIMME's own default, '"PRIMME_DYNAMIC"', because that one switches between the two by measured timings, so two runs of the same call need not return the same vectors. |
convtest |
'NULL' for the convergence test described under 'tol', or a function '(value, x, rnorm, anorm)' returning 'TRUE' when the pair is converged. It receives PRIMME's Ritz value, the unit Ritz vector or 'NULL' where PRIMME passes none, PRIMME's residual norm on the operator 'apply' applies, and the estimate of that operator's norm. A caller iterating on a transformed operator, such as a shift-and-invert, measures the pair on the operator it wants here. |
A list with ‘values' (PRIMME’s Ritz values), 'vectors', 'resNorms', ‘nconv', 'info' (PRIMME’s return code, '0' on success and '-3' when the budget ran out), 'stats' and the 'params' PRIMME settled on.
n <- 100 lap <- function(X) 2 * X - rbind(X[-1, , drop = FALSE], 0) - rbind(0, X[-n, , drop = FALSE]) fit <- primme_eigsh(lap, n, k = 2, which = "SA") fit$values - 4 * sin(1:2 * pi / (2 * (n + 1)))^2n <- 100 lap <- function(X) 2 * X - rbind(X[-1, , drop = FALSE], 0) - rbind(0, X[-n, , drop = FALSE]) fit <- primme_eigsh(lap, n, k = 2, which = "SA") fit$values - 4 * sin(1:2 * pi / (2 * (n + 1)))^2
The version of the vendored 'PRIMME' library and of the calling contract between this package and 'linop'.
primme_engine()primme_engine()
A list with 'engine_version' and 'contract_version'.
primme_engine()primme_engine()
Calls 'dprimme_svds()' or 'zprimme_svds()' with the default method, on an operator given by its action and its adjoint.
primme_svds( apply, m, n, k, which = "LM", tol = 1e-10, maxit = 10000L, ncv = NULL, block = NULL, locking = NULL, complex = FALSE, seed = 1L, norm = 0, preset = "PRIMME_DEFAULT_MIN_MATVECS", convtest = NULL )primme_svds( apply, m, n, k, which = "LM", tol = 1e-10, maxit = 10000L, ncv = NULL, block = NULL, locking = NULL, complex = FALSE, seed = 1L, norm = 0, preset = "PRIMME_DEFAULT_MIN_MATVECS", convtest = NULL )
apply |
A function '(X, trans)': 'A the conjugate transpose of 'A' applied to 'X' when it is 'TRUE'. |
m, n
|
The operator is 'm x n'. |
k |
How many triplets. |
which |
'"LM"' (largest) or '"SM"' (smallest). |
tol |
PRIMME's 'eps'. A pair is converged when its residual norm is at most 'tol' times the estimate of '||A||' and at most 'tol' times the magnitude of its value, each plus the arithmetic floor 'floor * .Machine$double.eps * (||A|| + |value|)', the second waived where that magnitude is below 'floor * .Machine$double.eps' times the estimate of ‘||A||'. These are the backward-error and residual bounds of ’linop”s eigenpair certificate. PRIMME refuses a 'tol' below machine epsilon. |
maxit |
PRIMME's 'maxMatvecs', the budget of single-column applies. |
ncv |
PRIMME's 'maxBasisSize', or 'NULL' for its default. |
block |
PRIMME's 'maxBlockSize', or 'NULL' for its default. |
locking |
PRIMME's 'locking', 'TRUE' or 'FALSE', or 'NULL' for its default. |
complex |
Whether the operator is complex. |
seed |
Seed for PRIMME's own random initial vectors. |
norm |
An estimate of '||A||' for the convergence test, or '0' for PRIMME to estimate it. |
preset |
The PRIMME preset method for both stages of the singular value solver; see [primme_eigsh()]. |
convtest |
‘NULL' for PRIMME’s own convergence test, or a function '(value, u, v, rnorm, anorm)' returning 'TRUE' when the triplet is converged. It receives PRIMME's singular value, the left and right vectors or 'NULL' for a side PRIMME does not pass (its first stage, on the normal equations, passes one side), PRIMME's residual norm and its estimate of '||A||'. |
A list with 'd', 'u', 'v', 'resNorms', 'nconv', 'info', the overall ‘stats' and those of each of PRIMME’s two stages, and 'params'. PRIMME returns only the triplets it converged, so after an exhausted budget (‘info' '-103' or '-203', the eigensolver’s '-3' from the first or second stage) 'd', 'u' and 'v' hold 'nconv' of them, possibly none.
A <- diag(c(5, 4, 3, 2, 1))[, 1:4] fit <- primme_svds(function(X, trans) if (trans) crossprod(A, X) else A %*% X, 5, 4, k = 2) fit$dA <- diag(c(5, 4, 3, 2, 1))[, 1:4] fit <- primme_svds(function(X, trans) if (trans) crossprod(A, X) else A %*% X, 5, 4, k = 2) fit$d