diff --git a/lib/meataxe.gi b/lib/meataxe.gi index e98730d22e..8baa93c8c2 100644 --- a/lib/meataxe.gi +++ b/lib/meataxe.gi @@ -14,24 +14,29 @@ InstallGlobalFunction(GModuleByMats,function(arg) local l,f,dim,m; - l:=arg[1]; - if Length(arg)=1 then + if Length(arg)<>2 and Length(arg)<>3 then Error("Usage: GModuleByMats(,[,])"); fi; + l:=arg[1]; f:=arg[Length(arg)]; if Length(l)>0 and Characteristic(l[1])<>Characteristic(f) then Error("matrices and field do not fit together"); fi; l:=List(l,i->ImmutableMatrix(f,i)); - if ForAny(l,i->Length(i)<>Length(i[1])) or - Length(Set(l,Length))>1 then + if ForAny(l,i->NrRows(i)<>NrCols(i)) or + Length(Set(l,NrRows))>1 then Error(" must be a list of square matrices of the same dimension"); fi; m:=rec(field:=f, isMTXModule:=true); if Length(l)>0 then - dim:=Length(l[1][1]); + dim:=NrRows(l[1]); + if Length(arg) = 3 then + if dim <> arg[2] then + Error("matrices and dim do not fit together"); + fi; + fi; elif Length(arg)=2 then Error("if no generators are given the dimension must be given explicitly"); else diff --git a/tst/testinstall/meataxe.tst b/tst/testinstall/meataxe.tst index f8a68f2010..cfa58fd34b 100644 --- a/tst/testinstall/meataxe.tst +++ b/tst/testinstall/meataxe.tst @@ -1,6 +1,26 @@ #@local G,M,M2,M3,M4,M5,V,bf,bo,cf,homs,m,mat,qf,randM,res,sf,subs,mats,Q,orig,S gap> START_TEST("meataxe.tst"); +# +# GModuleByMats input validation +# +gap> GModuleByMats(); +Error, Usage: GModuleByMats(,[,]) +gap> GModuleByMats([], 2, GF(2), "extra"); +Error, Usage: GModuleByMats(,[,]) +gap> GModuleByMats([[[Z(2)]]], 2, GF(2)); +Error, matrices and dim do not fit together +gap> GModuleByMats([[[Z(2),Z(2)]]], GF(2)); +Error, must be a list of square matrices of the same dimension +gap> GModuleByMats([[[Z(2)]], [[Z(2),Z(2)],[Z(2),0*Z(2)]]], GF(2)); +Error, must be a list of square matrices of the same dimension + +# module with no generators +gap> GModuleByMats([], 2, GF(2)); +rec( IsOverFiniteField := true, dimension := 2, field := GF(2), + generators := [ ], isMTXModule := true, + smashMeataxe := rec( isZeroGens := true ) ) + # # #