library("SpaNorm")
m <- crossprod(matrix(rnorm(30), 10, 3))
invert_mat(m) [,1] [,2] [,3]
[1,] 0.37654288 -0.02936674 0.2416824
[2,] -0.02936674 0.13275540 -0.1000020
[3,] 0.24168244 -0.10000201 0.3246875
Inverts a (typically small) symmetric positive-definite matrix using a Cholesky factorisation, falling back to a general solve when the Cholesky fails. When a torch backend is active and mat is a tensor, the factorisation runs on the accelerator (or CPU for MPS) and the result is returned on the input device. Exposed for downstream packages (e.g. spiDE) that reuse SpaNorm’s fitting machinery for Wald-type inference.
invert_mat(mat)
mat
|
a symmetric positive-definite matrix (base matrix or torch tensor). |
the matrix inverse, in the same representation as mat.