ZR-*_*ZR- 4 python numpy matrix complex-numbers
这是我正在处理的 Python 代码:
def inver_hopf(x,y,z):
return (1/np.sqrt(x**2+y**2+(1+z)**2))*np.matrix([[1+z],[x+y.j]],dtype=complex)
Run Code Online (Sandbox Code Playgroud)
问题发生在[x+y.j],其中j意味着复杂的单位。它返回给我错误信息AttributeError: 'int' object has no attribute 'j'。如果我删除点,那么它返回NameError: name 'yj' is not defined. 我该如何纠正?谢谢!