Skip to content

Commit a43e5ff

Browse files
committed
improve code quality by removing redundancy
1 parent ae51ea2 commit a43e5ff

File tree

1 file changed

+26
-46
lines changed

1 file changed

+26
-46
lines changed

test/test_ecc_nonabelin2bga.jl

Lines changed: 26 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1-
@testitem "ECC 2BGA lin2024quantum" begin
2-
import Hecke: group_algebra, GF, abelian_group, gens, quo, one
1+
@testitem "ECC 2BGA abelian and non-abelian groups via group presentation" begin
2+
using Nemo: FqFieldElem
3+
using Hecke: group_algebra, GF, abelian_group, gens, quo, one, GroupAlgebra
34
using QuantumClifford.ECC
4-
using QuantumClifford.ECC: LPCode, code_k, code_n, two_block_group_algebra_codes
5-
using Oscar: free_group, small_group_identification, describe
5+
using QuantumClifford.ECC: code_k, code_n, two_block_group_algebra_codes
6+
using Oscar: free_group, small_group_identification, describe, order, FPGroupElem, FPGroup, FPGroupElem
7+
8+
function get_code(a_elts::Vector{FPGroupElem}, b_elts::Vector{FPGroupElem}, F2G::GroupAlgebra{FqFieldElem, FPGroup, FPGroupElem})
9+
a = sum(F2G(x) for x in a_elts)
10+
b = sum(F2G(x) for x in b_elts)
11+
c = two_block_group_algebra_codes(a,b)
12+
return c
13+
end
614

715
@testset "Reproduce Table 1 Block 1" begin
816
# [[72, 8, 9]]
@@ -13,9 +21,7 @@
1321
r = gens(G)[1]
1422
a_elts = [one(G), r^28]
1523
b_elts = [one(G), r, r^18, r^12, r^29, r^14]
16-
a = sum(F2G(x) for x in a_elts)
17-
b = sum(F2G(x) for x in b_elts)
18-
c = two_block_group_algebra_codes(a, b)
24+
c = get_code(a_elts, b_elts, F2G)
1925
@test describe(G) == "C36"
2026
@test small_group_identification(G) == (36, 2)
2127
@test code_n(c) == 72 && code_k(c) == 8
@@ -30,9 +36,7 @@
3036
r, s = gens(G)
3137
a_elts = [one(G), r]
3238
b_elts = [one(G), s, r^6, s^3 * r, s * r^7, s^3 * r^5]
33-
a = sum(F2G(x) for x in a_elts)
34-
b = sum(F2G(x) for x in b_elts)
35-
c = two_block_group_algebra_codes(a, b)
39+
c = get_code(a_elts, b_elts, F2G)
3640
@test describe(G) == "C9 : C4"
3741
@test small_group_identification(G) == (36, 1)
3842
@test code_n(c) == 72 && code_k(c) == 8
@@ -45,9 +49,7 @@
4549
r, s = gens(G)
4650
a_elts = [one(G), s*r^4]
4751
b_elts = [one(G), r, r^2, s, s^3 * r, s^2 * r^6]
48-
a = sum(F2G(x) for x in a_elts)
49-
b = sum(F2G(x) for x in b_elts)
50-
c = two_block_group_algebra_codes(a, b)
52+
c = get_code(a_elts, b_elts, F2G)
5153
@test describe(G) == "C5 : C8"
5254
@test small_group_identification(G) == (40, 1)
5355
@test code_n(c) == 80 && code_k(c) == 8
@@ -62,9 +64,7 @@
6264
r = gens(G)[1]
6365
a_elts = [one(G), r, r^3, r^7]
6466
b_elts = [one(G), r, r^12, r^19]
65-
a = sum(F2G(x) for x in a_elts);
66-
b = sum(F2G(x) for x in b_elts)
67-
c = two_block_group_algebra_codes(a, b)
67+
c = get_code(a_elts, b_elts, F2G)
6868
@test describe(G) == "C27"
6969
@test small_group_identification(G) == (27, 1)
7070
@test code_n(c) == 54 && code_k(c) == 6
@@ -77,9 +77,7 @@
7777
r = gens(G)[1]
7878
a_elts = [one(G), r^10, r^6, r^13]
7979
b_elts = [one(G), r^25, r^16, r^12]
80-
a = sum(F2G(x) for x in a_elts);
81-
b = sum(F2G(x) for x in b_elts)
82-
c = two_block_group_algebra_codes(a, b)
80+
c = get_code(a_elts, b_elts, F2G)
8381
@test describe(G) == "C30"
8482
@test small_group_identification(G) == (30, 4)
8583
@test code_n(c) == 60 && code_k(c) == 6
@@ -92,9 +90,7 @@
9290
r = gens(G)[1]
9391
a_elts = [one(G), r^15, r^16, r^18]
9492
b_elts = [one(G), r, r^24, r^27]
95-
a = sum(F2G(x) for x in a_elts);
96-
b = sum(F2G(x) for x in b_elts)
97-
c = two_block_group_algebra_codes(a, b)
93+
c = get_code(a_elts, b_elts, F2G)
9894
@test describe(G) == "C35"
9995
@test small_group_identification(G) == (35, 1)
10096
@test code_n(c) == 70 && code_k(c) == 8
@@ -107,9 +103,7 @@
107103
r = gens(G)[1]
108104
a_elts = [one(G), r^9, r^28, r^31]
109105
b_elts = [one(G), r, r^21, r^34]
110-
a = sum(F2G(x) for x in a_elts);
111-
b = sum(F2G(x) for x in b_elts)
112-
c = two_block_group_algebra_codes(a, b)
106+
c = get_code(a_elts, b_elts, F2G)
113107
@test describe(G) == "C36"
114108
@test small_group_identification(G) == (36, 2)
115109
@test code_n(c) == 72 && code_k(c) == 8
@@ -122,9 +116,7 @@
122116
r = gens(G)[1]
123117
a_elts = [one(G), r^9, r^28, r^13]
124118
b_elts = [one(G), r, r^3, r^22]
125-
a = sum(F2G(x) for x in a_elts);
126-
b = sum(F2G(x) for x in b_elts)
127-
c = two_block_group_algebra_codes(a, b)
119+
c = get_code(a_elts, b_elts, F2G)
128120
@test describe(G) == "C36"
129121
@test small_group_identification(G) == (36, 2)
130122
@test code_n(c) == 72 && code_k(c) == 10
@@ -139,9 +131,7 @@
139131
r, s = gens(G)
140132
a_elts = [one(G), s, r, s*r^6]
141133
b_elts = [one(G), s^2*r, s^2*r^6, r^2]
142-
a = sum(F2G(x) for x in a_elts);
143-
b = sum(F2G(x) for x in b_elts)
144-
c = two_block_group_algebra_codes(a, b)
134+
c = get_code(a_elts, b_elts, F2G)
145135
@test describe(G) == "C9 : C4"
146136
@test small_group_identification(G) == (36, 1)
147137
@test code_n(c) == 72 && code_k(c) == 8
@@ -154,9 +144,7 @@
154144
r, s = gens(G)
155145
a_elts = [one(G), r, s, s^3*r^5]
156146
b_elts = [one(G), r^2, s*r^4, s^3*r^2]
157-
a = sum(F2G(x) for x in a_elts)
158-
b = sum(F2G(x) for x in b_elts)
159-
c = two_block_group_algebra_codes(a, b)
147+
c = get_code(a_elts, b_elts, F2G)
160148
@test describe(G) == "C5 : C8"
161149
@test small_group_identification(G) == (40, 1)
162150
@test code_n(c) == 80 && code_k(c) == 8
@@ -169,9 +157,7 @@
169157
r, s = gens(G)
170158
a_elts = [one(G), r, s, r^14]
171159
b_elts = [one(G), r^2, s*r^4, r^11]
172-
a = sum(F2G(x) for x in a_elts)
173-
b = sum(F2G(x) for x in b_elts)
174-
c = two_block_group_algebra_codes(a, b)
160+
c = get_code(a_elts, b_elts, F2G)
175161
@test describe(G) == "C3 : C16"
176162
@test small_group_identification(G) == (48, 1)
177163
@test code_n(c) == 96 && code_k(c) == 6
@@ -184,9 +170,7 @@
184170
r, s = gens(G)
185171
a_elts = [one(G), r^7, r^8, s*r^10]
186172
b_elts = [one(G), s, r^5, s^2*r^13]
187-
a = sum(F2G(x) for x in a_elts)
188-
b = sum(F2G(x) for x in b_elts)
189-
c = two_block_group_algebra_codes(a, b)
173+
c = get_code(a_elts, b_elts, F2G)
190174
@test describe(G) == "C7 x S3"
191175
@test small_group_identification(G) == (42, 3)
192176
@test code_n(c) == 84 && code_k(c) == 10
@@ -199,9 +183,7 @@
199183
r, s = gens(G)
200184
a_elts = [one(G), s, r^9, s * r]
201185
b_elts = [one(G), s^2 * s^9, r^7, r^2]
202-
a = sum(F2G(x) for x in a_elts);
203-
b = sum(F2G(x) for x in b_elts)
204-
c = two_block_group_algebra_codes(a, b)
186+
c = get_code(a_elts, b_elts, F2G)
205187
@test describe(G) == "C12 : C4"
206188
@test small_group_identification(G) == (48, 13)
207189
@test code_n(c) == 96 && code_k(c) == 6
@@ -214,9 +196,7 @@
214196
r, s = gens(G)
215197
a_elts = [one(G), r, s^3 * r^2, s^2 * r^3]
216198
b_elts = [one(G), r, s^4 * r^6, s^5 * r^3]
217-
a = sum(F2G(x) for x in a_elts)
218-
b = sum(F2G(x) for x in b_elts)
219-
c = two_block_group_algebra_codes(a, b)
199+
c = get_code(a_elts, b_elts, F2G)
220200
@test describe(G) == "C2 x (C3 : C8)"
221201
@test small_group_identification(G) == (48, 9)
222202
@test code_n(c) == 96 && code_k(c) == 12

0 commit comments

Comments
 (0)