[Numpy-discussion] Re: Feature request: dot product along arbitrary axes

2022-07-05 Thread Aaron Meurer
On Tue, Jul 5, 2022 at 9:10 PM wrote: > > Oh nevermind, I see that this is added as an experimental module in the > latest numpy version. It would be nice to not have to have another whole set > of APIs, but on the other hand the numpy API is so messy and inconsistent > that maybe it is a good

[Numpy-discussion] Re: Feature request: dot product along arbitrary axes

2022-07-05 Thread rmccampbell7
Oh nevermind, I see that this is added as an experimental module in the latest numpy version. It would be nice to not have to have another whole set of APIs, but on the other hand the numpy API is so messy and inconsistent that maybe it is a good thing :) But it does mean now we have at least 9

[Numpy-discussion] Re: Feature request: dot product along arbitrary axes

2022-07-05 Thread rmccampbell7
Yes, if I am doing this more than once in some code I would make a helper. But it's much better I think to have a common function that people can learn and use consistently instead of having to roll their own functions all the time. Especially because numpy otherwise usually just works when you

[Numpy-discussion] Re: Feature request: dot product along arbitrary axes

2022-07-05 Thread rmccampbell7
I'm unaware of the context here, is this a specification for functions that it is hoped will eventually be made consistent across numpy/tensorflow/etc? If that's the idea then yeah, I'm all for it, but I would suggest also adding a keepdim parameter (as I mentioned above it helps with broadcasti

[Numpy-discussion] Re: Feature request: dot product along arbitrary axes

2022-07-05 Thread Sebastian Berg
On Tue, 2022-07-05 at 23:36 +, rmccampbe...@gmail.com wrote: > Maybe I wasn't clear, I'm talking about the 1-dimensional vector > product, but applied to N-D arrays of vectors. Certainly dot products > can be realized as matrix products, and often are in mathematics for > convenience, but matri

[Numpy-discussion] Re: Feature request: dot product along arbitrary axes

2022-07-05 Thread Ilhan Polat
It might be just me, that @ product is way more readable than chaining different operators below that I don't find readable at all but anyways that's taste I guess. Also if you are going to do this, for a better performance code, you shouldn't bend the ops but you should wrangle the array to the co

[Numpy-discussion] Re: Feature request: dot product along arbitrary axes

2022-07-05 Thread Aaron Meurer
The vecdot() function in the array API should be what you are looking for (note that the current implementation in numpy.array_api is incorrect, which I'm fixing at https://github.com/numpy/numpy/pull/21928). It works like dot() but it always applies the 1-D dot product case with broadcasting, and

[Numpy-discussion] Re: Feature request: dot product along arbitrary axes

2022-07-05 Thread Aaron Meurer
On Tue, Jul 5, 2022 at 5:49 PM Aaron Meurer wrote: > > The vecdot() function in the array API should be what you are looking > for (note that the current implementation in numpy.array_api is > incorrect, which I'm fixing at > https://github.com/numpy/numpy/pull/21928). It works like dot() but it >

[Numpy-discussion] Re: Feature request: dot product along arbitrary axes

2022-07-05 Thread rmccampbell7
Maybe I wasn't clear, I'm talking about the 1-dimensional vector product, but applied to N-D arrays of vectors. Certainly dot products can be realized as matrix products, and often are in mathematics for convenience, but matrices and vectors are not the same thing, theoretically or coding wise.