View source: R/constraints_utils.R
| ensure_spd | R Documentation |
Force a symmetric matrix to be symmetric positive definite:
the result satisfies is_pd(., rtol = tol). Already-PD input is returned
unchanged; otherwise a Gershgorin-based diagonal shift is applied, with a
Matrix::nearPD() fallback for small dense matrices and an escalating
jitter as a last resort.
ensure_spd(M, tol = 1e-06, nearpd_maxn = 2000L, name = "M")
M |
numeric matrix or Matrix::Matrix |
tol |
relative positive-definiteness margin (default 1e-6) |
nearpd_maxn |
only use nearPD when n <= nearpd_maxn and matrix is dense |
name |
label used in error messages |
a Matrix object (sparse stays sparse when possible)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.