From 3ebf2d84ebc6982ecb616881a5696ebc6c1889b6 Mon Sep 17 00:00:00 2001 From: Fe-r-oz Date: Fri, 20 Sep 2024 09:14:38 +0500 Subject: [PATCH] misc cleanup --- docs/src/references.bib | 3 +- src/ecc/ECC.jl | 1 - .../codes/classical/recursivereedmuller.jl | 1 - src/ecc/codes/quantumreedmuller.jl | 10 ++-- test/test_ecc_base.jl | 6 +- test/test_ecc_quantumreedmuller.jl | 59 ++++++++++--------- 6 files changed, 40 insertions(+), 40 deletions(-) diff --git a/docs/src/references.bib b/docs/src/references.bib index b3052873d..996aa9bd5 100644 --- a/docs/src/references.bib +++ b/docs/src/references.bib @@ -434,5 +434,4 @@ @article{anderson2014fault pages={080501}, year={2014}, publisher={APS} - } - \ No newline at end of file +} diff --git a/src/ecc/ECC.jl b/src/ecc/ECC.jl index dc1704ab9..8730fb1de 100644 --- a/src/ecc/ECC.jl +++ b/src/ecc/ECC.jl @@ -102,7 +102,6 @@ function rate(c) return rate end -function generator end """The distance of a code.""" function distance end diff --git a/src/ecc/codes/classical/recursivereedmuller.jl b/src/ecc/codes/classical/recursivereedmuller.jl index e745a5bf1..ae30ae578 100644 --- a/src/ecc/codes/classical/recursivereedmuller.jl +++ b/src/ecc/codes/classical/recursivereedmuller.jl @@ -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 diff --git a/src/ecc/codes/quantumreedmuller.jl b/src/ecc/codes/quantumreedmuller.jl index f63323e18..80e250031 100644 --- a/src/ecc/codes/quantumreedmuller.jl +++ b/src/ecc/codes/quantumreedmuller.jl @@ -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.")) @@ -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 @@ -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] - diff --git a/test/test_ecc_base.jl b/test/test_ecc_base.jl index c7d8fee1a..f01b1592f 100644 --- a/test/test_ecc_base.jl +++ b/test/test_ecc_base.jl @@ -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) diff --git a/test/test_ecc_quantumreedmuller.jl b/test/test_ecc_quantumreedmuller.jl index 5e45a2bc7..9ca74539e 100644 --- a/test/test_ecc_quantumreedmuller.jl +++ b/test/test_ecc_quantumreedmuller.jl @@ -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