Skip to content

Commit

Permalink
improving doctests for Enumeration.jl (#327)
Browse files Browse the repository at this point in the history
Co-authored-by: Stefan Krastanov <github.acc@krastanov.org>
  • Loading branch information
Fe-r-oz and Krastanov committed Aug 3, 2024
1 parent 5acfeb6 commit db6b01c
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
42 changes: 40 additions & 2 deletions src/enumeration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ const all_single_qubit_patterns = (

"""Generate a symbolic single-qubit gate given its index. Optionally, set non-trivial phases.
```jldoctest
julia> enumerate_single_qubit_gates(6)
sPhase on qubit 1
X₁ ⟼ + Y
Z₁ ⟼ + Z
julia> enumerate_single_qubit_gates(6, qubit=2, phases=(true, true))
SingleQubitOperator on qubit 2
X₁ ⟼ - Y
Z₁ ⟼ - Z
```
See also: [`enumerate_cliffords`](@ref)."""
function enumerate_single_qubit_gates(index; qubit=1, phases::Tuple{Bool,Bool}=(false,false))
@assert index<=6 "Only 6 single-qubit gates exit, up to the choice of phases"
Expand Down Expand Up @@ -37,9 +49,21 @@ function enumerate_single_qubit_gates(index; qubit=1, phases::Tuple{Bool,Bool}=(
end
end

"""The size of the Clifford group over a given number of qubits, possibly modulo the phases.
"""The size of the Clifford group `𝒞` over a given number of qubits, possibly modulo the phases.
For n qubits, not accounting for phases is `2ⁿⁿΠⱼ₌₁ⁿ(4ʲ-1)`. There are `4ⁿ` different phase configurations.
```jldoctest
julia> clifford_cardinality(7)
457620995529680351512370381586432000
```
For n qubits, not accounting for phases is 2ⁿⁿΠⱼ₌₁ⁿ(4ʲ-1). There are 4ⁿ different phase configurations.
When not accounting for phases (`phases = false`) the result is the same as the size of the Symplectic group `Sp(2n) ≡ 𝒞ₙ/𝒫ₙ`, where `𝒫ₙ` is the Pauli group over `n` qubits.
```jldoctest
julia> clifford_cardinality(7, phases=false)
27930968965434591767112450048000
```
See also: [`enumerate_cliffords`](@ref).
"""
Expand Down Expand Up @@ -83,6 +107,20 @@ end
The algorithm is detailed in [koenig2014efficiently](@cite).
```jldoctest
julia> symplecticGS(P"X", padded_n=3)
X₁ ⟼ + X__
X₂ ⟼ + _X_
X₃ ⟼ + __X
Z₁ ⟼ + Z__
Z₂ ⟼ + _Z_
Z₃ ⟼ + __Z
julia> symplecticGS(P"Z")
X₁ ⟼ + Z
Z₁ ⟼ + X
```
See also: [`enumerate_cliffords`](@ref), [`clifford_cardinality`](@ref)."""
function symplecticGS(pauli::PauliOperator; padded_n=nqubits(pauli))
n = nqubits(pauli)
Expand Down
4 changes: 4 additions & 0 deletions test/test_enumerate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@
@test length(collect(enumerate_cliffords(2))) == length(collect(enumerate_phases(enumerate_cliffords(2))))/2^4 == 720
@test first(enumerate_cliffords(3)) == C"X__ __Z _Z_ Z__ __X _X_"
@test first(enumerate_cliffords(5)) == C"X____ ____Z ___Z_ __Z__ _Z___ Z____ ____X ___X_ __X__ _X___"
for n in 1:10
symplectic_cardinality = clifford_cardinality(n, phases=false)
@test clifford_cardinality(n) == symplectic_cardinality*(2^(2n))
end
end

0 comments on commit db6b01c

Please sign in to comment.