Ask Your Question

Revision history [back]

To construct a matrix of matrices:

sage: a = random_matrix(QQ, 2, 2)
sage: b = random_matrix(QQ, 2, 2)
sage: c = random_matrix(QQ, 2, 2)
sage: d = random_matrix(QQ, 2, 2)
sage: v = matrix([[a,b,c,d]])

It prints horribly (but view(v) looks good).

sage: a
[  2   0]
[  1 1/2]
sage: b
[  0  -1]
[1/2   2]
sage: c
[ 2  1]
[ 2 -2]
sage: d
[ -1 1/2]
[1/2   1]
sage: v
[[  2   0]
[  1 1/2] [  0  -1]
[1/2   2]     [ 2  1]
[ 2 -2] [ -1 1/2]
[1/2   1]]

sage: v.nrows()
1
sage: v.ncols()
4
sage: v.base_ring()
Full MatrixSpace of 2 by 2 dense matrices over Rational Field