Skip to content
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

implement sm⊗sm, tHadamard*sm, pcT⊗P"X" , pcT*tId1 , P"-Y"*sm and copy(sm) from #260 #345

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
12 changes: 6 additions & 6 deletions docs/src/stab-algebra-manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -627,12 +627,12 @@ julia> s=S"-XXX
julia> d = Destabilizer(s)
𝒟ℯ𝓈𝓉𝒶𝒷
+ Z__
+ _X_
+ _XX
+ __X
𝒮𝓉𝒶𝒷━
- XXX
- ZZ_
- Z_Z
+ _ZZ
```

They have convenience methods to extract only the stabilizer and destabilizer
Expand All @@ -642,11 +642,11 @@ pieces:
julia> stabilizerview(d)
- XXX
- ZZ_
- Z_Z
+ _ZZ

julia> destabilizerview(d)
+ Z__
+ _X_
+ _XX
+ __X
```

Expand All @@ -672,12 +672,12 @@ Clifford operations can be applied the same way they are applied to stabilizers.
julia> apply!(d,tCNOT⊗tHadamard)
𝒟ℯ𝓈𝓉𝒶𝒷
- X_Z
+ XXZ
+ _XZ
+ X__
𝒮𝓉𝒶𝒷━
+ _ZX
- _Z_
- Z_X
+ ZZX
```

# Mixed States
Expand Down
11 changes: 9 additions & 2 deletions ext/QuantumCliffordQOpticsExt/QuantumCliffordQOpticsExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,14 @@ Ket(dim=4)
```"""
Ket(s::QuantumClifford.AbstractStabilizer) = stab_to_ket(s)

function stabmix_to_densityop(s::StabMixture)
"""
$TYPEDSIGNATURES

Convert a stabilizer tableau to a density matrix corresponding to the given state.
"""
Operator(s::QuantumClifford.AbstractStabilizer) = dm(Ket(s)) # TODO support mixed stabilizer states

function genstab_to_densityop(s::GeneralizedStabilizer)
ρ₀ = zero(dm(Ket(s.stab)))
for ((Pₗᵇⁱᵗˢ,Pᵣᵇⁱᵗˢ), χ) in s.destabweights
ρ̃ = dm(Ket(s.stab))
Expand All @@ -96,7 +103,7 @@ end
$TYPEDSIGNATURES

"""
Operator(s::StabMixture) = stabmix_to_densityop(s)
Operator(s::GeneralizedStabilizer) = genstab_to_densityop(s)


"""
Expand Down
51 changes: 42 additions & 9 deletions src/QuantumClifford.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export
# Pauli frames
PauliFrame, pftrajectories, pfmeasurements,
# Useful States
bell, ghz,
bell, ghz, maximally_mixed,
single_z, single_x, single_y,
# Graphs
graphstate, graphstate!, graph_gatesequence, graph_gate,
Expand All @@ -84,7 +84,7 @@ export
# petrajectories
petrajectories, applybranches,
# nonclifford
StabMixture, UnitaryPauliChannel, PauliChannel, pcT,
GeneralizedStabilizer, UnitaryPauliChannel, PauliChannel, pcT,
# makie plotting -- defined only when extension is loaded
stabilizerplot, stabilizerplot_axis,
# sum types
Expand Down Expand Up @@ -445,21 +445,54 @@ tab(s::AbstractStabilizer) = s.tab

"""
A tableau representation of a pure stabilizer state. The tableau tracks the
destabilizers as well, for efficient projections. On initialization there are
destabilizers as well, for efficient projections.

For full-rank tableaux, the stabilizer part of the tableau is guaranteed to be kept the same as the input stabilizer tableau given to the constructor (a guarantee not kept by [`MixedDestabilizer`](@ref)).

On initialization there are
no checks that the provided state is indeed pure. This enables the use of this
data structure for mixed stabilizer state, but a better choice would be to use
data structure for mixed stabilizer state, but usually a better choice would be
[`MixedDestabilizer`](@ref).
""" # TODO clean up and document constructor

```
julia> Destabilizer(S"ZZI XXX")
𝒟ℯ𝓈𝓉𝒶𝒷
+ Z__
+ _X_
𝒮𝓉𝒶𝒷━
+ XXX
+ ZZ_

julia> Destabilizer(S"ZZI XXX IZZ")
𝒟ℯ𝓈𝓉𝒶𝒷
+ X__
+ _Z_
+ __X
𝒮𝓉𝒶𝒷━
+ ZZ_
+ XXX
+ _ZZ
```
"""
struct Destabilizer{T<:Tableau} <: AbstractStabilizer
tab::T
end

function Destabilizer(s::Stabilizer)
row, col = size(s)
row>col && error(DomainError("The input stabilizer has more rows than columns, making it inconsistent or overdetermined."))
mixed_destab = MixedDestabilizer(s)
t = vcat(tab(destabilizerview(mixed_destab)),tab(stabilizerview(mixed_destab)))
Destabilizer(t)
if row<col
mixed_destab = MixedDestabilizer(s)
t = vcat(tab(destabilizerview(mixed_destab)),tab(stabilizerview(mixed_destab)))
return Destabilizer(t)
elseif row==col
maxmix = maximally_mixed(col)
for row in s
project!(maxmix, row)
end
return Destabilizer(maxmix.tab)
else
error(DomainError("The input stabilizer has more rows than columns, making it inconsistent or overdetermined."))
end
end

Base.length(d::Destabilizer) = length(tab(d))÷2
Expand Down
4 changes: 2 additions & 2 deletions src/dense_cliffords.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ ERROR: DimensionMismatch: Input tableau should be of size 2n×n (top half is the
```jldoctest
julia> d = Destabilizer(S"Y")
𝒟ℯ𝓈𝓉𝒶𝒷
+ Z
+ X
𝒮𝓉𝒶𝒷
+ Y

julia> CliffordOperator(d)
X₁ ⟼ + Z
X₁ ⟼ + X
Z₁ ⟼ + Y
```
"""
Expand Down
Loading
Loading