On Wed, 2022-12-21 at 14:58 +0100, Thibaut Lunet wrote:
> Hi everyone,
> 
> I want to vectorize multiple matrix-vector products and avoid a for 
> loop, a little bit like np.linalg.solve does, for instance :
> 

<snip>

>  
> dimension > 2.
> 
> Since np.linalg.solve does this vectorization naturally, I wonder if 
> there is a way to get the same behavior with matrix-vector 
> multiplication already in numpy, and why np.matmul does not behave
> like 
> np.linalg.solve does ?


All of these functions need some convention to deal with ambiguity of
matrix vs. stack of vector.  Since we don't indicate it on the array
itself, both matmul and the `@` operator assume matrix inputs unless
given a vector.

There have been thoughts of having a pair of `vecmat` and `matvec` 
functions to make working with stacked vectors more convenient.  I
don't think anyone ever pushed for it very strongly.
There is maybe a bit more of a push for `vecdot` (both vectors) right
now, but you want the mixed case...

- Sebastian



> 
> Best,
> 
> Thibaut
> 
> _______________________________________________
> NumPy-Discussion mailing list -- numpy-discussion@python.org
> To unsubscribe send an email to numpy-discussion-le...@python.org
> https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
> Member address: sebast...@sipsolutions.net


_______________________________________________
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com

Reply via email to