From: Rob H. <ro...@ho...> - 2006-06-02 05:31:43
|
Christopher Barker wrote: > x = N.arange(minx, maxx+Spacing, Spacing) # makeing sure to get the last > point > y = N.arange(miny, maxy+Spacing, Spacing) # an extra is OK > points = N.zeros((len(y), len(x), 2), N.Float) > x.shape = (1,-1) > y.shape = (-1,1) > points[:,:,0] += x > points[:,:,1] += y > points.shape = (-1,2) > > print points How about something like: >>> k=Numeric.repeat(range(0,5+1),Numeric.ones(6)*7) >>> l=Numeric.resize(range(0,6+1),[42]) >>> zone=Numeric.concatenate((k[:,Numeric.NewAxis],l[:,Numeric.NewAxis]),axis=1) >>> zone array([[0, 0], [0, 1], [0, 2], ... [5, 4], [5, 5], [5, 6]]) This is the same speed as Robert Kern's solution for large arrays, a bit slower for small arrays. Both are a little faster than yours. Rob -- Rob W.W. Hooft || ro...@ho... || http://www.hooft.net/people/rob/ |