splinepy.utils.data.cartesian_product#

splinepy.utils.data.cartesian_product(arrays, reverse=True)[source]#

Fast Cartesian product. Adapted from stackoverflow entry: https://stackoverflow.com/questions/11144513/ cartesian-product-of-x-and-y-array-points-into-single-array-of-2d-points/ 49445693#49445693 Answer from Paul Panzer.

In splinepy, we use the ordering, where lowest dimension changes fastest. Thus, a reverse option.

Parameters:
  • arrays (tuple or list) – tuple or list of array-like

  • reverse (bool) – Default is True. Reverses order of fastest iterating dimension. If False, highest indexed dimension iterates fastest.

Returns:

cartesian

Return type:

(n, len(arrays)) np.ndarray