-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Add phase property to Gate class #3472
Conversation
1a050c7
to
450a08f
Compare
Why have phase and phase_angle? Seems like more to keep track of and check. |
@ewinston it only has one internal attribute, the rest are getter/setter over that. |
@ajavadia What if |
67934aa
to
e3f1dd2
Compare
As @ewinston suggested (and several others also requested) removed the non-polar form of phase and renamed |
e3f1dd2
to
8b68dd6
Compare
dbc097c
to
035b572
Compare
035b572
to
28122be
Compare
9410589
to
07e4634
Compare
@ewinston I rebase to fix conflicts with master, but there are still some issues with controlled gates and failing tests |
@@ -32,6 +32,10 @@ def add_control(operation, num_ctrl_qubits, label): | |||
num_qubits + 2*num_ctrl_qubits - 1. | |||
""" | |||
import qiskit.extensions.standard as standard | |||
if operation.phase: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to be able to remove this clause and have the phase case handled by the standard control
function without converting to a unitary first.
Change simplify atol to simplify_tolerance
* Added phase to base Gate class * Added phase to base ControlledGate class * Added phase to standard gate extensions
07e4634
to
457d60b
Compare
Made a new PR #3930 since only way to clean up history with master was huge squash rebase |
Summary
phase
andphase_angle
properties toGate
class for storing global phaseeto_matrix
to return the matrix definition times the phaseDetails and comments
When constructing a gate a
phase
can be set usingphase=theta
kwarg.theta
will be stored as a float[-2*pi, 2*pi]
in the gate object, representing a complex coefficientexp(i theta)
on the matrix definition of the gate.After construction a gate object can have its phase modified using
gate.phase = theta
.When calling
to_matrix
the returned matrix will beexp(i theta) * U_def
whereU_def
is the matrix definition of the gate.When unrolling any set phase parameter will be passed to one of the gates in the definition so that the unrolled circuit has the same global phase as the original gate.
TODO
Fixes #3304