On Mon, Feb 26, 2018 at 9:53 AM, Seb <splu...@gmail.com> wrote:
> On Sun, 25 Feb 2018 18:52:14 -0500,
> Terry Reedy <tjre...@udel.edu> wrote:
>
> [...]
>
>> numpy has a matrix multiply function and now the '@' matrix multiply
>> operator.
>
> Yes, but what I was wondering is whether there's a faster way of
> multiplying each row (1x3) of a matrix by another matrix (3x3), compared
> to looping through the matrix row by row as shown in the code.  Perhaps
> I'm not understanding how to use the broadcasting features of `matmul`.

>From the matmul documentation:

"If either argument is N-D, N > 2, it is treated as a stack of
matrices residing in the last two indexes and broadcast accordingly."

So you probably want your uvw array to be 1000x1x3 instead of 1000x3.
Then the result of multiplying them should be 1000 1x3 matrices.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to