Skip to content

Commit

Permalink
add test suite for [[4p, 2(p − 2), 4]] DelfosseRepCode
Browse files Browse the repository at this point in the history
  • Loading branch information
Fe-r-oz committed Jan 21, 2025
1 parent ffb7178 commit a8c4fc2
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/ecc/codes/delfosserepcode.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
45 changes: 45 additions & 0 deletions test/test_ecc_delfosse_repcode.jl
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a8c4fc2

Please sign in to comment.