Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Slice indexing works for both dense and sparse matrices :

sage: M=matrix(SR, 5, sparse=True) ; M[2, 1]=3 ; M[3,2]=5 ; M
[0 0 0 0 0]
[0 0 0 0 0]
[0 3 0 0 0]
[0 0 5 0 0]
[0 0 0 0 0]
sage: M[2:5, 1:4]
[3 0 0]
[0 5 0]
[0 0 0]

HTH,