On Thu, May 22, 2008 at 2:16 PM, Andrea Gavana <[EMAIL PROTECTED]> wrote:
> By the way, about the solution Francesc posted:
>
> xyzReq = (xCent >= xMin) & (xCent <= xMax) &  \
>            (yCent >= yMin) & (yCent <= yMax) &  \
>            (zCent >= zMin) & (zCent <= zMax)
>

You could implement this with inplace operations to save memory:
xyzReq = (xCent >= xMin)
xyzReq &= (xCent <= xMax)
xyzReq &= (yCent >= yMin)
xyzReq &= (yCent <= yMax)
xyzReq &= (zCent >= zMin)
xyzReq &= (zCent <= zMax)


> Do you think is there any chance that a C extension (or something
> similar) could be faster? Or something else using weave? I understand
> that this solution is already highly optimized as it uses the power of
> numpy with the logic operations in Python, but I was wondering if I
> can make it any faster

A C implementation would certainly be faster, perhaps 5x faster, due
to short-circuiting the AND operations and the fact that you'd only
pass over the data once.

OTOH I'd be very surprised if this is the slowest part of your application.

-- 
Nathan Bell [EMAIL PROTECTED]
http://graphics.cs.uiuc.edu/~wnbell/
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to