0

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!

1 Answer 1

1

Ok, I think that I solved it:

C = A[:, B]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.