Skip to content

Commit

Permalink
misc cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Fe-r-oz committed Sep 20, 2024
1 parent 9c2770d commit 3ebf2d8
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 40 deletions.
3 changes: 1 addition & 2 deletions docs/src/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -434,5 +434,4 @@ @article{anderson2014fault
pages={080501},
year={2014},
publisher={APS}
}
}
1 change: 0 additions & 1 deletion src/ecc/ECC.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ function rate(c)
return rate
end

function generator end

"""The distance of a code."""
function distance end
Expand Down
1 change: 0 additions & 1 deletion src/ecc/codes/classical/recursivereedmuller.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Here, the matrix 0 denotes an all-zero matrix with dimensions matching `G(r - 1,
In addition, the dimension of `RM(m - r - 1, m)` equals the dimension of the dual of `RM(r, m)`. Thus, `RM(m - r - 1, m) = RM(r, m)^⊥` shows that the [dual code](https://en.wikipedia.org/wiki/Dual_code) of `RM(r, m)` is `RM(m − r − 1, m)`, indicating the parity check matrix of `RM(r, m)` is the generator matrix for `RM(m - r - 1, m)`.
See also: `ReedMuller`
"""
struct RecursiveReedMuller <: ClassicalCode
r::Int
Expand Down
10 changes: 5 additions & 5 deletions src/ecc/codes/quantumreedmuller.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
"""
The family of `[[2ᵐ - 1, 1, 3]]` CSS Quantum-Reed-Muller codes, as discovered by Steane in his 1999 paper [steane1999quantum](@cite).
Quantum codes are constructed from shortened Reed-Muller codes `RM(1, m)`, by removing the first row and column of the generator matrix `Gₘ`. Similarly, we can define truncated dual codes `RM(m - 2, m)` using the generator matrix `Hₘ`. The quantum Reed-Muller codes `QRM(m)` derived from `RM(1, m)` are CSS codes.
Quantum codes are constructed from shortened Reed-Muller codes `RM(1, m)`, by removing the first row and column of the generator matrix `Gₘ`. Similarly, we can define truncated dual codes `RM(m - 2, m)` using the generator matrix `Hₘ` [anderson2014fault](@cite). The quantum Reed-Muller codes `QRM(m)` derived from `RM(1, m)` are CSS codes.
Given that the stabilizers of the quantum code are defined through the generator matrix of the classical code, the minimum distance of the quantum code corresponds to the minimum distance of the dual classical code, which is `d = 3`, thus it can correct any single qubit error. Since one stabilizer from the original and one from the dual code are removed in the truncation process, the code parameters are `[[2ᵐ - 1, 1, 3]]`.
You might be interested in consulting [anderson2014fault](@cite) and [campbell2012magic](@cite) as well.
The ECC Zoo has an [entry for this family](https://errorcorrectionzoo.org/c/quantum_reed_muller).
"""
struct QuantumReedMuller <: AbstractECC
m::Int

function QuantumReedMuller(m)
if m < 3 || m > 11
throw(ArgumentError("Invalid parameters: m must be ≤ 3 and m ≤ 11 in order to valid code."))
Expand All @@ -23,8 +24,8 @@ function iscss(::Type{QuantumReedMuller})
end

function parity_checks(c::QuantumReedMuller)
RM₁₋ₘ = generator(RecursiveReedMuller(1, c.m))
RM₍ₘ₋₂₎₋ₘ₎ = generator(RecursiveReedMuller(c.m - 2, c.m))
RM₁₋ₘ = generator(RecursiveReedMuller(1,c.m))
RM₍ₘ₋₂₎₋ₘ₎ = generator(RecursiveReedMuller(c.m-2, c.m))
QRM = CSS(RM₁₋ₘ[2:end, 2:end], RM₍ₘ₋₂₎₋ₘ₎[2:end, 2:end])
Stabilizer(QRM)
end
Expand All @@ -38,4 +39,3 @@ distance(c::QuantumReedMuller) = 3
parity_checks_x(c::QuantumReedMuller) = stab_to_gf2(parity_checks(QuantumReedMuller(c.m)))[1:c.m, 1:end÷2]

parity_checks_z(c::QuantumReedMuller) = stab_to_gf2(parity_checks(QuantumReedMuller(c.m)))[end-(code_n(c::QuantumReedMuller) - 2 - c.m):end, end÷2+1:end]

6 changes: 2 additions & 4 deletions test/test_ecc_base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ const code_instance_args = Dict(
Toric => [(3,3), (4,4), (3,6), (4,3), (5,5)],
Surface => [(3,3), (4,4), (3,6), (4,3), (5,5)],
Gottesman => [3, 4, 5],
CSS => (c -> (parity_checks_x(c), parity_checks_z(c))).([Shor9(), Steane7(), Toric(4,4)]),
Concat => [(Perfect5(), Perfect5()), (Perfect5(), Steane7()), (Steane7(), Cleve8()), (Toric(2,2), Shor9())],
CSS => (c -> (parity_checks_x(c), parity_checks_z(c))).([Shor9(), Steane7(), Toric(4, 4)]),
Concat => [(Perfect5(), Perfect5()), (Perfect5(), Steane7()), (Steane7(), Cleve8()), (Toric(2, 2), Shor9())],
CircuitCode => random_circuit_code_args
QuantumReedMuller => [(3), (4), (5)]
CircuitCode => random_circuit_code_args,
QuantumReedMuller => [3, 4, 5]
)

function all_testablable_code_instances(;maxn=nothing)
Expand Down
59 changes: 32 additions & 27 deletions test/test_ecc_quantumreedmuller.jl
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
using Test
using Nemo: echelon_form, matrix, GF
using LinearAlgebra
using QuantumClifford
using QuantumClifford: canonicalize!, Stabilizer, stab_to_gf2
using QuantumClifford.ECC
using QuantumClifford.ECC: AbstractECC, QuantumReedMuller, Steane7
@testitem "Quantum Reed-Muller" begin
using Test
using Nemo: echelon_form, matrix, GF
using LinearAlgebra
using QuantumClifford
using QuantumClifford: canonicalize!, Stabilizer, stab_to_gf2
using QuantumClifford.ECC
using QuantumClifford.ECC: AbstractECC, QuantumReedMuller, Steane7

function designed_distance(matrix)
distance = 3
for row in eachrow(matrix)
count = sum(row)
if count < distance
return false
function designed_distance(mat)
dist = 3
for row in eachrow(mat)
count = sum(row)
if count < dist
return false
end
end
return true
end
return true
end

@testset "Test QRM(r, m) properties" begin
for m in 3:10
stab = parity_checks(QuantumReedMuller(m))
H = stab_to_gf2(stab)
@test designed_distance(H) == true
# QuantumReedMuller(3) is the Steane7() code.
@test canonicalize!(parity_checks(Steane7())) == parity_checks(QuantumReedMuller(3))
@test code_n(QuantumReedMuller(m)) == 2 ^ m - 1
@test code_k(QuantumReedMuller(m)) == 1
@test distance(QuantumReedMuller(m)) == 3
@test parity_checks_x(QuantumReedMuller(m)) == H[1:m, 1: 1:end÷2]
@test parity_checks_z(QuantumReedMuller(m)) == H[end-(code_n(QuantumReedMuller(m)) - 2 - m):end, end÷2+1:end]
@testset "Test QuantumReedMuller(r,m) properties" begin
for m in 3:10
stab = parity_checks(QuantumReedMuller(m))
H = stab_to_gf2(stab)
@test designed_distance(H) == true
# QuantumReedMuller(3) is the Steane7 code.
@test canonicalize!(parity_checks(Steane7())) == parity_checks(QuantumReedMuller(3))
@test code_n(QuantumReedMuller(m)) == 2^m - 1
@test code_k(QuantumReedMuller(m)) == 1
@test distance(QuantumReedMuller(m)) == 3
@test parity_checks_x(QuantumReedMuller(m)) == H[1:m, 1: 1:end÷2]
@test parity_checks_z(QuantumReedMuller(m)) == H[end-(code_n(QuantumReedMuller(m))-2-m):end, end÷2+1:end]
# [[15,1,3]] qrm code from table 1 of https://arxiv.org/pdf/1705.0010
qrm₁₅₁₃ = S"ZIZIZIZIZIZIZIZ//IZZIIZZIIZZIIZZ//IIIZZZZIIIIZZZZ//IIIIIIIZZZZZZZZ//IIZIIIZIIIZIIIZ//IIIIZIZIIIIIZIZ//IIIIIZZIIIIIIZZ//IIIIIIIIIZZIIZZ//IIIIIIIIIIIZZZZ//IIIIIIIIZIZIZIZ//XIXIXIXIXIXIXIX//IXXIIXXIIXXIIXX//IIIXXXXIIIIXXXX//IIIIIIIXXXXXXXX"
@test canonicalize!(parity_checks(qrm₁₅₁₃)) == canonicalize!(parity_checks(QuantumReedMuller(4)))
end
end
end

0 comments on commit 3ebf2d8

Please sign in to comment.