-
Notifications
You must be signed in to change notification settings - Fork 1
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
Refactor Gate
, Operator
definitions
#48
Conversation
const Pauli = Union{I,X,Y,Z} | ||
const Phase = Union{I,Z,S,Sd,T,Td,Rz,Hz,FSim} | ||
The `SU{N}` multi-qubit general unitary gate that can be used to represent any unitary matrix that acts on | ||
`N` qubits. A new random `SU{N}` can be created with `rand(SU{N}, lanes...)`, where `N` is the dimension |
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.
`N` qubits. A new random `SU{N}` can be created with `rand(SU{N}, lanes...)`, where `N` is the dimension | |
`log2(N)` qubits. A new random `SU{N}` can be created with `rand(SU{N}, lanes...)`, where `N` is the dimension |
The definition of SU{N}
(random unitary) is that N
is the number of dimensions of the operator, therefore, in the case of qubits, this would be log2(N)
. This is how I have seen SU
defined everywhere (see in Qiskit
, in some papers, ...).
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.
Yep, but using N
as the dimension of the matrix is super annoying. First, it doesn't tell you in how many sites it acts. Also I added a note to describe that N
in our case is the number of sites, not the dimensionality.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #48 +/- ##
==========================================
+ Coverage 56.02% 57.58% +1.55%
==========================================
Files 5 5
Lines 282 323 +41
==========================================
+ Hits 158 186 +28
- Misses 124 137 +13 ☔ View full report in Codecov by Sentry. |
This PR refactors the
Gate
andOperator
definitions. The difference gate types (e.g.X
,Swap
,Ry
,CZ
, ...) are stillOperator
subtypes, but now they are concrete subtypes that implement the parameters in their fields (unlike before, where parameters where encoded as a generic parameter of theGate
type).This change lets us create operators without assigning the site they are acting on, which should be sufficient for retrieving the array representations or some other information. With this change, the
Gate
andOperator
types have more clear semantics: AGate
is anOperator
acting somewhere (i.e. hassites
).It also provides a small macro utility
@gatedecl
for declaring gate types.Closes #44