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.