Python构造虚数矩阵报警告ComplexWarning: Casting complex values to real discards the imaginary part
问题描述:我在构造哈密顿矩阵时是包含复数i的,调试的时候控制台报警告,ComplexWarning:Castingcomplexvaluestorealdiscardstheimaginarypart代码和警告如下T0=np.kron(s0,M*sz)+t1_*np.eye(4,k=1)+t1_*np.eye(4,k=-1)T0[0,2]=t2_*np.exp(-1j*phi)T0[2,0]=t2