[Numpy-discussion] Create a n-D grid; meshgrid alternative

Stefan Otte stefan.otte at gmail.com
Tue May 12 04:17:12 EDT 2015


Hello,

indeed I was looking for the cartesian product.

I timed the two stackoverflow answers and the winner is not quite as clear:

n_elements:    10  cartesian  0.00427 cartesian2  0.00172
n_elements:   100  cartesian  0.02758 cartesian2  0.01044
n_elements:  1000  cartesian  0.97628 cartesian2  1.12145
n_elements:  5000  cartesian 17.14133 cartesian2 31.12241

(This is for two arrays as parameters: np.linspace(0, 1, n_elements))
cartesian2 seems to be slower for bigger.

I'd really appreciate if this was be part of numpy. Should I create a pull
request?

Regarding combinations and permutations: I could be convenient to have as
well.


Cheers,
 Stefan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20150512/7f23bcb8/attachment.html>


More information about the NumPy-Discussion mailing list