Skip to content

Commit d3b021d

Browse files
committed
fixed bug in mlab.sqrtm; numpy.linalg.eig behaves different than Numeric did
svn path=/branches/v0_91_maint/; revision=5095
1 parent efa87f1 commit d3b021d

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

CHANGELOG

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2008-04-29 Fix bug in mlab.sqrtm - MM
2+
13
2008-04-28 Fix bug in SVG text with Mozilla-based viewers (the symbol
24
tag is not supported) - MGD
35

lib/matplotlib/mlab.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1901,7 +1901,7 @@ def rank(x):
19011901
def sqrtm(x):
19021902
"""
19031903
Returns the square root of a square matrix.
1904-
This means that s=sqrtm(x) implies s*s = x.
1904+
This means that s=sqrtm(x) implies dot(s,s) = x.
19051905
Note that s and x are matrices.
19061906
"""
19071907
return mfuncC(npy.sqrt, x)
@@ -1914,9 +1914,10 @@ def mfuncC(f, x):
19141914
"""
19151915

19161916
x = npy.asarray(x)
1917-
(v, u) = npy.linalg.eig(x)
1918-
uT = u.transpose()
1917+
(v,uT) = npy.linalg.eig(x)
19191918
V = npy.diag(f(v+0j))
1919+
# todo: warning: this is not exactly what matlab does
1920+
# MATLAB "B/A is roughly the same as B*inv(A)"
19201921
y = npy.dot(uT, npy.dot(V, npy.linalg.inv(uT)))
19211922
return approx_real(y)
19221923

0 commit comments

Comments
 (0)