def times_unitary(x,n,swap_re_im,Wparams,Wimpl):
# multiply tensor x on the right by the unitary matrix W parameterized by Wparams
if (Wimpl == 'adhoc'):
theta=Wparams[0]
reflection=Wparams[1]
index_permute_long=Wparams[2]
step1 = times_diag(x, n, theta[0,:], swap_re_im)
step2 = do_fft(step1, n)
step3 = times_reflection(step2, n, reflection[0,:])
step4 = vec_permutation(step3, index_permute_long)
step5 = times_diag(step4, n, theta[1,:], swap_re_im)
step6 = do_ifft(step5, n)
step7 = times_reflection(step6, n, reflection[1,:])
step8 = times_diag(step7, n, theta[2,:], swap_re_im)
y = step8
elif (Wimpl == 'full'):
Waug=Wparams[0]
y = T.dot(x,Waug)
return y
评论列表
文章目录