DirectSumMat for general fields in GAP

63 Views Asked by At

The GAP-command DirectSumMat allows to take the direct sum of matrices over (only certain?) fields. Now I did the following in GAP:

F:=FunctionField(Rationals,["x1","x2","x3","x4"]);AssignGeneratorVariables(F);
N:=[[x1,x2],[x3,x4]];U:=DirectSumMat(N,N);

This gives an error so it seems that the command DirectSumMat does not work over the field F:=FunctionField(Rationals,["x1","x2","x3","x4"]); or am I using the command wrong? The command DirectSumMat seems to work fine over the rationals.

Question: Is there an easy fix for this so that one can take the direct sum of matrices over any fields in GAP?

1

There are 1 best solutions below

0
On

As a workaround until DirectSumMat is fixed (hopefully in GAP 4.13.0, to be released in a couple weeks if all goes well), you can use this helper. For simplicity, it takes the coefficient ring plus two matrices; if you need more you can either call it multiple times or adapt it suitably):

MyDirectSumMat:=function(R,m1,m2)
  local m, r1, r2, c1, c2;
  r1 := NrRows(m1);
  r2 := NrRows(m2);
  c1 := NrCols(m1);
  c2 := NrCols(m2);
  m := NullMat(r1+r2, c1+c2, R);
  CopySubMatrix(m1, m, [1..r1], [1..r1], [1..c1], [1..c1] );
  CopySubMatrix(m2, m, [1..r2], [r1+1..r1+r2], [1..c2], [c1+1..c1+c2] );
  return m;
end;

Example:

gap> F:=FunctionField(Rationals,["x1","x2","x3","x4"]);AssignGeneratorVariables(F);
FunctionField(...,[ x1, x2, x3, x4 ])
#I  Assigned the global variables [ x1, x2, x3, x4 ]
gap> N:=[[x1,x2],[x3,x4]];
[ [ x1, x2 ], [ x3, x4 ] ]
gap> U:=MyDirectSumMat(F, N, N);
[ [ x1, x2, 0, 0 ], [ x3, x4, 0, 0 ], [ 0, 0, x1, x2 ], [ 0, 0, x3, x4 ] ]