Skip to content

Commit

Permalink
Merge 31daf1d into 77a3a48
Browse files Browse the repository at this point in the history
  • Loading branch information
BoxiLi committed Sep 22, 2021
2 parents 77a3a48 + 31daf1d commit f90cf06
Show file tree
Hide file tree
Showing 25 changed files with 3,037 additions and 1,647 deletions.
17 changes: 11 additions & 6 deletions src/qutip_qip/algorithms/qft.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from qutip import Qobj


__all__ = ['qft', 'qft_steps', 'qft_gate_sequence']
__all__ = ["qft", "qft_steps", "qft_gate_sequence"]


def qft(N=1):
Expand Down Expand Up @@ -67,8 +67,9 @@ def qft_steps(N=1, swapping=True):
else:
for i in range(N):
for j in range(i):
U_step_list.append(cphase(np.pi / (2 ** (i - j)), N,
control=i, target=j))
U_step_list.append(
cphase(np.pi / (2 ** (i - j)), N, control=i, target=j)
)
U_step_list.append(snot(N, i))
if swapping:
for i in range(N // 2):
Expand Down Expand Up @@ -104,9 +105,13 @@ def qft_gate_sequence(N=1, swapping=True):
else:
for i in range(N):
for j in range(i):
qc.add_gate("CPHASE", targets=[j], controls=[i],
arg_label=r"{\pi/2^{%d}}" % (i - j),
arg_value=np.pi / (2 ** (i - j)))
qc.add_gate(
"CPHASE",
targets=[j],
controls=[i],
arg_label=r"{\pi/2^{%d}}" % (i - j),
arg_value=np.pi / (2 ** (i - j)),
)
qc.add_gate("SNOT", targets=[i])
if swapping:
for i in range(N // 2):
Expand Down
Loading

0 comments on commit f90cf06

Please sign in to comment.