Skip to content

Commit

Permalink
meataxe: dedup code via SMTX._NewGModule helper
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Nov 9, 2024
1 parent 0137bde commit 08ae33c
Showing 1 changed file with 28 additions and 63 deletions.
91 changes: 28 additions & 63 deletions lib/meataxe.gi
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,18 @@ end;

SMTX.SubmoduleGModule:=SMTX.SubGModule;

# internal helper to created a new induced/quotient/sub module over a
# a given module, taking MTX.IsZeroGens into account
SMTX._NewGModule:=function(module, newgens)
local F;
F:=SMTX.Field(module);
if SMTX.IsZeroGens(module) then
return GModuleByMats([],Length(newgens[1]),F);
else
return GModuleByMats(newgens,F);
fi;
end;

#############################################################################
##
#F SMTX.SubQuotActions(module,sub,typ) . . .
Expand Down Expand Up @@ -631,7 +643,7 @@ end;
## module for which sub is the basis.
## If sub does not generate a submodule then fail is returned.
SMTX.InducedActionSubmoduleNB:=function( module, sub )
local ans, smodule, F;
local ans;

if Length(sub) = 0 then
return List(module.generators,i->[[]]);
Expand All @@ -643,18 +655,12 @@ SMTX.InducedActionSubmoduleNB:=function( module, sub )
return fail;
fi;

F:=SMTX.Field(module);
if SMTX.IsZeroGens(module) then
smodule:=GModuleByMats([],Length(ans.smatrices[1]),F);
else
smodule:=GModuleByMats(ans.smatrices,F);
fi;
return smodule;
return SMTX._NewGModule(module, ans.smatrices);
end;

# Ditto, but allowing also unnormed modules
SMTX.InducedActionSubmodule:=function(module,sub)
local nb,ans,smodule,F;
local nb,ans;

nb:=SMTX.NormedBasisAndBaseChange(sub);
sub:=nb[1];
Expand All @@ -671,13 +677,7 @@ local nb,ans,smodule,F;
fi;

# conjugate the matrices to correspond to given sub
F:=SMTX.Field(module);
if SMTX.IsZeroGens(module) then
smodule:=GModuleByMats([],Length(ans.smatrices[1]),F);
else
smodule:=GModuleByMats(List(ans.smatrices,i->i^nb),F);
fi;
return smodule;
return SMTX._NewGModule(module, List(ans.smatrices,i->i^nb));;
end;

SMTX.ProperSubmoduleBasis:=function(module)
Expand All @@ -698,7 +698,7 @@ end;
## is the quotient module.
##
SMTX.InducedActionFactorModule:=function(module, sub, compl...)
local ans, F, qmodule;
local ans;

sub:=TriangulizedMat(sub);

Expand All @@ -719,13 +719,7 @@ local ans, F, qmodule;
ans.qmatrices:=List(ans.qmatrices,i->i^sub);
fi;

F:=SMTX.Field(module);
if SMTX.IsZeroGens(module) then
qmodule:=GModuleByMats([],Length(ans.qmatrices[1]),F);
else
qmodule:=GModuleByMats(ans.qmatrices, F);
fi;
return qmodule;
return SMTX._NewGModule(module, ans.qmatrices);
end;

#############################################################################
Expand All @@ -734,7 +728,7 @@ end;
##
# FIXME: this function is never used and documented. Keep it or remove it?
SMTX.InducedActionFactorModuleWithBasis:=function(module,sub)
local ans, F, qmodule;
local ans, qmodule;

sub:=TriangulizedMat(sub);

Expand All @@ -750,13 +744,7 @@ local ans, F, qmodule;

# fetch new basis
sub:=ans.nbasis{[Length(sub)+1..module.dimension]};

F:=SMTX.Field(module);
if SMTX.IsZeroGens(module) then
qmodule:=GModuleByMats([],Length(ans.qmatrices[1]),F);
else
qmodule:=GModuleByMats(ans.qmatrices, F);
fi;
qmodule:=SMTX._NewGModule(module, ans.qmatrices);
return [qmodule,sub];

end;
Expand All @@ -780,7 +768,7 @@ end;
## corresponding matrices of smodule and qmodule resepctively.
## If sub is not the basis of a submodule then fail is returned.
SMTX.InducedAction:=function(module, sub, typ... )
local ans,F,erg;
local ans,erg;

if Length(typ)>0 then
typ:=typ[1];
Expand All @@ -796,27 +784,14 @@ local ans,F,erg;

ans:=[];

F:=SMTX.Field(module);
if IsBound(erg.smatrices) then
if SMTX.IsZeroGens(module) then
Add(ans,GModuleByMats([],Length(erg.smatrices[1]), F));
else
Add(ans,GModuleByMats(erg.smatrices, F));
fi;
Add(ans,SMTX._NewGModule(module, erg.smatrices));
fi;
if IsBound(erg.qmatrices) then
if SMTX.IsZeroGens(module) then
Add(ans,GModuleByMats([],Length(erg.qmatrices[1]), F));
else
Add(ans,GModuleByMats(erg.qmatrices, F));
fi;
Add(ans,SMTX._NewGModule(module, erg.qmatrices));
fi;
if IsBound(erg.nmatrices) then
if SMTX.IsZeroGens(module) then
Add(ans,GModuleByMats([],Length(erg.nmatrices[1]), F));
else
Add(ans,GModuleByMats(erg.nmatrices, F));
fi;
Add(ans,SMTX._NewGModule(module, erg.nmatrices));
fi;
if IsBound(erg.nbasis) then
Add(ans,erg.nbasis);
Expand Down Expand Up @@ -3037,13 +3012,7 @@ local cf;
end;

SMTX.DualModule:=function(module)
if SMTX.IsZeroGens(module) then
return GModuleByMats([],module.dimension,SMTX.Field(module));
else
return GModuleByMats(List(SMTX.Generators(module),i->TransposedMat(i)^-1),
module.dimension,
SMTX.Field(module));
fi;
return SMTX._NewGModule(module, List(SMTX.Generators(module),i->TransposedMat(i)^-1));
end;

###############################################################################
Expand Down Expand Up @@ -3279,13 +3248,9 @@ SMTX.TwistedDualModule:=function(module)
if r^2 <> q then
Error("Size of field of module is not a square");
fi;
if SMTX.IsZeroGens(module) then
return GModuleByMats([],module.dimension,SMTX.Field(module));
else
mats:=List( SMTX.Generators(module),
i->SMTX.MatrixUnderFieldAuto(TransposedMat(i)^-1,r) );
return GModuleByMats( mats, module.dimension, SMTX.Field(module) );
fi;
mats:=List( SMTX.Generators(module),
i->SMTX.MatrixUnderFieldAuto(TransposedMat(i)^-1,r) );
return SMTX._NewGModule(module, mats);
end;

SMTX.SetInvariantSesquilinearForm:=function(module,b)
Expand Down

0 comments on commit 08ae33c

Please sign in to comment.