Skip to content

Commit

Permalink
Simplify cz circuit even more
Browse files Browse the repository at this point in the history
Co-authored-by: Shelly Garion <46566946+ShellyGarion@users.noreply.github.com>
Co-authored-by: Alexander Ivrii <alexi@il.ibm.com>
  • Loading branch information
3 people committed May 2, 2024
1 parent b613008 commit d8d819f
Showing 1 changed file with 7 additions and 20 deletions.
27 changes: 7 additions & 20 deletions qiskit/circuit/library/standard_gates/equivalence_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -881,36 +881,23 @@ def _cnot_rxx_decompose(plus_ry: bool = True, plus_rxx: bool = True):
# │ ≡
# q_1: ─X─
#
# global phase: 7π/4
# ┌─────────┐ ┌────┐ ┌────┐ ┌────────┐┌────┐┌──────────┐ »
# q_0: ┤ Rz(π/2) ├────┤ √X ├────■─┤ √X ├─■─┤ Rz(-π) ├┤ √X ├┤ Rz(-π/2) ├─■─»
# └──┬────┬─┘┌───┴────┴──┐ │ ├────┤ │ └─┬────┬─┘└────┘└──────────┘ │ »
# q_1: ───┤ √X ├──┤ Rz(-3π/2) ├─■─┤ √X ├─■───┤ √X ├─────────────────────■─»
# └────┘ └───────────┘ └────┘ └────┘ »
# « ┌────┐ ┌─────────┐
# «q_0: ───┤ √X ├──┤ Rz(π/2) ├
# « ┌──┴────┴─┐└─────────┘
# «q_1: ┤ Rz(π/2) ├───────────
# « └─────────┘
#
# global phase: 3π/2
# ┌────┐ ┌────┐ ┌────┐
# q_0: ┤ √X ├─■─┤ √X ├─■─┤ √X ├─■─
# ├────┤ │ ├────┤ │ ├────┤ │
# q_1: ┤ √X ├─■─┤ √X ├─■─┤ √X ├─■─
# └────┘ └────┘ └────┘
q = QuantumRegister(2, "q")
def_swap_cz = QuantumCircuit(q, global_phase=7 * pi / 4)
def_swap_cz.rz(pi / 2, 0)
def_swap_cz = QuantumCircuit(q, global_phase=-pi / 2)
def_swap_cz.sx(0)
def_swap_cz.sx(1)
def_swap_cz.rz(-3 * pi / 2, 1)
def_swap_cz.cz(0, 1)
def_swap_cz.sx(0)
def_swap_cz.sx(1)
def_swap_cz.cz(0, 1)
def_swap_cz.rz(-pi, 0)
def_swap_cz.sx(0)
def_swap_cz.rz(-pi / 2, 0)
def_swap_cz.sx(1)
def_swap_cz.cz(0, 1)
def_swap_cz.sx(0)
def_swap_cz.rz(pi / 2, 0)
def_swap_cz.rz(pi / 2, 1)
_sel.add_equivalence(SwapGate(), def_swap_cz)

# iSwapGate
Expand Down

0 comments on commit d8d819f

Please sign in to comment.