Skip to content

Commit

Permalink
introducing inverse sparsity Λ(χ) and Λ(ϕᵢⱼ)
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 79a825d
Show file tree
Hide file tree
Showing 3 changed files with 51 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
34 changes: 34 additions & 0 deletions src/nonclifford.jl
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,40 @@ nqubits(pc::UnitaryPauliChannel) = nqubits(pc.paulis[1])

apply!(state::GeneralizedStabilizer, gate::UnitaryPauliChannel; prune_threshold=1e-10) = apply!(state, gate.paulichannel; prune_threshold)

"""
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"X")
A mixture ∑ ϕᵢⱼ Pᵢ ρ Pⱼ† where ρ is
𝒟ℯ𝓈𝓉𝒶𝒷
+ Z
𝒮𝓉𝒶𝒷
+ X
with ϕᵢⱼ | Pᵢ | Pⱼ:
1.0+0.0im | + _ | + _
julia> apply!(sm, pcT) |> invsparsity
4
```
Similarly, it calculates the number of non-zero elements in the density
matrix `ϕᵢⱼ`​ of a PauliChannel, providing a measure of the channel
complexity.
```jldoctest
julia> invsparsity(pcT)
4
```
See also: [`GeneralizedStabilizer`](@ref)
"""
invsparsity(sm::GeneralizedStabilizer) = count(!iszero, values(sm.destabweights::DefaultDict{Tuple{BitVector, BitVector}, ComplexF64, ComplexF64}))
invsparsity(gate::AbstractPauliChannel) = count(!iszero, values(gate.paulichannel.weights::Vector{ComplexF64}))

##
# Predefined Pauli Channels
##
Expand Down
17 changes: 16 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,21 @@ end

##

@testset "Inverse sparsity" 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
# Λ(χ) ≤ 4ⁿ
@test invsparsity(gs) <= 4^n
channels = [embed(n, i, pcT) for i in 1:rand(1:4)]
# Λ(ϕᵢⱼ) ≤ 4ⁿ
@test all(invsparsity(channel) <= 4^n for channel in channels)
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 79a825d

Please sign in to comment.