I have a matrix A of size 256 X 16, and a second matrix B of size 8 X 8, where every element of B is an integer in the range [0, 15]. If A was just a row vector (i.e. of size 1X16) then C = A[B] would output an 8X8 matrix where Cij = A[bij]. Is there any efficient way I could do the same if A is 256X16 using numpy (or anything else)? I mean that I want an output matrix C of size 256 X 8 X 8 (i.e., B is indexing every row of A).
Thanks!
Add a comment
|