Skip to content

Commit

Permalink
noncliff: introducing inverse sparsity Λ(χ) and Λ(ϕᵢⱼ) (#376)
Browse files Browse the repository at this point in the history
Co-authored-by: Stefan Krastanov <[email protected]>
  • Loading branch information
Fe-r-oz and Krastanov authored Nov 5, 2024
1 parent e4a6479 commit cd74b92
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
36 changes: 36 additions & 0 deletions src/nonclifford.jl
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,42 @@ 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)
"""
function invsparsity end

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 cd74b92

Please sign in to comment.