[Numpy-discussion] Matrix square root
Andrew Nesbit
alnesbit at students.cs.mu.oz.au
Thu Sep 4 07:46:55 EDT 2003
I need a function equivalent to Matlab's sqrtm, i.e., a square root
for matrices.
I constructed the following definition:
def sqrtm(M):
(U,S,VT) = LinearAlgebra.singular_value_decomposition(M)
D = MLab.diag(sqrt(S))
return matrixmultiply(matrixmultiply(U,D),VT)
but this technique only works for Hermitian, positive definite
matrices. The matrices I operate on don't necessarily satisfy that
condition.
Does anybody know of a more general technique, preferably with an
accompanying Python implementation?
Thanks.
Andrew.
More information about the NumPy-Discussion
mailing list