sparse_meshgrid

odl.discr.grid.sparse_meshgrid(\*x)[source]

Make a sparse meshgrid by adding empty dimensions.

Parameters
x1,…,xNarray-like

Input arrays to turn into sparse meshgrid vectors.

Returns
meshgridtuple of numpy.ndarray’s

Sparse coordinate vectors representing an N-dimensional grid.

See also

numpy.meshgrid

dense or sparse meshgrids

Examples

>>> x, y = [0, 1], [2, 3, 4]
>>> mesh = sparse_meshgrid(x, y)
>>> sum(xi for xi in mesh).ravel()  # first axis slowest
array([2, 3, 4, 3, 4, 5])