Skip to content

Commit d931a05

Browse files
authored
Merge branch 'dev' into dev1
2 parents 096a35b + e0d4db6 commit d931a05

File tree

3 files changed

+178
-51
lines changed

3 files changed

+178
-51
lines changed

Project.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1717
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1818
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1919
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
20-
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2120
TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a"
2221

2322
[weakdeps]
@@ -54,3 +53,9 @@ NetworkLayout = "0.4.6"
5453
StatsBase = "0.34.2"
5554
WGLMakie = "0.8.15"
5655
julia = "≥ 1.9"
56+
57+
[extras]
58+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
59+
60+
[targets]
61+
test = ["Test"]
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# misc codes from the literature
2+
@testitem "Quantum/misc_lit_codes.jl" begin
3+
using Oscar
4+
using CodingTheory
5+
6+
@testset "Misc Codes From Literature" begin
7+
# TODO codes from "LRESC" paper, make tests (long range _ surface code?)
8+
# # the dual of any [3, 2, 2] code is a [3, 1, 3] repetition code
9+
# # but we'll build this the GAP way anyway
10+
# C_GAP = GAP.Globals.BestKnownLinearCode(3, 2, GAP.Globals.GF(2));
11+
# G = GAP.Globals.GeneratorMat(C_GAP);
12+
# y = [GAP.Globals.Int(G[i, j]) for i in 1:2, j in 1:3];
13+
# C32 = LinearCode(y, 2);
14+
# R4 = RepetitionCode(2, 4);
15+
# seed1 = concatenate(C32, R4)
16+
# LRESC1 = HypergraphProductCode(parity_check_matrix(seed1), parity_check_matrix(seed1))
17+
18+
# # unclear as to which [6, 2, 4] code they used here
19+
# C_GAP = GAP.Globals.BestKnownLinearCode(6, 2, GAP.Globals.GF(2));
20+
# G = GAP.Globals.GeneratorMat(C_GAP);
21+
# y = [GAP.Globals.Int(G[i, j]) for i in 1:2, j in 1:6];
22+
# C62 = LinearCode(y, 2)
23+
# R2 = RepetitionCode(2, 2);
24+
# seed2 = concatenate(C62, R2)
25+
# LRESC2 = HypergraphProductCode(parity_check_matrix(seed2), parity_check_matrix(seed2))
26+
27+
# # they either could have used this code or the extended Hamming code below
28+
# C_GAP = GAP.Globals.BestKnownLinearCode(8, 4, GAP.Globals.GF(2));
29+
# G = GAP.Globals.GeneratorMat(C_GAP);
30+
# y = [GAP.Globals.Int(G[i, j]) for i in 1:4, j in 1:8];
31+
# C84 = LinearCode(y, 2)
32+
# R3 = RepetitionCode(2, 3);
33+
# seed3 = concatenate(C84, R3)
34+
# LRESC3 = HypergraphProductCode(parity_check_matrix(seed3), parity_check_matrix(seed3))
35+
36+
# ext_Ham = extend(HammingCode(2, 3))
37+
# seed3_alt = concatenate(ext_Ham, R3)
38+
# LRESC3_alt = HypergraphProductCode(parity_check_matrix(seed3_alt), parity_check_matrix(seed3_alt))
39+
40+
# julia> are_permutation_equivalent(C84, ext_Ham)
41+
# (false, missing)
42+
43+
44+
45+
46+
47+
# radial codes
48+
# using StatsBase, Graphs, Oscar, CodingTheory
49+
# F = Oscar.Nemo.Native.GF(2)
50+
# S, x = polynomial_ring(F, :x)
51+
# l = 5
52+
# R, _ = residue_ring(S, x^l - 1)
53+
# A1 = matrix(R, 3, 3,
54+
# [x^3, x^2, x,
55+
# x^4, x^1, x^4,
56+
# x, x^2, x^3])
57+
# A2 = matrix(R, 3, 3,
58+
# [x^3, x^3, 1,
59+
# x, 1, x,
60+
# x^4, x^2, 1])
61+
# code = LiftedProductCode(A1, A2)
62+
# # [[90, 8]]_2 CSS stabilizer code
63+
# # julia> check_weights(code)
64+
# # (w_X, q_X, w_Z, q_Z) = (6, 3, 6, 3)
65+
# L_X = LDPCCode(code.X_stabs);
66+
# G_X, _, _ = Tanner_graph(L_X);
67+
# D_X = DiGraph(G_X);
68+
# L_X_cycles = CodingTheory._modified_hawick_james(D_X, 12);
69+
# countmap(length.(L_X_cycles))
70+
# # Dict{Int64, Int64} with 3 entries:
71+
# # 6 => 48
72+
# # 10 => 4842
73+
# # 8 => 777
74+
# L_Z = LDPCCode(code.Z_stabs);
75+
# G_Z, _, _ = Tanner_graph(L_Z);
76+
# D_Z = DiGraph(G_Z);
77+
# L_Z_cycles = CodingTheory._modified_hawick_james(D_Z, 12);
78+
# countmap(length.(L_Z_cycles))
79+
# # Dict{Int64, Int64} with 3 entries:
80+
# # 6 => 20
81+
# # 10 => 4074
82+
# # 8 => 678
83+
84+
# l = 11
85+
# R, _ = residue_ring(S, x^l - 1)
86+
# A1 = matrix(R, 4, 4,
87+
# [x^10, x^10, x, x^6,
88+
# x^4, x^7, x^5, x^2,
89+
# x^8, x^10, x^6, x^9,
90+
# x, x^6, 1, x^6])
91+
# A2 = matrix(R, 4, 4,
92+
# [x^9, x^5, x^8, x^3,
93+
# x^5, x^4, x, 1,
94+
# 1, x^4, x^6, x^10,
95+
# x^2, x^8, x^4, x^2])
96+
# code = LiftedProductCode(A1, A2)
97+
# # [[352, 18]]_2 CSS stabilizer code
98+
# # julia> check_weights(code)
99+
# # (w_X, q_X, w_Z, q_Z) = (8, 4, 8, 4)
100+
# L_X = LDPCCode(code.X_stabs);
101+
# G_X, _, _ = Tanner_graph(L_X);
102+
# D_X = DiGraph(G_X);
103+
# L_X_cycles = CodingTheory._modified_hawick_james(D_X, 12);
104+
# countmap(length.(L_X_cycles))
105+
# # Dict{Int64, Int64} with 3 entries:
106+
# # 6 => 96
107+
# # 10 => 61668
108+
# # 8 => 3970
109+
# L_Z = LDPCCode(code.Z_stabs);
110+
# G_Z, _, _ = Tanner_graph(L_Z);
111+
# D_Z = DiGraph(G_Z);
112+
# L_Z_cycles = CodingTheory._modified_hawick_james(D_Z, 12);
113+
# countmap(length.(L_Z_cycles))
114+
# # Dict{Int64, Int64} with 3 entries:
115+
# # 6 => 72
116+
# # 10 => 60787
117+
# # 8 => 3954
118+
end
119+
end

test/Quantum/product_codes_test.jl

Lines changed: 53 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -550,58 +550,61 @@
550550
Q = BivariateBicycleCode(a, b)
551551
@test length(Q) == 180
552552
@test dimension(Q) == 8
553-
@test_broken minimum_distance(S) == 16
554-
end
555553

556-
@testset "HyperBicycleCode" begin
557-
# Quantum ``hyperbicycle'' low-density parity check codes with finite rate
558-
559-
# Odd-distance rotated CSS toric codes
560-
# f1 = 1 + x^(2 * t^2 + 1)
561-
# f2 = x * (1 + x^(2 * t^2 - 1))
562-
# t - # errors
563-
# [[2t^2 + 2(t + 1)^2, 2, 2t + 1]]
564-
# [[10, 2, 3]]
565-
# [[26, 2, 5]]
566-
# [[50, 2, 7]]
567-
# [[82, 2, 9]]
568-
# ...
569-
570-
# Figure 2
571-
F = Oscar.Nemo.Native.GF(2)
572-
S, x = polynomial_ring(F, :x)
573-
l = 21
574-
R = ResidueRing(S, x^l - 1)
575-
h = R(1 + x + x^3)
576-
A = residue_polynomial_to_circulant_matrix(h)
577-
a1 = A[1:7, 1:7]
578-
a2 = A[1:7, 8:14]
579-
a3 = A[1:7, 15:21]
580-
χ = 1
581-
Q = HyperBicycleCodeCSS([a1, a2, a3], [a1, a2, a3], χ)
582-
@test length(Q) == 294
583-
@test dimension(Q) == 18
554+
# Table 1 of https://arxiv.org/pdf/2404.17676
555+
# [[72, 8, 6]]
556+
l = 12
557+
m = 3
558+
R, _ = quo(S, ideal(S, [x^l - 1, y^m - 1]))
559+
a = R(x^9 + y^1 + y^2)
560+
b = R(1 + x^1 + x^11)
561+
Q = BivariateBicycleCode(a, b)
562+
@test length(Q) == 72
563+
@test dimension(Q) == 8
564+
@test_broken minimum_distance(S) == 6
584565

585-
# Example 6
586-
l = 30
587-
R = ResidueRing(S, x^l - 1)
588-
h = R(1 + x + x^3 + x^5)
589-
A = residue_polynomial_to_circulant_matrix(h)
590-
a1 = A[1:15, 1:15]
591-
a2 = A[1:15, 16:30]
592-
χ = 1
593-
Q = HyperBicycleCodeCSS([a1, a2], [a1, a2], χ)
594-
@test length(Q) == 900
595-
@test dimension(Q) == 50
566+
# [[90, 8, 6]]
567+
l = 9
568+
m = 5
569+
R, _ = quo(S, ideal(S, [x^l - 1, y^m - 1]))
570+
a = R(x^8 + y^4 + y^1)
571+
b = R(y^5 + x^8 + x^7)
572+
Q = BivariateBicycleCode(a, b)
573+
@test length(Q) == 90
574+
@test dimension(Q) == 8
575+
@test_broken minimum_distance(S) == 6
596576

597-
# Example 13
598-
l = 17
599-
R = ResidueRing(S, x^l - 1)
600-
h = R(x^(div(17 - 9, 2)) * (1 + x + x^3 + x^6 + x^8 + x^9))
601-
A = residue_polynomial_to_circulant_matrix(h)
602-
χ = 1
603-
Q = HyperBicycleCode([A], [A], χ)
604-
@test length(Q) == 289
605-
@test dimension(Q) == 81
577+
# [[120, 8, 8]]
578+
l = 12
579+
m = 5
580+
R, _ = quo(S, ideal(S, [x^l - 1, y^m - 1]))
581+
a = R(x^10 + y^4 + y^1)
582+
b = R(1 + x^1 + x^2)
583+
Q = BivariateBicycleCode(a, b)
584+
@test length(Q) == 120
585+
@test dimension(Q) == 8
586+
@test_broken minimum_distance(S) == 8
587+
588+
# [[150, 8, 8]]
589+
l = 15
590+
m = 5
591+
R, _ = quo(S, ideal(S, [x^l - 1, y^m - 1]))
592+
a = R(x^5 + y^2 + y^3)
593+
b = R(y^2 + x^7 + x^6)
594+
Q = BivariateBicycleCode(a, b)
595+
@test length(Q) == 150
596+
@test dimension(Q) == 8
597+
@test_broken minimum_distance(S) == 8
598+
599+
# [[196, 12, 8]]
600+
l = 14
601+
m = 7
602+
R, _ = quo(S, ideal(S, [x^l - 1, y^m - 1]))
603+
a = R(x^6 + y^5 + y^6)
604+
b = R(1 + x^4 + x^13)
605+
Q = BivariateBicycleCode(a, b)
606+
@test length(Q) == 196
607+
@test dimension(Q) == 12
608+
@test_broken minimum_distance(S) == 8
606609
end
607610
end

0 commit comments

Comments
 (0)