Suppose I have a matrix composed of a list of lists like so:
>>> LoL=[list(range(10)) for i in range(10)] >>> LoL [[0, 1, 2, 3, 4, 5, 6, 7,
Do this,
submat = [ [ mat[ i ][ j ] for j in range( index1, index2 ) ] for i in range( index3, index4 ) ]
the submat will be the rectangular (square if index3 == index1 and index2 == index4) chunk of your original big matrix.