Skip to content

Commit

Permalink
removing U1 and U2 gates MCXVChain
Browse files Browse the repository at this point in the history
  • Loading branch information
IsmaelCesar committed Mar 13, 2024
1 parent 36acd6b commit 9074352
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions qiskit/circuit/library/standard_gates/x.py
Original file line number Diff line number Diff line change
Expand Up @@ -1466,8 +1466,8 @@ def _define(self):
"""Define the MCX gate using a V-chain of CX gates."""
# pylint: disable=cyclic-import
from qiskit.circuit.quantumcircuit import QuantumCircuit
from .u1 import U1Gate
from .u2 import U2Gate
from .t import TGate, TdgGate
from .h import HGate

q = QuantumRegister(self.num_qubits, name="q")
qc = QuantumCircuit(q, name=self.name)
Expand Down Expand Up @@ -1502,7 +1502,7 @@ def _define(self):
[],
)
)
definition.append((U1Gate(pi / 4), [targets[i]], [])) # T gate
definition.append((TGate(), [targets[i]], []))
definition.append(
(
CXGate(),
Expand All @@ -1511,12 +1511,12 @@ def _define(self):
)
)
definition.append(
(U1Gate(-pi / 4), [targets[i]], []) # inverse T gate
(TdgGate(), [targets[i]], [])
)
definition.append((U2Gate(0, pi), [targets[i]], [])) # H gate
definition.append((HGate(), [targets[i]], []))
else:
definition.append((U2Gate(0, pi), [targets[i]], [])) # H gate
definition.append((U1Gate(pi / 4), [targets[i]], [])) # T gate
definition.append((HGate(), [targets[i]], []))
definition.append((TGate(), [targets[i]], []))
definition.append(
(
CXGate(),
Expand All @@ -1525,7 +1525,7 @@ def _define(self):
)
)
definition.append(
(U1Gate(-pi / 4), [targets[i]], []) # inverse T gate
(TdgGate(), [targets[i]], [])
)
definition.append(
(
Expand All @@ -1542,44 +1542,44 @@ def _define(self):

definition.append((CCXGate(), [*controls, targets[i]], []))
else:
definition.append((U2Gate(0, pi), [targets[i]], [])) # H gate
definition.append((U1Gate(pi / 4), [targets[i]], [])) # T gate
definition.append((HGate(), [targets[i]], []))
definition.append((TGate(), [targets[i]], []))
definition.append(
(
CXGate(),
[q_controls[self.num_ctrl_qubits - i - 2], targets[i]],
[],
)
)
definition.append((U1Gate(-pi / 4), [targets[i]], [])) # inverse T gate
definition.append((TdgGate(), [targets[i]], []))
definition.append(
(
CXGate(),
[q_controls[self.num_ctrl_qubits - i - 1], targets[i]],
[],
)
)
definition.append((U1Gate(pi / 4), [targets[i]], [])) # T gate
definition.append((TGate(), [targets[i]], []))
definition.append(
(
CXGate(),
[q_controls[self.num_ctrl_qubits - i - 2], targets[i]],
[],
)
)
definition.append((U1Gate(-pi / 4), [targets[i]], [])) # inverse T gate
definition.append((U2Gate(0, pi), [targets[i]], [])) # H gate
definition.append((TdgGate(), [targets[i]], []))
definition.append((HGate(), [targets[i]], []))

break

for i in range(num_ancillas - 1): # reset part
definition.append((CXGate(), [q_ancillas[i], q_ancillas[i + 1]], []))
definition.append((U1Gate(pi / 4), [q_ancillas[i + 1]], [])) # T gate
definition.append((TGate(), [q_ancillas[i + 1]], []))
definition.append((CXGate(), [q_controls[2 + i], q_ancillas[i + 1]], []))
definition.append(
(U1Gate(-pi / 4), [q_ancillas[i + 1]], []) # inverse T gate
(TdgGate(), [q_ancillas[i + 1]], [])
)
definition.append((U2Gate(0, pi), [q_ancillas[i + 1]], [])) # H gate
definition.append((HGate(), [q_ancillas[i + 1]], []))

if self._action_only:
definition.append(
Expand Down

0 comments on commit 9074352

Please sign in to comment.