Skip to content

Commit

Permalink
introducing inverse sparsity Λ(χ)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fe-r-oz committed Oct 1, 2024
1 parent 624eedd commit 6aa6404
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/QuantumClifford.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export
# petrajectories
petrajectories, applybranches,
# nonclifford
GeneralizedStabilizer, UnitaryPauliChannel, PauliChannel, pcT,
GeneralizedStabilizer, UnitaryPauliChannel, PauliChannel, pcT, invsparsity,
# makie plotting -- defined only when extension is loaded
stabilizerplot, stabilizerplot_axis,
# sum types
Expand Down
40 changes: 40 additions & 0 deletions src/nonclifford.jl
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,46 @@ function rowdecompose(pauli,state::Union{MixedDestabilizer, Destabilizer})
return p+pauli.phase[], b, c
end

"""
Calculates the number of non-zero elements in the density matrix `χ`
of a [`GeneralizedStabilizer`](@ref), representing the inverse sparsity
of `χ`. It provides a measure of the state's complexity, with bounds
`Λ(χ) ≤ 4ⁿ`.
```jldoctest
julia> sm = GeneralizedStabilizer(S"-ZY XZ")
A mixture ∑ ϕᵢⱼ Pᵢ ρ Pⱼ† where ρ is
𝒟ℯ𝓈𝓉𝒶𝒷
+ Z_
+ _Z
𝒮𝓉𝒶𝒷
+ XZ
- ZY
with ϕᵢⱼ | Pᵢ | Pⱼ:
1.0+0.0im | + __ | + __
julia> apply!(sm, embed(2, 1, pcT))
A mixture ∑ ϕᵢⱼ Pᵢ ρ Pⱼ† where ρ is
𝒟ℯ𝓈𝓉𝒶𝒷
+ Z_
+ _Z
𝒮𝓉𝒶𝒷
+ XZ
- ZY
with ϕᵢⱼ | Pᵢ | Pⱼ:
0.5+0.0im | + __ | + __
0.0+0.5im | + __ | + Z_
0.0-0.5im | + Z_ | + __
0.5+0.0im | + Z_ | + Z_
julia> invsparsity(sm)
4
```
See also: [`GeneralizedStabilizer`](@ref)
"""
invsparsity(sm::GeneralizedStabilizer) = count(!iszero, values(sm.destabweights))

"""A Pauli channel datastructure, mainly for use with [`GeneralizedStabilizer`](@ref).
More convenient to use than [`PauliChannel`](@ref) when you know your Pauli channel is unitary.
Expand Down
13 changes: 12 additions & 1 deletion test/test_nonclifford.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using QuantumClifford
using QuantumClifford: GeneralizedStabilizer, rowdecompose, PauliChannel, mul_left!, mul_right!
using QuantumClifford: GeneralizedStabilizer, rowdecompose, PauliChannel, invsparsity, mul_left!, mul_right!
using Test
using InteractiveUtils
using Random
Expand Down Expand Up @@ -39,6 +39,17 @@ end

##

@testset "Inverse sparsity Λ(χ) ≤ 4ⁿ" begin
for n in 1:5
s = random_stabilizer(n)
gs = GeneralizedStabilizer(s)
for i in 1:rand(1:4)
apply!(gs, embed(n, i, pcT))
end
@test invsparsity(gs) <= 4^n
end
end

@test_throws ArgumentError GeneralizedStabilizer(S"XX")
@test_throws ArgumentError PauliChannel(((P"X", P"Z"), (P"X", P"ZZ")), (1,2))
@test_throws ArgumentError PauliChannel(((P"X", P"Z"), (P"X", P"Z")), (1,))
Expand Down

0 comments on commit 6aa6404

Please sign in to comment.