[Numpy-discussion] Vectorized version of numpy.linspace

Lars Grüter lagru at mailbox.org
Wed Nov 14 13:20:33 EST 2018

On 14.11.18 17:57, Stephan Hoyer wrote:
> It recently came up on GitHub (at part of the discussion
> in https://github.com/numpy/numpy/issues/12379) that numpy.linspace
> could, at least in principle, be modified to support array inputs:
> It looks like this has been requested on StackOverflow, too:
> https://stackoverflow.com/questions/46694167/vectorized-numpy-linspace-across-multi-dimensional-arrays
> My tentative proposal:
> - "start" and "stop" are broadcast against each other to form start/stop
> arrays. (Or we could require that start/stop have matching shape.)
> - A new dimension of size "num" is inserted into the result, either
> along the first or last axis.
> - A new keyword argument "axis" could control where the axis is inserted
> in the result.
> - Vectorization support should be added in the same way to geomspace and
> logspace.

This reminds me of a function [1] I wrote which I think has a lot of
similarities to what Stephan describes here. It is currently part of a
PR to rewrite numpy.pad [2].

Maybe that's helpful to know depending on how this discussion resolves. :)

Best regards,

[2] https://github.com/numpy/numpy/pull/11358

More information about the NumPy-Discussion mailing list