[SciPy-user] Problems with linalg.logm

Nils Wagner wagner.nils at vdi.de
Wed Sep 24 14:16:17 EDT 2003


Dear experts, 
 
I tried to do something with linalg.logm 
I have enclosed the program. 
 
Result may be inaccurate, approximate err = 1.32516030853e-09 
Traceback (most recent call last): 
  File "logm-test.py", line 36, in ? 
    P1 = P1 + 
(linalg.logm(z1*identity(7)-A)-linalg.logm(z0*identity(7)-A))/(2*pi*sqrt(-1.)) 
  File "/usr/lib/python2.2/site-packages/scipy/linalg/matfuncs.py", line 225, in 
logm 
    F -= temp.T 
  File "/usr/lib/python2.2/site-packages/Numeric/UserArray.py", line 58, in 
__isub__ 
    subtract(self.array, other, self.array) 
TypeError: return array has incorrect type 
 
What is the reason for that ? 
 
Nils 
 
from scipy import * 
A = zeros((7,7),Float) 
A[0,0] = -2.0 
A[0,1] = 25.0 
A[1,1] = -3.0 
A[1,2] = 10.0 
A[1,3] = 3.0 
A[1,4] = 3.0 
A[1,5] = 3.0 
A[2,2] = 2.0 
A[2,3] = 15.0 
A[2,4] = 3.0 
A[2,5] = 3.0 
A[3,4] = 15.0 
A[3,5] = 3.0 
A[4,4] = 3.0 
A[4,5] = 10.0 
A[5,5] = -2.0 
A[5,6] = 25.0 
A[6,6] = -3.0 
nm = 4 
# 
# Center of the circle 
# 
gamma = 1.5 
# 
# Radius of the circle 
# 
rho   =  1.6 
# 
P1 = zeros((7,7),Complex) 
# 
for i in arange(0,nm-1): 
  z0 = gamma+rho*exp(2.*pi*i*sqrt(-1.)/nm) 
  z1 = gamma+rho*exp(2.*pi*(i+1)*sqrt(-1.)/nm) 
  P1 = P1 + 
(linalg.logm(z1*identity(7)-A)-linalg.logm(z0*identity(7)-A))/(2*pi*sqrt(-1.)) 
C=dot(P1,P1)-P1 
print trace(C) 
print P1 
 




More information about the SciPy-User mailing list