[Numpy-discussion] Faster than ndindex?
Eleftherios Garyfallidis
garyfallidis@gmail....
Sat Dec 4 13:00:43 CST 2010
Hi guys,
I would like to know if there is any way to make the following operation
faster.
def test():
shape=(200,200,200,3)
refinds = np.ndindex(shape[:3])
reftmp=np.zeros(shape)
for ijk_t in refinds:
i,j,k = ijk_t
reftmp[i,j,k,0]=i
reftmp[i,j,k,1]=j
reftmp[i,j,k,2]=k
%timeit test()
1 loops, best of 3: 19.5 s per loop
I am using ndindex and then a for loop. Is there a better/faster way?
Thank you,
Eleftherios
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20101204/c29cdbb4/attachment.html
More information about the NumPy-Discussion
mailing list