I’m looking for a quick and easy method to do the below four things

Replace P rows of an M*N matrix with a P*N matrix

Replace P columns of an M*N matrix with a M*P matrix

Retrieve P rows from an M*N matrix into a P*N matrix

Retrieve P columns from an M*N matrix into a M*P matrix

All the above apply to dense column major matrices - and assume that I have an idx vector to extract/replace the rows/columns like below

idx=[0,3,5,7,8,9,10,16,16,17]

So to rephrase, I’m looking for an easy to code and quick to run method to

M.getcols(idx) creates a matrix M*10 containing the 0th,3rd,5th…17th columns
M.setrows(idx) Puts the rows of the 10*N matrix into the 0th,3rd,5th,…17th rows of M

Thanks!