[Numpy-discussion] Re: mixed mode arithmetic

2023-07-11 Thread Robert Kern
On Tue, Jul 11, 2023 at 10:11 AM Matti Picus wrote: > > On 10/7/23 16:13, Jens Glaser via NumPy-Discussion wrote: > > Hi Matti, > > > > The documentation for numpy.dot currently states > > > > """ > > out > > ndarray, optional > > Output argument. This must have the exact kind that would be retur

[Numpy-discussion] Re: mixed mode arithmetic

2023-07-11 Thread Matti Picus
On 10/7/23 16:13, Jens Glaser via NumPy-Discussion wrote: Hi Matti, The documentation for numpy.dot currently states """ out ndarray, optional Output argument. This must have the exact kind that would be returned if it was not used. In particular, it must have the right type, must be C-conti

[Numpy-discussion] Re: mixed mode arithmetic

2023-07-11 Thread Jens Glaser via NumPy-Discussion
Hi Matti, The documentation for numpy.dot currently states """ out ndarray, optional Output argument. This must have the exact kind that would be returned if it was not used. In particular, it must have the right type, must be C-contiguous, and its dtype must be the dtype that would be returned

[Numpy-discussion] Re: mixed mode arithmetic

2023-07-10 Thread Robert Kern
On Mon, Jul 10, 2023 at 1:49 AM Matti Picus wrote: > On 9/7/23 23:34, glaserj--- via NumPy-Discussion wrote: > > > Reviving this old thread - I note that numpy.dot supports in-place > > computation for performance reasons like this > > c = np.empty_like(a, order='C') > > np.dot(a, b, out=c) > > >

[Numpy-discussion] Re: mixed mode arithmetic

2023-07-09 Thread Matti Picus
On 9/7/23 23:34, glaserj--- via NumPy-Discussion wrote: Reviving this old thread - I note that numpy.dot supports in-place computation for performance reasons like this c = np.empty_like(a, order='C') np.dot(a, b, out=c) However, the data type of the pre-allocated c array must match the result

[Numpy-discussion] Re: mixed mode arithmetic

2023-07-09 Thread glaserj--- via NumPy-Discussion
Neal Becker wrote: > I've been browsing the numpy source. I'm wondering about mixed-mode > arithmetic on arrays. I believe the way numpy handles this is that it > never does mixed arithmetic, but instead converts arrays to a common type. > Arguably, that might be efficient for a mix of say, doub