Skip to content

Commit c03ba39

Browse files
authored
Use downward ranges instead of reversing upward ranges (#59)
1 parent 114aa5f commit c03ba39

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

gap/nofoma.gi

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ InstallGlobalFunction(PolynomialToMatVec,function(A,pol,v)
4848
coeffs := CoefficientsOfUnivariatePolynomial(pol);
4949
n:=Length(coeffs);
5050
v1:=ShallowCopy(coeffs[n]*v);
51-
for i in Reversed([1..n-1]) do
51+
for i in [n-1,n-2..1] do
5252
v1:=v1*A;
5353
if not IsZero(coeffs[i]) then
5454
AddRowVector(v1,v,coeffs[i]);
@@ -65,7 +65,7 @@ InstallGlobalFunction(PolynomialToMat,function(A,pol)
6565
coeffs := CoefficientsOfUnivariatePolynomial(pol);
6666
n:=Length(coeffs);
6767
A1:=coeffs[n]*idm;
68-
for i in Reversed([1..n-1]) do
68+
for i in [n-1,n-2..1] do
6969
A1:=A1*A;
7070
if not IsZero(coeffs[i]) then
7171
A1:=A1+coeffs[i]*idm;
@@ -205,7 +205,7 @@ BindGlobal("nfmOrderPolM",function(M,svec,rpols,z,v)
205205
local i,f,v1,h,g,l;
206206
f:=[];
207207
v1:=ShallowCopy(v);
208-
for i in Reversed([1..z]) do
208+
for i in [z,z-1..1] do
209209
l:=v1{[svec[i]..svec[i+1]-1]};
210210
if not IsZero(l) then
211211
if IsOne(Degree(rpols[i])) then
@@ -606,9 +606,10 @@ BindGlobal("nfmFindCyclicVectorNC", function(A) #Field F, Matrix A, n upper boun
606606
end);
607607

608608
BindGlobal("nfmRemoveZeroRows", function(mat)
609-
local i,matcopy;
609+
local n,i,matcopy;
610610
matcopy := MutableCopyMat(mat);
611-
for i in Reversed([1..NrRows(matcopy)]) do
611+
n := NrRows(matcopy);
612+
for i in [n,n-1..1] do
612613
if IsZero(matcopy[i]) then
613614
Remove(matcopy, i);
614615
fi;

0 commit comments

Comments
 (0)