Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
sage: v = range(-2,6) # a list that arbitrarily given 
sage: m = 3 # off-diagonal index
sage: T = block_matrix([[zero_matrix(len(v),m), diagonal_matrix(v)],
                        [zero_matrix(m,m),0]])     
sage: # len(v), get the length of the list to determine the dimensional of T
sage: T # result
[ 0  0  0|-2  0  0  0  0  0  0  0]
[ 0  0  0| 0 -1  0  0  0  0  0  0]
[ 0  0  0| 0  0  0  0  0  0  0  0]
[ 0  0  0| 0  0  0  1  0  0  0  0]
[ 0  0  0| 0  0  0  0  2  0  0  0]
[ 0  0  0| 0  0  0  0  0  3  0  0]
[ 0  0  0| 0  0  0  0  0  0  4  0]
[ 0  0  0| 0  0  0  0  0  0  0  5]
[--------+-----------------------]
[ 0  0  0| 0  0  0  0  0  0  0  0]
[ 0  0  0| 0  0  0  0  0  0  0  0]
[ 0  0  0| 0  0  0  0  0  0  0  0]
sage: v = range(-2,6) # a list that list, arbitrarily given 
sage: m = 3 # the off-diagonal index
sage: T = block_matrix([[zero_matrix(len(v),m), block_matrix([[zero_matrix(len(v),off), diagonal_matrix(v)],
                        [zero_matrix(m,m),0]])     
sage: # len(v), get the length of the list to determine the dimensional of T
sage: T # result
[ 0  0  0|-2  0  0  0  0  0  0  0]
[ 0  0  0| 0 -1  0  0  0  0  0  0]
[ 0  0  0| 0  0  0  0  0  0  0  0]
[ 0  0  0| 0  0  0  1  0  0  0  0]
[ 0  0  0| 0  0  0  0  2  0  0  0]
[ 0  0  0| 0  0  0  0  0  3  0  0]
[ 0  0  0| 0  0  0  0  0  0  4  0]
[ 0  0  0| 0  0  0  0  0  0  0  5]
[--------+-----------------------]
[ 0  0  0| 0  0  0  0  0  0  0  0]
[ 0  0  0| 0  0  0  0  0  0  0  0]
[ 0  0  0| 0  0  0  0  0  0  0  0]
sage: v = range(-2,6) # a list, arbitrarily given 
sage: m = 3 # the off-diagonal index
sage: T = block_matrix([[zero_matrix(len(v),off), block_matrix([[zero_matrix(len(v),m), diagonal_matrix(v)],
                        [zero_matrix(m,m),0]])     
sage: # len(v), get the length of the list to determine the dimensional of T
sage: T # result
[ 0  0  0|-2  0  0  0  0  0  0  0]
[ 0  0  0| 0 -1  0  0  0  0  0  0]
[ 0  0  0| 0  0  0  0  0  0  0  0]
[ 0  0  0| 0  0  0  1  0  0  0  0]
[ 0  0  0| 0  0  0  0  2  0  0  0]
[ 0  0  0| 0  0  0  0  0  3  0  0]
[ 0  0  0| 0  0  0  0  0  0  4  0]
[ 0  0  0| 0  0  0  0  0  0  0  5]
[--------+-----------------------]
[ 0  0  0| 0  0  0  0  0  0  0  0]
[ 0  0  0| 0  0  0  0  0  0  0  0]
[ 0  0  0| 0  0  0  0  0  0  0  0]

This is inspired by @Luca 's answer.