Re: [Numpy-discussion] Is there a way that indexing a matrix of data with a matrix of indices?

2017-11-29 Thread Sebastian Berg
On Wed, 2017-11-29 at 14:56 +, ZHUO QL (KDr2) wrote: > Hi, all > > suppose: > > - D, is the data matrix, its shape is  M x N > - I, is the indices matrix, its shape is M x K,  K<=N > > Is there a efficient way to get a Matrix R with the same shape of I > so that R[x,y] = D[x, I[x,y]] ? > >

Re: [Numpy-discussion] Is there a way that indexing a matrix of data with a matrix of indices?

2017-11-29 Thread Eric Hermes
)[:, np.newaxis] * N R = D.ravel()[I.ravel()].reshape((M, K)) Eric > > ZHUO QL (KDr2) http://kdr2.com > -- next part -- > An HTML attachment was scrubbed... > URL: <http://mail.python.org/pipermail/numpy- > discussion/attachments/20171129/baead