These functions raise the matrix x
to the desired power:
matrixsqrt
takes the square root, matrixinvsqrt
takes
the inverse square root, and matrixpower
takes the specified
power of x
.
Up to numerical error, matrixpower(x, 2)
should be equivalent
to x %*% x
, and matrixpower(x, -1)
should be
equivalent to solve(x)
, the inverse of x
.
The square root y <- matrixsqrt(x)
should satisfy
y %*% y = x
. The inverse square root
z <- matrixinvsqrt(x)
should satisfy z %*% z = solve(x)
.
Computations are performed using the eigen decomposition
(eigen
).