Skip to content

Commit

Permalink
simplify ctrl-gphase transform
Browse files Browse the repository at this point in the history
  • Loading branch information
jcjaskula-aws committed Nov 20, 2023
1 parent 9f8a547 commit 76989f7
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/braket/circuits/gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,16 +310,12 @@ def gphase(
X.x(control_qubits[-1]),
]

highest_control_qubit = max(
[qubit for qubit, state in zip(control_qubits, control_basis_state) if state]
)
highest_control_qubit_index = control_qubits.index(highest_control_qubit)

control_qubits.pop(highest_control_qubit_index)
control_basis_state.pop(highest_control_qubit_index)
rightmost_control_qubit_index = control_basis_state.index(1)
rightmost_control_qubit = control_qubits.pop(rightmost_control_qubit_index)
control_basis_state.pop(rightmost_control_qubit_index)

return PhaseShift.phaseshift(
highest_control_qubit,
rightmost_control_qubit,
angle,
control=control_qubits,
control_state=control_basis_state,
Expand Down

0 comments on commit 76989f7

Please sign in to comment.