Create a block diagonal matrix with different sizes of blocks in GAP

279 Views Asked by At

I don't know if this question has been asked before, or if this is the right site to ask it. If not, let me know about a site where can I ask, please.

Problem: I want to create a block diagonal matrix with different size of blocks in GAP, for example with a block $1\times 1$ and a block $2\times 2$. I read the manual of GAP and I found the command "BlockMatrix" but I don't understand if it is possible to create such a matrix it with different sizes of blocks.

Thanks in advance!

1

There are 1 best solutions below

0
On BEST ANSWER

As long as the blocks are diagonal, you can use DirectSumMat with the matrices to be placed along the diagonal as arguments:

gap> m1:=[[1,2],[3,4]];;
gap> m2:=[[1,2,3],[4,5,6],[7,8,9]];;
gap> DirectSumMat(m1,m2);
[ [ 1, 2, 0, 0, 0 ], [ 3, 4, 0, 0, 0 ], [ 0, 0, 1, 2, 3 ], [ 0, 0, 4, 5, 6 ],
  [ 0, 0, 7, 8, 9 ] ]

If the blocks are not along the diagonal, you would have to build the matrix yourself.

(BlockMatrix is a special representation where blocks must have the same dimension, used mainly for representing induced representations)