I have a matrix A, and a list of indices, say l = [0,3,4,5]
. Is there an easy way to access the 4x4 submatrix of A corresponding to those rows and columns, i.e. A[l,l]
? A[l,:]
accesses all columns for the rows in l, A[l,1:4]
access the rows in l
and first four columns of A
, but I cannot find a way to access the l
column and row indices in this fashion.
The purpose is I want to define a new matrix as, e.g., G = np.eye(4) - A[l,l]
or a new vector v = A[l,l]*c
for some 4x1 vector c
without moving / copying the data stored in A.