>>> import numpy as np
>>> A = np.zeros((3,3))
>>> A[0,0] = 9
>>> A
array([[ 9., 0., 0.],
[ 0., 0., 0.],
[ 0., 0., 0.]])
>>> A[0,1] = 1+2j
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can't convert complex to float
>>> A[0,1] = np.complex(1, 2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can't convert complex to float
根据我的示例代码,我试图将复数放入numpy的数组中,但它没有起作用。也许我错过了一些基本的东西。