I have the following array:
>>> x = numpy.array([2,4,2,3,1])
>>> x
array([2, 4, 2, 3, 1])
I would like an array of ranges of these values. I can create it like this:
>>> numpy.hstack( (numpy.arange(v) for v in x) )
array([0, 1, 0, 1, 2, 3, 0, 1, 0, 1, 2, 0])
Given x, is there a faster way to generate this with numpy without having to use a for loop?
xabove. I needed the output range set to triangulate the polygons quickly in a single array.