-
Notifications
You must be signed in to change notification settings - Fork 47
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
Additional group theory functions for error correction #351
Changes from 66 commits
3ec3098
dee1c59
a708c00
8627fee
3bf54ae
4f377b7
929607d
1161ff2
da32a75
09ea8b5
e2af6b7
c1510a0
f22cf6e
5ded49b
59cf3be
2076a52
b7d0eab
7694800
bd5e63a
d4265dd
b9071e1
43f4736
afa2d17
c1282d8
79f8f75
0fc1725
6029b7f
d2bf12a
b633615
be86915
61d2b9c
e0ad281
ade696b
e9d914f
cb62f53
ec06fc2
8cc20f8
2786c66
14714c2
3b23fa9
eb5dbfe
ee3a0fa
121cd36
a2c8a17
ca05512
cbd2208
1697097
39af6f0
109104e
f77b7bd
51d5ba6
0441e25
256cfa0
a8a0133
c4d3cdc
7d3a7a3
7440d7d
3c5f917
8fdd651
a1c84b7
688ca8c
5cfc2c9
a4b73d2
b199101
5b5b45b
3d2f1d5
903d843
50fea07
5500322
04c4c29
5257f1a
64e1caa
ee7beb3
c785372
023550f
7f71467
b0bb5e1
e50620b
bfccfe1
39daadd
06b9282
ea023ca
b29e0f1
dd95172
c118dba
3adf539
8f14bd3
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 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,6 +1,92 @@ | ||||||||||||||
using Graphs | ||||||||||||||
using LinearAlgebra | ||||||||||||||
|
||||||||||||||
""" | ||||||||||||||
A tableau representation of the logical operator canonical form of a set of Paulis. | ||||||||||||||
The index of the first operator that commutes with all others is tracked so that the | ||||||||||||||
stabilizer, destabilizer, logical X, and logical Z aspects of the tableau can be | ||||||||||||||
represented. | ||||||||||||||
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. I do not think Check with Kenneth on this, maybe ask him to help with the documentation for it. |
||||||||||||||
""" | ||||||||||||||
mutable struct SubsystemCodeTableau <: AbstractStabilizer | ||||||||||||||
tab::Tableau | ||||||||||||||
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. Parameterize the tableau type (same as MixedDestabilizer for instance), to ensure type information is not lost here. |
||||||||||||||
index::Int | ||||||||||||||
r::Int | ||||||||||||||
m::Int | ||||||||||||||
k::Int | ||||||||||||||
end | ||||||||||||||
function SubsystemCodeTableau(t::Tableau) | ||||||||||||||
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. Why is this constructor necessary? It is a pretty expensive one. Should this not be a part of the |
||||||||||||||
# identity = zero(PauliOperator, nqubits(t)) | ||||||||||||||
# num = 0 | ||||||||||||||
# for p in t | ||||||||||||||
# if p == identity num+=1 end | ||||||||||||||
# end | ||||||||||||||
index = 1 | ||||||||||||||
for i in range(1, stop=length(t), step=2) | ||||||||||||||
if i + 1 > length(t) | ||||||||||||||
break | ||||||||||||||
end | ||||||||||||||
if comm(t[i], t[i+1]) == 0x01 | ||||||||||||||
index = i+2 # index to split loc into non-commuting pairs and commuting operators | ||||||||||||||
end | ||||||||||||||
end | ||||||||||||||
s = Stabilizer(t[index:length(t)]) | ||||||||||||||
ind = 1 | ||||||||||||||
if length(s)>nqubits(s)#if stabilizer is overdetermined, Destabilizer constructor throws error | ||||||||||||||
m = length(s) | ||||||||||||||
tab = zero(Tableau, length(t)+length(s), nqubits(t)) | ||||||||||||||
for i in s | ||||||||||||||
tab[ind] = zero(PauliOperator, nqubits(s)) | ||||||||||||||
ind+=1 | ||||||||||||||
end | ||||||||||||||
else | ||||||||||||||
d = Destabilizer(s) | ||||||||||||||
m = length(d) | ||||||||||||||
tab = zero(Tableau, length(t)+length(d), nqubits(t)) | ||||||||||||||
for p in destabilizerview(d) | ||||||||||||||
tab[ind] = p | ||||||||||||||
ind+=1 | ||||||||||||||
end | ||||||||||||||
end | ||||||||||||||
for i in range(1, stop=index-1, step=2) | ||||||||||||||
tab[ind] = t[i] | ||||||||||||||
ind+=1 | ||||||||||||||
end | ||||||||||||||
for p in s | ||||||||||||||
|
||||||||||||||
tab[ind] = p | ||||||||||||||
ind+=1 | ||||||||||||||
|
||||||||||||||
end | ||||||||||||||
for i in range(2, stop=index, step=2) | ||||||||||||||
tab[ind] = t[i] | ||||||||||||||
ind+=1 | ||||||||||||||
end | ||||||||||||||
return SubsystemCodeTableau(tab, index, length(s), m, (index-1)/2) | ||||||||||||||
|
||||||||||||||
end | ||||||||||||||
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.
Suggested change
|
||||||||||||||
|
||||||||||||||
Base.length(t::SubsystemCodeTableau) = length(t.tab) | ||||||||||||||
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. Is this used somewhere? Given the complicated internal structure, I am reluctant to define a "homogenous" length function as I am not sure what it would mean semantically. If it is not used, let's delete it. |
||||||||||||||
|
||||||||||||||
Base.copy(t::SubsystemCodeTableau) = SubsystemCodeTableau(copy(t.tab)) | ||||||||||||||
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. This is a very expensive way to make a copy as you are redoing a ton of computation. It would be better if this just copies over the various indices as well. |
||||||||||||||
|
||||||||||||||
"""A view of the subtableau corresponding to the stabilizer. See also [`tab`](@ref), [`destabilizerview`](@ref), [`logicalxview`](@ref), [`logicalzview`](@ref)""" | ||||||||||||||
function stabilizerview(s::SubsystemCodeTableau) | ||||||||||||||
return Stabilizer(@view tab(s)[s.m+s.k+1:s.m+s.k+s.r]) | ||||||||||||||
end | ||||||||||||||
"""A view of the subtableau corresponding to the destabilizer. See also [`tab`](@ref), [`stabilizerview`](@ref), [`logicalxview`](@ref), [`logicalzview`](@ref)""" | ||||||||||||||
function destabilizerview(s::SubsystemCodeTableau) | ||||||||||||||
return Stabilizer(@view tab(s)[1:s.m]) | ||||||||||||||
end | ||||||||||||||
"""A view of the subtableau corresponding to the logical X operators. See also [`tab`](@ref), [`stabilizerview`](@ref), [`destabilizerview`](@ref), [`logicalzview`](@ref)""" | ||||||||||||||
function logicalxview(s::SubsystemCodeTableau) | ||||||||||||||
return Stabilizer(tab(s)[s.m+1:s.m+s.k]) | ||||||||||||||
end | ||||||||||||||
"""A view of the subtableau corresponding to the logical Z operators. See also [`tab`](@ref), [`stabilizerview`](@ref), [`destabilizerview`](@ref), [`logicalzview`](@ref)""" | ||||||||||||||
function logicalzview(s::SubsystemCodeTableau) | ||||||||||||||
return Stabilizer(tab(s)[s.m+1+s.k+s.r:length(s)]) | ||||||||||||||
end | ||||||||||||||
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. No need to repeat the docstrings. Each one of these functions already has a docstring. Here you are defining new methods for these pre-existing functions. If the methods are novel or differing in some way, it makes sense to add new docstrings, bug given that these are just repeats of the already existing docstrings, they are not needed. The help file will already give you the docstrings defined earlier. You can just remove all four docstrings here. |
||||||||||||||
|
||||||||||||||
|
||||||||||||||
""" | ||||||||||||||
Return the full stabilizer group represented by the input generating set (a [`Stabilizer`](@ref)). | ||||||||||||||
|
||||||||||||||
|
@@ -18,16 +104,17 @@ function groupify(s::Stabilizer) | |||||||||||||
# Create a `Tableau` of 2ⁿ n-qubit identity Pauli operators(where n is the size of | ||||||||||||||
# `Stabilizer` s), then multiply each one by a different subset of the elements in s to | ||||||||||||||
# create all 2ⁿ unique elements in the group generated by s, then return the `Tableau`. | ||||||||||||||
n = length(s)::Int | ||||||||||||||
group = zero(Tableau, 2^n, nqubits(s)) | ||||||||||||||
gen_set = minimal_generating_set(s) | ||||||||||||||
n = length(gen_set)::Int | ||||||||||||||
group = zero(Tableau, 2^n, nqubits(gen_set)) | ||||||||||||||
for i in 0:2^n-1 | ||||||||||||||
for (digit_order, j) in enumerate(digits(i, base=2, pad=n)) | ||||||||||||||
if j == 1 | ||||||||||||||
group[i+1] *= s[digit_order] | ||||||||||||||
group[i+1] *= gen_set[digit_order] | ||||||||||||||
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.
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. By the way, does this function work correctly if there are terms with non-trivial phases? 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. If there are non-real phases it doesn't work because it uses 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. Additionally, there doesn't seem to be any method of 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. just writing down what we discussed in the call: just add a kwargument phases=false, and throw an error if someone tries to run phases=true with some message about it not being implemented For QuantumClifford.jl/src/mul_leftright.jl Line 166 in 4e06c01
I think it would be just
and then do |
||||||||||||||
end | ||||||||||||||
end | ||||||||||||||
end | ||||||||||||||
return group | ||||||||||||||
return group | ||||||||||||||
end | ||||||||||||||
Krastanov marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
|
||||||||||||||
|
||||||||||||||
|
@@ -59,9 +146,143 @@ function minimal_generating_set(s::Stabilizer) | |||||||||||||
end | ||||||||||||||
end | ||||||||||||||
|
||||||||||||||
""" | ||||||||||||||
For a not-necessarily commutative set of Paulis, returning a generating set of the form | ||||||||||||||
<A₁, B₁, A₂, B₂, ... Aₖ, Bₖ, Aₖ₊₁, ... Aₘ> where two operators anticommute if and only if they | ||||||||||||||
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. The order of operators does not seem correct anymore |
||||||||||||||
are of the form Aₖ, Bₖ and commute otherwise. | ||||||||||||||
|
||||||||||||||
Returns the generating set as a data structure of type [`SubsystemCodeTableau`](@ref). | ||||||||||||||
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. Mention the four different view functions that can be used to access this structure |
||||||||||||||
|
||||||||||||||
```jldoctest | ||||||||||||||
julia> tab(logical_operator_canonicalize(QuantumClifford.Tableau([P"XX", P"XZ", P"XY"]))) | ||||||||||||||
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. we should just make |
||||||||||||||
+ Z_ | ||||||||||||||
+ XX | ||||||||||||||
-iX_ | ||||||||||||||
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. The presence of an 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. This is happening because the function multiplies 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. yup, let's just remove the phases |
||||||||||||||
+ XZ | ||||||||||||||
``` | ||||||||||||||
""" | ||||||||||||||
function logical_operator_canonicalize(t:: QuantumClifford.Tableau) | ||||||||||||||
loc = zero(QuantumClifford.Tableau, length(t), nqubits(t)) | ||||||||||||||
IsaacP1234 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
index = 1 | ||||||||||||||
for i in eachindex(t) | ||||||||||||||
for j in eachindex(t) | ||||||||||||||
if comm(t[i], t[j]) == 0x01 | ||||||||||||||
for k in eachindex(t) | ||||||||||||||
if k !=i && k != j | ||||||||||||||
if comm(t[k], t[i]) == 0x01 | ||||||||||||||
t[k] = t[j] *t[k] | ||||||||||||||
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.
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. with |
||||||||||||||
end | ||||||||||||||
if comm(t[k], t[j]) == 0x01 | ||||||||||||||
t[k] = t[i] *t[k] | ||||||||||||||
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.
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. with |
||||||||||||||
end | ||||||||||||||
end | ||||||||||||||
end | ||||||||||||||
if !(t[i] in loc || -1 *t[i] in loc || 1im *t[i] in loc || -1im * t[i] in loc) | ||||||||||||||
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. This will probably be extremely slow (especially the phase modification and check... maybe zero out all the phases at the very start to not worry about this). That way it can be one single check instead of 4. |
||||||||||||||
loc[index]= t[i] | ||||||||||||||
index+=1 | ||||||||||||||
end | ||||||||||||||
if !(t[j] in loc || -1 *t[j] in loc || 1im *t[j] in loc || -1im * t[j] in loc) | ||||||||||||||
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. same comment about cost of check |
||||||||||||||
loc[index]= t[j] | ||||||||||||||
index+=1 | ||||||||||||||
end | ||||||||||||||
end | ||||||||||||||
end | ||||||||||||||
end | ||||||||||||||
for i in eachindex(t) | ||||||||||||||
if !(t[i] in loc || -1 *t[i] in loc || 1im *t[i] in loc || -1im * t[i] in loc) | ||||||||||||||
loc[index]= t[i] | ||||||||||||||
index+=1 | ||||||||||||||
end | ||||||||||||||
end | ||||||||||||||
while length(loc) > 1 && loc[length(loc)-1] == zero(PauliOperator, nqubits(loc)) | ||||||||||||||
loc = loc[1:(length(loc)-1)] | ||||||||||||||
end | ||||||||||||||
return SubsystemCodeTableau(loc) | ||||||||||||||
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. Can you give the constructor more information so it does not run all that expensive processing and searching? |
||||||||||||||
end | ||||||||||||||
|
||||||||||||||
""" | ||||||||||||||
For a not-necessarily commutative set of Paulis, return the logical operator canonical | ||||||||||||||
form of that set, and for each pair Aₖ, Bₖ of anticommutative Paulis, add an X to Aₖ, | ||||||||||||||
a Z to Bₖ, and an I to each other operator, such that the set is now fully commutative | ||||||||||||||
as well as return a list of the indices of the added qubits. | ||||||||||||||
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. Could you significantly expand this into multiple sentences and definitions? Currently, it is one long sentence and it is pretty difficult to understand. Could you also add a comment on what this is useful for? Is there a reference for this? Probably check with Kenneth about documenting it a bit more. 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. It is used in the 'matroid_parent' function. By comment, do you mean as a comment in the code or a line in the documentation? 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. In the docs. And in terms of use, do mention |
||||||||||||||
|
||||||||||||||
Phases are ignored, and returned Stabilizers contain only the + phase | ||||||||||||||
|
||||||||||||||
```jldoctest | ||||||||||||||
julia> commutavise(QuantumClifford.Tableau([P"XX", P"XZ", P"XY"]))[1] | ||||||||||||||
+ XXX | ||||||||||||||
+ XZZ | ||||||||||||||
+ X__ | ||||||||||||||
|
||||||||||||||
julia> commutavise(QuantumClifford.Tableau([P"XX", P"XZ", P"XY"]))[2] | ||||||||||||||
1-element Vector{Any}: | ||||||||||||||
3 | ||||||||||||||
``` | ||||||||||||||
""" | ||||||||||||||
function commutavise(t) | ||||||||||||||
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. mentioned elsewhere as well, but let's bikeshed the name a bit. Currently it is not very clear what it means and whether there is a precedent for this name (precedent is not necessary, but it helps) |
||||||||||||||
loc = QuantumClifford.logical_operator_canonicalize(t) | ||||||||||||||
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.
Suggested change
|
||||||||||||||
commutative = zero(Stabilizer, 2*loc.k+loc.r, nqubits(loc)+loc.k) | ||||||||||||||
ind = 1 | ||||||||||||||
for i in 1:loc.k | ||||||||||||||
dummy = commutative[ind] | ||||||||||||||
for j in eachindex(logicalxview(loc)[i]) dummy[j] = logicalxview(loc)[i][j] end | ||||||||||||||
dummy[nqubits(loc)+i] = (true, false) | ||||||||||||||
commutative[ind] = dummy | ||||||||||||||
ind+=1 | ||||||||||||||
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. Why do you need the
More generally though, I have the impression that a lot of this code (at least all of the inner loops) can be replaced with just 4 calls to QuantumClifford.jl/src/project_trace_reset.jl Line 746 in e51a142
|
||||||||||||||
end | ||||||||||||||
for i in 1:loc.k | ||||||||||||||
dummy = commutative[ind] | ||||||||||||||
for j in eachindex(logicalzview(loc)[i]) dummy[j] = logicalzview(loc)[i][j] end | ||||||||||||||
dummy[nqubits(loc)+i] = (false, true) | ||||||||||||||
commutative[ind] = dummy | ||||||||||||||
ind+=1 | ||||||||||||||
end | ||||||||||||||
for i in 1:loc.r | ||||||||||||||
dummy = commutative[ind] | ||||||||||||||
for j in eachindex(stabilizerview(loc)[i]) dummy[j] = stabilizerview(loc)[i][j] end | ||||||||||||||
commutative[ind] = dummy | ||||||||||||||
ind+=1 | ||||||||||||||
end | ||||||||||||||
to_delete = [] | ||||||||||||||
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. something more like |
||||||||||||||
for i in 1:loc.k | ||||||||||||||
push!(to_delete, i+nqubits(tab(loc))) | ||||||||||||||
end | ||||||||||||||
return commutative, to_delete | ||||||||||||||
end | ||||||||||||||
|
||||||||||||||
""" | ||||||||||||||
For a given set of Paulis that does not necessarily represent a state, return a set of | ||||||||||||||
Paulis that contains the commutativised given set and represents a state, as well as deletions | ||||||||||||||
needed to return to the original set of Paulis. | ||||||||||||||
|
||||||||||||||
By deleting the qubits in the first returned array, taking the normalizer, then deleting the qubits in the | ||||||||||||||
second returned array from the normalizer, the original set is produced. | ||||||||||||||
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. Add references to the related functions which you are talking about (e.g. commutavise). 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. This is a bit difficult to follow. Could you rewrite it with shorter sentences and fewer pronouns/references ("original set", "returned array", etc are pretty difficult to follow). Maybe introduce names / letters and some definitions. |
||||||||||||||
|
||||||||||||||
```jldoctest | ||||||||||||||
julia> embed(QuantumClifford.Tableau([P"XX"]))[1] | ||||||||||||||
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. making Tableau public (and just using the |
||||||||||||||
+ X_X | ||||||||||||||
+ ZZZ | ||||||||||||||
+ XX_ | ||||||||||||||
+ ___ | ||||||||||||||
|
||||||||||||||
julia> embed(QuantumClifford.Tableau([P"XX"]))[2] | ||||||||||||||
1-element Vector{Any}: | ||||||||||||||
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. these should be ranges or vectors of ints, not vectors of any |
||||||||||||||
3 | ||||||||||||||
|
||||||||||||||
julia> embed(QuantumClifford.Tableau([P"XX"]))[3] | ||||||||||||||
Any[] | ||||||||||||||
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. these should be ranges or vectors of ints, not vectors of any |
||||||||||||||
``` | ||||||||||||||
""" | ||||||||||||||
function embed(t::QuantumClifford.Tableau) | ||||||||||||||
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. needs a different name, check with Kenneth as well |
||||||||||||||
com, d1= QuantumClifford.commutavise(t) | ||||||||||||||
norm = QuantumClifford.normalizer(com.tab) | ||||||||||||||
state, d2 = QuantumClifford.commutavise(norm) | ||||||||||||||
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.
Suggested change
|
||||||||||||||
return state, d2, d1 | ||||||||||||||
end | ||||||||||||||
|
||||||||||||||
""" | ||||||||||||||
Return the full Pauli group of a given length. Phases are ignored by default, | ||||||||||||||
but can be included by setting `phases=true`. | ||||||||||||||
but can be included by setting `phases = 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.
Suggested change
|
||||||||||||||
|
||||||||||||||
```jldoctest | ||||||||||||||
julia> pauligroup(1) | ||||||||||||||
|
@@ -130,27 +351,37 @@ julia> normalizer(T"X") | |||||||||||||
+ X | ||||||||||||||
``` | ||||||||||||||
""" | ||||||||||||||
function normalizer(t::Tableau) | ||||||||||||||
function normalizer(t::Tableau; phases=false) | ||||||||||||||
# For each `PauliOperator` p in the with same number of qubits as the `Stabilizer` s, iterate through s and check each | ||||||||||||||
# operator's commutivity with p. If they all commute, add p a vector of `PauliOperators`. Return the vector | ||||||||||||||
# converted to `Tableau`. | ||||||||||||||
n = nqubits(t) | ||||||||||||||
pgroup = pauligroup(n, phases=false) | ||||||||||||||
ptype = typeof(t[1]) | ||||||||||||||
normalizer = ptype[] | ||||||||||||||
for p in pgroup | ||||||||||||||
ptype =typeof(P"I") | ||||||||||||||
norm = ptype[] | ||||||||||||||
|
||||||||||||||
p = zero(PauliOperator, n) | ||||||||||||||
paulis = ((false, false), (true, false), (false, true), (true, true)) | ||||||||||||||
for i in Iterators.product(Iterators.repeated(paulis, n)...) | ||||||||||||||
QuantumClifford.zero!(p) | ||||||||||||||
for (j, k) in enumerate(i) | ||||||||||||||
p[j] = k | ||||||||||||||
end | ||||||||||||||
commutes = true | ||||||||||||||
for q in t | ||||||||||||||
if comm(p, q) == 0x01 | ||||||||||||||
commutes = false | ||||||||||||||
end | ||||||||||||||
end | ||||||||||||||
if commutes | ||||||||||||||
push!(normalizer, p) | ||||||||||||||
push!(norm, copy(p)) | ||||||||||||||
end | ||||||||||||||
if phases | ||||||||||||||
for phase in [-1, 1im, -1im] | ||||||||||||||
push!(norm, phase *p) | ||||||||||||||
end | ||||||||||||||
end | ||||||||||||||
end | ||||||||||||||
|
||||||||||||||
return Tableau(normalizer) | ||||||||||||||
return QuantumClifford.Tableau(norm) | ||||||||||||||
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.
Suggested change
|
||||||||||||||
end | ||||||||||||||
|
||||||||||||||
""" | ||||||||||||||
|
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.
@KDGoodenough , @IsaacP1234
commutavise
andcommutivise
? Is this term used elsewhere by anyone else? Where does the name come frome?logical_operator_canonicalize
? The name is a bit long and I am not quite sure whether it conveys what is happening well.embed
as a name is already used for other purposes so this also would need to be renamed. There is alreadyembed
methods which embed a small unitary operator in a larger space by padding it with identities.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.
let's use the following name for
logical_operator_canoninicalize
to keep in similar to the other canonicalize methods we have: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.
let's, for now, change commutavise to
commutify
to keep it in sync with simplify or lambdify or sympifyThere 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.
let's, for now, rename
embed
tomatroid_parent