diff --git a/src/ecc/codes/delfosserepcode.jl b/src/ecc/codes/delfosserepcode.jl index e7667cdc6..6c2212707 100644 --- a/src/ecc/codes/delfosserepcode.jl +++ b/src/ecc/codes/delfosserepcode.jl @@ -55,6 +55,12 @@ function parity_checks(c::DelfosseRepCode) Stabilizer(code) end +code_n(c::DelfosseRepCode) = 4*c.blocks + +code_k(c::DelfosseRepCode) = 2*(c.blocks - 2) + +distance(c::DelfosseRepCode) = 4 + parity_checks_x(c::DelfosseRepCode) = _extend_414_repetition_code(c.blocks) parity_checks_z(c::DelfosseRepCode) = _extend_414_repetition_code(c.blocks) diff --git a/test/test_ecc_delfosse_repcode.jl b/test/test_ecc_delfosse_repcode.jl new file mode 100644 index 000000000..f67f5dedf --- /dev/null +++ b/test/test_ecc_delfosse_repcode.jl @@ -0,0 +1,45 @@ +@testitem "ECC [[4p, 2(p − 2), 4]] DelfosseRepCode" begin + + using LinearAlgebra + using QuantumClifford.ECC + using QuantumClifford.ECC: DelfosseRepCode, _extend_414_repetition_code + using Nemo: matrix, GF + + @testset "Testing [[4p, 2(p − 2), 4]] DelfosseRepCode properties" begin + for i in 1:50 + p = 2*i + n = 4*p + k = 2*(p - 2) + stab = parity_checks(DelfosseRepCode(p)) + H = stab_to_gf2(stab) + mat = matrix(GF(2), H) + computed_rank = rank(mat) + @test computed_rank == n - k + end + + # crosscheck parity check matrices from VIII. 1 Generalizing the [4, 1, 4] + # classical repetition code, pg. 10 of https://arxiv.org/pdf/2008.05051 + blocks = 1 + @test _extend_414_repetition_code(blocks) == [1 1 1 1; + 0 0 1 1; + 0 1 0 1]; + blocks = 4 + # [16, 10, 4] classical linear code + @test _extend_414_repetition_code(blocks) == [1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0; + 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0; + 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0; + 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1; + 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1; + 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1] + blocks = 6 + # [24, 16, 4] classical linear code + @test _extend_414_repetition_code(blocks) == [1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0; + 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0; + 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0; + 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0; + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0; + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1; + 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1; + 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1]; + end +end