python - 如何在 numpy 矩阵中使用这个复数?

标签 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)
问题发生在 [x+y.j] ,其中 j表示复杂的单位。它返回错误消息 AttributeError: 'int' object has no attribute 'j' .如果我删除点,那么它返回 NameError: name 'yj' is not defined .我该如何纠正?谢谢!

最佳答案

j单独是一个变量,您可以通过键入 1j 获得复数

关于python - 如何在 numpy 矩阵中使用这个复数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68669841/

相关文章:

python - urllib2 不使用代理(Fiddler2),使用 ProxyHandler 设置

python - 使用单个 for 循环的列表中相同数字之间的距离

python - 带函数返回的 Flask render_template

python - 具有固定斜率的 linalg.lstsq?

python - 256GB RAM、64 位 python 和 64 位 numpy 的 Numpy 内存错误。限制问题?

matlab - 构造由基矩阵的不同幂组成的 block 矩阵

java - 使用递归求解 Hadamard 矩阵

python - 扩展方法时将局部变量保留在作用域内

python - Python 中的自适应描述符

python - 用 Pandas 为所有字符串对创建距离矩阵