суб -матрица Python

'''
A matrix is a list containing lists, to form a 2 dimensonal data table.
A submatrix is a matrix made of selected values of a larger matrix.

To extract a submatrix, we'll use the following example
'''
Y = np.arange(16).reshape(4,4)
'''
Y is
[[ 0  1  2  3]
 [ 4  5  6  7]
 [ 8  9 10 11]
 [12 13 14 15]]
 
 We want to extract columns/rows 0 and 3, resulting in
 [[0 3]
 [12 15]]
 '''
 Y[np.ix_([0,3],[0,3])]
 
 '''
 this outputs 
 array([[ 0,  3],
       [12, 15]])
 
 According to the numpy database, "Using ix_ one can quickly construct index arrays
 that will index the cross product. a[np.ix_([1,3],[2,5])] returns the array
 [[a[1,2] a[1,5]], [a[3,2] a[3,5]]]."
 
 '''
Vihaking