-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Added U1, U2 and U3 deprecation warnings into Circuit Library #8391
Changes from 10 commits
e029651
7d0ebc3
f9f4081
8dc53ae
e6c5544
ebc2ffb
9b24a00
4d79ff5
e87bc35
cbcf87e
065e482
3e1c029
73de6ba
08b53ba
9ffc5c0
30d3bfb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,18 @@ | |
class U3Gate(Gate): | ||
r"""Generic single-qubit rotation gate with 3 Euler angles. | ||
|
||
.. warning:: | ||
|
||
This gate is deprecated. Instead, the following replacements should be used | ||
|
||
.. math:: | ||
|
||
U3(\theta, \phi, \lambda) = U(\theta, \phi, \lambda) | ||
.. codeblock:: python | ||
Guillermo-Mijares-Vilarino marked this conversation as resolved.
Show resolved
Hide resolved
Cryoris marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
circuit = QuantumCircuit(1) | ||
circuit.u(theta, phi, lambda) | ||
|
||
**Circuit symbol:** | ||
|
||
.. parsed-literal:: | ||
|
@@ -52,6 +64,11 @@ class U3Gate(Gate): | |
|
||
**Examples:** | ||
|
||
.. math:: | ||
|
||
U3(\theta, \phi, \lambda) = e^{i \frac{\pi + \theta}{2}} P(\phi + \pi) \sqrt{X} | ||
P(\theta + \pi) \sqrt{X} P(\lambda) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also here the global phase doesn't seem to match (or maybe I have a typo!) >>> decomp = np.exp(0.5j * (np.pi + th)) * np.dot(PhaseGate(phi + np.pi), np.dot(SXGate(), np.dot(PhaseGate(th + np.pi), np.dot(SXGate(), PhaseGate(lam)))))
>>> decomp
array([[-0.53350621-0.71685923j, 0.22160969+0.39034999j],
[ 0.23851082-0.38025854j, 0.56442266-0.69277925j]])
>>> u3 = U3Gate(th, phi, lam).to_matrix()
>>> u3 # matrix doesn't match decomp
array([[ 0.89359724+0.j , -0.44545363-0.05527232j],
[ 0.1626514 +0.41836406j, 0.21878112+0.86640109j]])
>>> Operator(u3).equiv(decomp) # but it is equivalent -- hence a global phase difference exists
True There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's because I forgot to add a minus sign to the global phase 😅. The correct phase is |
||
|
||
.. math:: | ||
|
||
U3\left(\theta, -\frac{\pi}{2}, \frac{\pi}{2}\right) = RX(\theta) | ||
|
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 think this first equivalence with RZ RY RZ misses a global phase, doesn't it?
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 hadn't actually checked that one (trusted it to be correct but seems that was an error on my part 🤦♂️) but you are correct.$U2(\phi, \lambda) = e^{i\frac{\phi+\lambda}{2}}RZ(\phi)RY(\pi/2)RZ(\lambda)$