// Functions used in paper 10: // _Cohomology and group extensions in Magma_ by Derek F. Holt // Section 2: Computing cohomology groups C0Matrix := function(M) local I; I := IdentityMatrix(BaseRing(M), Dimension(M)); return HorizontalJoin( [ ActionGenerator(M, k) - I : k in [1..Nagens(M)] ]); end function; add_block := procedure(~M, i, j, M2) local rows, cols, block; rows := NumberOfRows(M2); cols := NumberOfColumns(M2); block := ExtractBlock(M, i, j, rows, cols); InsertBlock(~M, block + M2, i, j); end procedure; C1Matrix := function(M) local K, d, G, RG, r, s, rel, w, C1, mat, g, si, sg; K := BaseRing(M); d := Dimension(M); G := Group(M); /* must be of type GrpFP */ RG := Relations(G); r := #Generators(G); s := #RG; C1 := RMatrixSpace(K, r*d, s*d) ! 0; // Now fill in the entries of "C1" for i in [1..s] do /* The i-th relation gives rise to the d columns of C1 from (i-1)*d+1 to i*d. First turn it into a relator. */ rel := RG[i]; w := LHS(rel)*RHS(rel)^-1; si := (i-1)*d + 1; mat := IdentityMatrix(K, d); /* We will scan the relator w from right to left. mat is the matrix of the action of the current suffix of w. */ for g in Reverse(Eltseq(w)) do /* The rows of C1 from (g-1)*d+1 to g*d correspond to generator g, and will be changed by this generator. */ sg := (Abs(g) - 1)*d + 1; if g lt 0 then mat := ActionGenerator(M, -g)^-1 * mat; end if; add_block(~C1, sg, si, Sign(g)*mat); if g gt 0 then mat := ActionGenerator(M, g) * mat; end if; end for; end for; return C1; end function;