【发布时间】:2017-09-21 21:04:18
【问题描述】:
我需要检查一个矩阵在python中是否是单一的,为此我使用了这个函数:
def is_unitary(m):
return np.allclose(np.eye(m.shape[0]), m.H * m)
但是当我尝试通过以下方式指定矩阵时:
m1=np.matrix([complex(1/math.sqrt(2)),cmath.exp(1j)],[-cmath.exp(-1j).conjugate(),complex(1/math.sqrt(2))],dtype=complex)
我得到一个
TypeError: __new__() got multiple values for argument 'dtype'
这里使用数据类型的正确方法是什么?
【问题讨论】:
标签: python python-3.x numpy linear-algebra complex-numbers