use the SVD of M:
M = U * S * transpose(V)
and compute the square root as
sqrt(M) = U * sqrt(S) * transpose(V)
If andInverseFlag is set, the inverse square root is also
returned, if onlyInverseFlag is set, only the inverse is
returned.
For rank deficient input matrices M, the inverse of
sqrt(M[:rank,:rank]) is returned.
Note: theoretically, U and V should be IDENTICAL if M is
symmetric. Practically, though, they will be different, and
computing sqrt(M) as U * sqrt(S) * transpose(U)
does not work. Using the SVD still seems to be numerically much
more reliable than using the eigendecomposition.
|