Skip to content

Commit 6a4b3ec

Browse files
committed
Simplify some code
1 parent 1a415da commit 6a4b3ec

File tree

7 files changed

+13
-17
lines changed

7 files changed

+13
-17
lines changed

lib/codecr.gi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ CalculateLinearCodeCoveringRadius := function( code )
4343
# (old version had line above in place of next 5)
4444
H:=CheckMat(code);
4545
CLs:=GuavaCosetLeadersMatFFE(H,LeftActingDomain(code));
46-
wts:=List([1..Length(CLs)],i->WeightVecFFE(CLs[i]));
46+
wts:=List(CLs, WeightVecFFE);
4747
rho:=Maximum(wts);
4848
return rho;
4949
fi;

lib/codecstr.gi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ function(C, D, check)
9797
NewH := List( [ 2..Length( H ) ], x -> H[ x ] );
9898
# throw away the first column of H' (it is (1, 0, ..., 0),
9999
# the one is already present in the new generator matrix)
100-
NewH := List( [ 1..Length( NewH ) ], x -> List(
101-
[ 2 .. WordLength( D ) ], y -> NewH[ x ][ y ] ) );
100+
NewH := List( NewH, x -> List(
101+
[ 2 .. WordLength( D ) ], y -> x[ y ] ) );
102102
# fill the lower left part with zeroes
103103
Nulmat := List( [ 1 .. Dimension( D ) - 1 ],
104104
x -> NullVector( WordLength( C ) , LeftActingDomain(C) ) );

lib/codegen.gi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1903,7 +1903,7 @@ function(n, L, F)
19031903
fi;
19041904
p := Characteristic(Field(L));
19051905
CC:=CyclotomicCosets(p,q-1);
1906-
CCz:=List([1..Length(CC)],i->List(CC[i],j->z^j));
1906+
CCz:=List(CC,cc->List(cc,j->z^j));
19071907
## this is the set of cyclotomic cosets, represented
19081908
## as powers of a primitive element z
19091909
powerlist := [];

lib/codeman.gi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2138,7 +2138,7 @@ __G_BZCode := function(O, I)
21382138
VectorRep := function(e, F)
21392139
local a, f, MF;
21402140
if IsZero(e) then;
2141-
return List([1..LogInt(Size(F), Characteristic(F))], i->Zero(GF(Characteristic(F))));
2141+
return List([1..DegreeOverPrimeField(F)], i->Zero(GF(Characteristic(F))));
21422142
fi;
21432143
a := PrimitiveElement(F);
21442144
f := MinimalPolynomial( GF(Characteristic(F)), a);
@@ -2152,17 +2152,17 @@ __G_BZCode := function(O, I)
21522152
fi;
21532153

21542154
# Make sure list O (outer codes) contains all linear codes
2155-
if (PositionNot( List([1..Size(O)], i->IsLinearCode(O[i])), true ) < Size(O)) then
2155+
if not ForAll(O, IsLinearCode) then
21562156
Error("The list O contains non linear code(s)\n");
21572157
fi;
21582158

21592159
# Make sure list I (inner codes) contains all linear codes
2160-
if (PositionNot( List([1..Size(I)], i->IsLinearCode(I[i])), true ) < Size(I)) then
2160+
if not ForAll(I, IsLinearCode) then
21612161
Error("The list I contains non linear code(s)\n");
21622162
fi;
21632163

21642164
# Make sure that all outer codes have the same length
2165-
if (PositionNot(List([1..Size(O)], i->CodeLength(O[i])), CodeLength(O[1])) < Size(O)) then
2165+
if Length(Set(O, CodeLength)) > 1 then
21662166
Error("Code lengths of all outer codes are required to be the same\n");
21672167
fi;
21682168

lib/curves.gi

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,7 @@ local partsf,monsf,vars,deg,i,j;
140140
partsf:=ConstituentsPolynomial(f);
141141
# varsf:=partsf.variables;
142142
monsf:=partsf.monomials;
143-
deg:=List([1..Length(monsf)],i->
144-
List([1..Length(vars)],j->
145-
[monsf[i],vars[j],DegreeIndeterminate(monsf[i],vars[j])]));
143+
deg:=List(monsf,mon->List(vars,var->[mon,var,DegreeIndeterminate(mon,var)]));
146144
return deg;
147145
end);
148146

@@ -161,9 +159,7 @@ local partsf,monsf,vars,deg,i,j;
161159
partsf:=ConstituentsPolynomial(f);
162160
# varsf:=partsf.variables;
163161
monsf:=partsf.monomials;
164-
deg:=List([1..Length(monsf)],i->
165-
Sum(List([1..Length(vars)],j->
166-
DegreeIndeterminate(monsf[i],vars[j]))));
162+
deg:=List(monsf,mon->Sum(vars,var->DegreeIndeterminate(mon,var)));
167163
return Maximum(deg);
168164
end);
169165

lib/decoders.gi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ function (C, r)
361361
fi;
362362
x := Indeterminate(F);
363363
if q = 2 then # error locator is not necessary
364-
pol := Sum(List([1..Length(ErrorLocator)], i->x^ErrorLocator[i]));
364+
pol := Sum(List(ErrorLocator, i->x^i));
365365
return Codeword((r - pol) mod (x^n-1), C);
366366
else
367367
pol := Derivative(sigma);

lib/matrices.gi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,10 @@ function(arg)
321321
if Length(arg) = 1 then
322322
M:=arg[1];
323323
else
324-
M:=List([1..Length(arg)],i->arg[i]);
324+
M:=arg;
325325
fi;
326326
n:=Length(M);
327-
if ( n >= Length(M[1]) ) or not ForAll(M, i-> IsLatinSquare(i)) then
327+
if n >= Length(M[1]) or not ForAll(M, IsLatinSquare) then
328328
return false; #this is right
329329
fi;
330330
q2 := Length(M[1])^2;

0 commit comments

Comments
 (0)