Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The block_matrix construction will do what you want. An example follows.

I first set up a dictionary containing data of the kind you discussed (I'm assuming that the final entry in your data set should be $(1,3,D)$ if you want a $4k$ by $4k$ matrix )

sage: d = {}
sage: d[0, 2] = matrix([[5, 11], [1, 2]])
sage: d[0, 3] = matrix([[2, 3], [1, 1]])
sage: d[1, 2] = matrix([[-1, 3], [0, -1]])
sage: d[1, 3] = matrix([[4, 9], [-1, -2]])

Then I defined a 4 by 4 array of zero matrices and put the data matrices in the appropriate positions

sage: m = [[matrix(2, 2, 0)]*4 for _ in range(4)]
sage: for i in range(4):
....:     for j in range(4):
....:         if (i, j) in d:
....:             m[i][j] = d[i, j]
....:         elif (j, i) in d:
....:             m[i][j] = d[j, i].inverse()

Now

sage: block_matrix(m)
[ 0  0| 0  0| 5 11| 2  3]
[ 0  0| 0  0| 1  2| 1  1]
[-----+-----+-----+-----]
[ 0  0| 0  0|-1  3| 4  9]
[ 0  0| 0  0| 0 -1|-1 -2]
[-----+-----+-----+-----]
[-2 11|-1 -3| 0  0| 0  0]
[ 1 -5| 0 -1| 0  0| 0  0]
[-----+-----+-----+-----]
[-1  3|-2 -9| 0  0| 0  0]
[ 1 -2| 1  4| 0  0| 0  0]

All the usual matrix methods are available, e.g.,

sage: block_matrix(m).rank()
6