Computes the principal matrix square root of a symmetric positive-definite (SPD)
matrix. The input matrix is first regularized to ensure positive definiteness.
The matrix square root S_sqrt is such that S_sqrt
Usage
matrix_sqrt_spd(S, regularize_epsilon = 1e-06)
Arguments
- S
A numeric, symmetric matrix.
- regularize_epsilon
Epsilon for regularization. Default 1e-6.
Value
The matrix square root of S (an SPD matrix).
Examples
S1 <- matrix(c(2.3, -0.3, -0.3, 3.6), 2, 2)
S1_sqrt <- matrix_sqrt_spd(S1)
# S1_reconstructed_from_sqrt <- S1_sqrt %*% S1_sqrt
# all.equal(S1, S1_reconstructed_from_sqrt) # Should be TRUE