diff --git a/lib/twocohom.gi b/lib/twocohom.gi index 5ad3bedbd1..d504e29dc3 100644 --- a/lib/twocohom.gi +++ b/lib/twocohom.gi @@ -987,7 +987,8 @@ local field,fp,fpg,gens,hom,mats,fm,mon,tzrules,dim,rules,eqs,i,j,k,l,o,l1, #eqs:=Filtered(TriangulizedMat(eqs),x->not IsZero(x)); eqs:=ShallowCopy(BasisVectors(eqs)); if Length(eqs)=0 then - eqs:=IdentityMat(Length(rules),field); + # no conditions, so the whole space of tail vectors consists of cocycles + eqs:=IdentityMat(nvars,field); else eqs:=ImmutableMatrix(field,eqs); eqs:=NullspaceMat(TransposedMat(eqs)); # basis of cocycles diff --git a/tst/testbugfix/2026-08-02-TwoCohomologyGeneric.tst b/tst/testbugfix/2026-08-02-TwoCohomologyGeneric.tst new file mode 100644 index 0000000000..9f29980431 --- /dev/null +++ b/tst/testbugfix/2026-08-02-TwoCohomologyGeneric.tst @@ -0,0 +1,17 @@ +# TwoCohomologyGeneric used the wrong dimension for the space of cocycles +# in case no conditions on the tails were found, which made it error out +# (or return a wrong answer) for modules of dimension > 1. +gap> triv:=function(G,d,F) +> local mo; +> mo:=GModuleByMats(List(GeneratorsOfGroup(G),x->IdentityMat(d,F)),d,F); +> return Length(TwoCohomologyGeneric(G,mo).cohomology); +> end;; +gap> List([1..3],d->triv(CyclicGroup(2),d,GF(2))); +[ 1, 2, 3 ] +gap> List([1..3],d->triv(ElementaryAbelianGroup(8),d,GF(2))); +[ 6, 12, 18 ] +gap> List([1..3],d->triv(DihedralGroup(8),d,GF(2))); +[ 3, 6, 9 ] +gap> List([1..3],d->triv(CyclicGroup(3),d,GF(3))); +[ 1, 2, 3 ] +gap> Unbind(triv);