@@ -169,12 +169,12 @@ InstallGlobalFunction(CyclicChainMat,function(mat)
169169 A:= ImmutableMatrix(DefaultFieldOfMatrix(mat),mat);
170170 idm:= OneMutable(A);
171171 if IsLowerTriangularMat(A) then
172- return [ idm,idm,[ 1 .. Length (A)+ 1 ] ,[ 1 .. Length (A)]] ;
172+ return [ idm,idm,[ 1 .. NrRows (A)+ 1 ] ,[ 1 .. NrRows (A)]] ;
173173 fi ;
174174 sp:= SpinMatVector1(A,idm[ 1 ] ,[] ,[] ,[] ,[] );
175175 svec:= [ 1 ,Length(sp[ 1 ] )+ 1 ] ;
176176 j:= 1 ;
177- while Length(sp[ 1 ] )< Length (A) do
177+ while Length(sp[ 1 ] )< NrRows (A) do
178178 while j in sp[ 5 ] do
179179 j:= j+ 1 ;
180180 od ;
@@ -230,23 +230,21 @@ end);
230230# Returns vector that has the same minimal polynomial as mat.
231231# For details about this function, see nofoma.gd.
232232InstallGlobalFunction(MaximalVectorMat,function (mat )
233- local A,M,k,idm,sp,l,np,i,v1,z,one,f,rpols,svec,lm;
233+ local A,M,k,idm,sp,l,np,i,v1,z,one,f,rpols,svec,lm,x ;
234234 k:= DefaultFieldOfMatrix(mat);
235235 A:= ImmutableMatrix(k,mat);
236236 one:= One(k);
237237 idm:= OneMutable(A);
238+ x:= Indeterminate(k);
238239 if IsDiagonalMat(A) then # first deal with diagonal matrix
239- if ForAll([ 2 .. Length (A)] ,i-> A[ i,i] = A[ 1 ,1 ] ) then
240+ if ForAll([ 2 .. NrRows (A)] ,i-> A[ i,i] = A[ 1 ,1 ] ) then
240241 v1:= idm[ 1 ] ;
241- np:= nfmPolCoeffs( [ - A[ 1 ,1 ] ,one ] ) ;
242+ np:= x - A[ 1 ,1 ] ;
242243 else
243- v1:= ListWithIdenticalEntries(Length (A),one);
244+ v1:= ListWithIdenticalEntries(NrRows (A),one);
244245 ConvertToVectorRepNC(v1,k);
245- l:= Set([ 1 .. Length(A)] ,i-> A[ i,i] );
246- np:= nfmPolCoeffs([ - l[ 1 ] ,one] );
247- for i in [ 2 .. Length(l)] do
248- np:= nfmPolCoeffs([ - l[ i] ,one] )* np;
249- od ;
246+ l:= Set([ 1 .. NrRows(A)] ,i-> A[ i,i] );
247+ np:= Product(l, a -> x- a);
250248 fi ;
251249 Info (Infonofoma,2 ," #I Degree of minimal polynomial is " ,Degree(np)," \n " );
252250 return [ v1,np] ;
@@ -296,7 +294,7 @@ InstallGlobalFunction(JacobMatComplement,function(T,d)
296294 fi ;
297295 od ;
298296 od ;
299- for i in [ d+ 1 .. Length (T)] do
297+ for i in [ d+ 1 .. NrRows (T)] do
300298 for j in [ 1 .. d] do
301299 base[ i,j] :=- F[ d+ 1 - j][ i] ;
302300 od ;
@@ -308,7 +306,7 @@ end);
308306BindGlobal(" BuildBlockDiagonalMat1" ,function (d,B )
309307 local neu,n,k;
310308 k:= DefaultFieldOfMatrix(B);
311- n:= d+ Length (B);
309+ n:= d+ NrRows (B);
312310 neu:= IdentityMat(n,k);
313311 neu{[ d+ 1 .. n]}{[ d+ 1 .. n]} := B;
314312 ConvertToMatrixRepNC(neu);
@@ -321,7 +319,7 @@ InstallGlobalFunction(RatFormStep1,function(A,v)
321319 sp:= SpinMatVector1(A,v,[] ,[] ,[] ,[] );
322320 t:= sp[ 2 ] ;
323321 d:= Length(t);
324- Append(t,idm{ Difference([ 1 .. Length (A)] ,sp[ 5 ] )} );
322+ Append(t,idm{ Difference([ 1 .. NrRows (A)] ,sp[ 5 ] )} );
325323 ConvertToMatrixRepNC(t);
326324 A1:= t* A* t^ (- 1 );
327325 minp:=- ShallowCopy(A1[ d]{[ 1 .. d]} );
@@ -335,14 +333,14 @@ InstallGlobalFunction(RatFormStep1J,function(A,v)
335333 sp:= SpinMatVector1(A,v,[] ,[] ,[] ,[] );
336334 t:= sp[ 2 ] ;
337335 d:= Length(t);
338- Append(t,idm{ Difference([ 1 .. Length (A)] ,sp[ 5 ] )} );
336+ Append(t,idm{ Difference([ 1 .. NrRows (A)] ,sp[ 5 ] )} );
339337 ConvertToMatrixRepNC(t);
340338 A1:= t* A* t^ (- 1 );
341339 minp:=- ShallowCopy(A1[ d]{[ 1 .. d]} );
342340 Add(minp,minp[ 1 ] ^ 0 );
343341 j:= JacobMatComplement(A1,Length(minp)- 1 );
344342 # return [j*A1*j^-1,j*t,minp];
345- return [ A1{[ d+ 1 .. Length (A1)]}{[ d+ 1 .. Length (A1)]} ,j* t,minp] ;
343+ return [ A1{[ d+ 1 .. NrRows (A1)]}{[ d+ 1 .. NrRows (A1)]} ,j* t,minp] ;
346344end );
347345
348346# TODO: replace by CompanionMat
@@ -382,14 +380,14 @@ InstallGlobalFunction(FrobeniusNormalForm,function(mat)
382380 local A,P,invf,i,k,mv,step1,rest,d,piv;
383381 k:= DefaultFieldOfMatrix(mat);
384382 A:= ImmutableMatrix(k,mat);
385- if IsDiagonalMat(A) and ForAll([ 2 .. Length (A)] ,i-> A[ i,i] = A[ 1 ,1 ] ) then
383+ if IsDiagonalMat(A) and ForAll([ 2 .. NrRows (A)] ,i-> A[ i,i] = A[ 1 ,1 ] ) then
386384 mv:= nfmPolCoeffs([ - A[ 1 ,1 ] ,A[ 1 ,1 ] ^ 0 ] );
387- return [ ListWithIdenticalEntries(Length (A),mv),A^ 0 ,[ 1 .. Length (A)]] ;
385+ return [ ListWithIdenticalEntries(NrRows (A),mv),A^ 0 ,[ 1 .. NrRows (A)]] ;
388386 fi ;
389387 mv:= MaximalVectorMat(A);
390388 invf:= [ mv[ 2 ]] ;
391389 d:= Degree(mv[ 2 ] );
392- if d= Length (A) then # cyclic space: only one companion block
390+ if d= NrRows (A) then # cyclic space: only one companion block
393391 step1:= [ mv[ 1 ]] ; # create base change
394392 for i in [ 2 .. d] do
395393 Add(step1,step1[ i- 1 ] * A);
@@ -416,7 +414,7 @@ InstallGlobalFunction(InvariantFactorsMat,function(mat)
416414 local A,A1,i,d,np,k,f,n,p;
417415 k:= DefaultFieldOfMatrix(mat);
418416 A:= ImmutableMatrix(k,mat);
419- n:= Length (A);
417+ n:= NrRows (A);
420418 np:= MaximalVectorMat(A);
421419 d:= Degree(np[ 2 ] );
422420 f:= [ np[ 2 ]] ;
@@ -491,7 +489,7 @@ InstallGlobalFunction(JordanChevalleyDecMatF,function(mat)
491489 local f,jc,p,N,D;
492490 f:= FrobeniusNormalForm(mat);
493491 Info (Infonofoma,2 ," Frobenius normal form complete\n " );
494- Add(f[ 3 ] ,Length (mat)+ 1 );
492+ Add(f[ 3 ] ,NrRows (mat)+ 1 );
495493 jc:= List(f[ 1 ] ,p-> JordanChevalleyDecMat(nfmCompanionMat1(CoefficientsOfUnivariatePolynomial(p)),p));
496494 N:= 0 * f[ 2 ] ;
497495 D:= 0 * f[ 2 ] ;
@@ -709,7 +707,7 @@ InstallGlobalFunction(PrimaryDecomp, function(A)
709707 for i in [ 1 .. Size(gs)] do
710708 Add(combined, [ gens[ i] ,gs[ i]] );
711709 od ;
712- Sort(combined, function ( v,w ) return v[ 2 ] < w[ 2 ] ; end );
710+ Sort(combined, { v,w} -> v[ 2 ] < w[ 2 ] );
713711 k := 0 ;
714712 dims := [] ;
715713 for i in [ 1 .. Size(gs)] do
@@ -833,19 +831,16 @@ end);
833831# Primary Decomposition for cyclic matrices
834832# Jordan normal form will call this function if a cyclic matrix is detected
835833BindGlobal(" nfmPrimaryDecompositionforJNFCyclic" , function (A, minpol, minpolfacs )
836- local vspan,F, n,w,i ,wspan,qi,k,v ,COB,dims;
834+ local vspan,n,w,mf ,wspan,qi,k,COB,dims;
837835 n := NrRows(A);
838- F := DefaultFieldOfMatrix(A);
839- A := Matrix(F,A);
840836 vspan := nfmFindCyclicVectorNC(A);
841- v := vspan[ 1 ] ;
842837 dims := [] ;
843838 COB := ZeroMutable(A);
844839 k := 0 ;
845- for i in [ 1 .. Size( minpolfacs) ] do
846- qi := (minpolfacs [ i ][ 1 ] )^ (minpolfacs [ i ] [2 ] );
840+ for mf in minpolfacs do
841+ qi := (mf [ 1 ] )^ (mf [ 2 ] );
847842 w := nfmPolyEvalFromSpan(vspan,Quotient(minpol,qi));
848- wspan := nfmSpinUntil(w,A,Degree(minpolfacs [ i ][ 1 ] )* minpolfacs [ i ] [2 ] );
843+ wspan := nfmSpinUntil(w,A,Degree(mf [ 1 ] )* mf [ 2 ] );
849844 CopySubMatrix(wspan, COB, [ 1 .. NrRows(wspan)] , [ k+ 1 .. k+ NrRows(wspan)] , [ 1 .. n] , [ 1 .. n] );
850845 Add(dims, NrRows(wspan));
851846 k := k + NrRows(wspan);
@@ -932,8 +927,8 @@ BindGlobal("CyclicDecompositionOfPrimarySubspace", function (A, p, m)
932927 dims := [] ; # dimensions of my cyclic subspaces
933928 sumdim := 0 ; # dimension of my direct sum
934929 conj := ZeroMutable(A);
935- while not Sum(minpolpowers, function ( v ) return v[ 2 ] * d; end ) = n do # generally bigger than n, working our way down
936- SortBy(minpolpowers, function ( v ) return v[ 2 ] ; end ); # Sort ws by their A-length (ascending)
930+ while not Sum(minpolpowers, v -> v[ 2 ] * d) = n do # generally bigger than n, working our way down
931+ SortBy(minpolpowers, v -> v[ 2 ] ); # Sort ws by their A-length (ascending)
937932 vecs := ZeroVector(F,Length(minpolpowers));
938933 for i in [ 1 .. Length(minpolpowers)] do
939934 vecs[ i] := minpolpowers[ i][ 3 ] ; # p(A)^(r-1)(w)
@@ -964,7 +959,7 @@ BindGlobal("CyclicDecompositionOfPrimarySubspace", function (A, p, m)
964959 fi ;
965960 od ;
966961 currdim := 1 ;
967- SortBy(minpolpowers, function ( v ) return v[ 2 ] ; end ); # sort by A-length
962+ SortBy(minpolpowers, v -> v[ 2 ] ); # sort by A-length
968963 for i in [ 1 .. Length(minpolpowers)] do
969964 wtrip := minpolpowers[ i] ;
970965 conj{[ currdim.. currdim+ (wtrip[ 2 ] * d)- 1 ]}{[ 1 .. n]} := nfmSpinUntil(wtrip[ 1 ] ,A,wtrip[ 2 ] * d);
0 commit comments