def QFT(self,nqbits):
N = 2**nqbits # number of rows and cols
theta = 2.0 * np.pi / N
opmat = [None]*N
for i in range(N):
# print "row",i,"--------------------"
row = []
for j in range(N):
pow = i * j
pow = pow % N
# print "w^",pow
row.append(np.e**(1.j*theta*pow))
opmat[i] = row
# print opmat
opmat = np.matrix(opmat,dtype=complex) / np.sqrt(N)
oper = ["QFT({:d})".format(nqbits),opmat]
return oper
评论列表
文章目录