Hi Paul 2009/2/10 Paul Rudin <[email protected]>: > > I've just written this snippet of code: > > result = numpy.empty((dim, dim, dim), numpy.bool) > for x in xrange(dim): > for y in xrange(dim): > for z in xrange(dim): > result[x, y, z] = ((xnear[y, z] < xfar[y, z]) and > (ynear[x, z] < yfar[x, z]) and > (znear[x, y] < zfar[x, y])) > > > Is there a way to get numpy to do the looping?
You can try the following: x = np.arange(dim) y = np.arange(dim) z = np.arange(dim) result = (xnear[y,z] < xfar[y, z]) & (ynear[x, z] < yfar[x, z]) & (znear[x,y] < zfar[x,y]) It broadcasts correctly, but you'll have to verify the results to be sure. Cheers Stéfan _______________________________________________ Numpy-discussion mailing list [email protected] http://projects.scipy.org/mailman/listinfo/numpy-discussion
