/
Alternant.mgm
261 lines (201 loc) · 7.18 KB
/
Alternant.mgm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
//==========================================================
// This program generates an alternant code
// Compared to Magma's AlternantCode primitive
// This function permits to specify the subfield
// while Magma's primitive only computes alternant
// codes on the prime subfield.
//==========================================================
//==========================================================
// INPUTS: - The support x (distinct elements of F_q^l);
// - The multiplier y
// - The degree r of the Alternant code
// - The subfield F on which is defined the code.
// - The extension degree m
//----------------------------------------------------------
// OUTPUTS: - The code Alt (F, r, x, y);
// - The GRS whose subfield subcode equals the
// alternant code;
//==========================================================
function Alt(F, r, m, x, y)
FF<w> := ext <F|m>;
R<X> := PolynomialRing(FF, 1);
n := #x;
// Generate a generator matrix of the dual GRS code.
M:=Matrix(r, n, [[y[i]*x[i]^j : i in {1..n}] :
j in {0..r-1}]);
C0:=Dual(LinearCode(M));
return SubfieldSubcode(C0,F), C0;
end function;
//=========================================================
// This program generates a random
// subgroup of s genrators of F_2^m
//=========================================================
//=========================================================
// INPUTS: - The ambient field F
// - the number of generators s
//---------------------------------------------------------
// OUTPUTS : - The list of generators of the group
// - The full list of elements of the group
//=========================================================
function RandomTranslationGroup(F, s)
i := 0;
while i lt s do
Generators := [];
for j:=1 to s do
Append(~Generators, Random(F));
end for;
// Check their independence
M := Matrix(PrimeField(F),
[ElementToSequence(b) : b in Generators]);
i := Rank(M);
end while;
Group := [F | 0, Generators[1]];
for b in Generators[2..s] do
U := [a + b : a in Group];
Group cat:= U;
end for;
assert #Group eq 2^s;
return Generators, Group;
end function;
//=========================================================
// This program returns the whole group
// of translations from a set of generators
//=========================================================
//=========================================================
// INPUTS: - the list of generators Generators
//---------------------------------------------------------
// OUTPUTS : - The full list of elements of the group
//=========================================================
function GroupFromGenerators(Generators)
s := #Generators;
Group := [Universe(Generators)| 0, Generators[1]];
for b in Generators[2..s] do
U := [a + b : a in Group];
Group cat:= U;
end for;
assert #Group eq 2^s;
return Group;
end function;
//==========================================================
// And the reciprocal function
//==========================================================
function GeneratorsFromGroup(Group)
s := 0;
while #Group gt 2^s do
s +:= 1;
end while;
assert #Group eq 2^s;
return [Group[1 + 2^i] : i in {0..s-1}];
end function;
//==========================================================
// This program generates a random
// Quasi-dyadic alternant code
//==========================================================
//==========================================================
// INPUTS: - The code length
// - The degree r of the Alternant code
// - The subfield F on which is defined the code.
// - The extension degree m
// - The number of generators s of the
// automorphism group
//----------------------------------------------------------
// OUTPUTS: - A quasi-dyadic alternant code;
// - The GRS code above
// - Its support x
// - Its multiplier y
//==========================================================
function QDAlternantCode(F, r, m, n, s)
assert (n mod 2^s) eq 0;
FF := ext <F | m>;
// Construct generators for the automorphism group
B, orbit := RandomTranslationGroup(FF, s);
x := [];
y := [];
while #x lt n do
repeat
x_i := Random(FF);
until &and[x_i + a notin x : a in orbit];
x cat:= [x_i + a : a in orbit];
repeat
y_i := Random(FF);
until y_i ne 0;
y cat:= [y_i : j in {1..2^s}];
end while;
//y := [1 : i in {1..n}];
C, GRS := Alt(F, r, m, x, y);
return C, GRS, x, y, B, orbit;
end function;
//==========================================================
// This program generates a random
// Quasi-dyadic alternant code with y = (1 .. 1).
//==========================================================
//==========================================================
// INPUTS: - The code length
// - The degree r of the Alternant code
// - The subfield F on which is defined the code.
// - The extension degree m
// - The number of generators s of the
// automorphism group
//----------------------------------------------------------
// OUTPUTS: - A quasi-dyadic alternant code;
// - The GRS code above
// - Its support x
//==========================================================
function ToyQDAlternantCode(F, r, m, n, s)
assert (n mod 2^s) eq 0;
FF := ext <F | m>;
// Construct generators for the automorphism group
i := 0;
while i lt s do
B := [];
for j:=1 to s do
Append(~B, Random(FF));
end for;
// Check their independence
M := Matrix(PrimeField(FF),
[ElementToSequence(b) : b in B]);
i := Rank(M);
end while;
//print B;
orbit := [FF | 0, B[1]];
for b in B[2..s] do
U := [a + b : a in orbit];
orbit cat:= U;
end for;
assert #orbit eq 2^s;
x := [];
while #x lt n do
repeat
x_i := Random(FF);
until &and[x_i + a notin x : a in orbit];
x cat:= [x_i + a : a in orbit];
end while;
y := [1 : i in {1..n}];
C, GRS := Alt(F, r, m, x, y);
return C, GRS, x;
end function;
//==========================================================
// This program generates a generating set
// for the permutation group of a quasi-dyadic code
//==========================================================
//==========================================================
// INPUTS: - The code length n (should be a multiple of 2^s)
// - the number of generators s (i.e. a group of
// size 2^s)
//----------------------------------------------------------
// OUTPUTS: - A list of permutations
//==========================================================
function ListOfPermutations(n, s)
assert (n mod 2^s) eq 0;
G := SymmetricGroup(n);
L := [G | G!1 : i in {1..s}];
for i in [1..s] do
for j in [1 .. n - 2^i + 1 by 2^i] do
for k in [0 .. 2^(i-1)-1] do
//print j, k;
L[i] := L[i] * G!(j+k, j+k+2^(i-1));
end for;
end for;
end for;
return L;
end function;