matrix multiplication

Ian Kelly ian.g.kelly at gmail.com
Tue Feb 27 12:47:15 EST 2018


On Tue, Feb 27, 2018 at 9:02 AM, Seb <spluque at gmail.com> wrote:
> That's right.  I just tried this manipulation by replacing the last
> block of code in my example, from the line above `for` loop with:
>
> ---<--------------------cut here---------------start------------------->---
> # Alternative using `np.matmul`
> uvw_alt = uvw.reshape((uvw.shape[0], 1, uvw.shape[1]))
> bmats = np.asarray(map(randint_mat, maxint))
> uvw_rots_alt = np.matmul(uvw_alt, bmats).squeeze()
> ---<--------------------cut here---------------end--------------------->---
>
> Interestingly, the time savings from IPython are not spectacular:

The second line is still calling the Python function randint_mat 1000
times. That should be possible to do without the Python function using
broadcasting, if https://github.com/numpy/numpy/issues/6745 were
fixed. Otherwise, I don't know of a way to vectorize that part
efficiently.



More information about the Python-list mailing list