[Numpy-discussion] matrix indexing

Naresh Pai npai@uark....
Mon Feb 6 11:44:23 CST 2012


I have two large matrices, say, ABC and DEF, each with a shape of 7000 by
4500. I have another list, say, elem, containing 850 values from ABC. I am
interested in finding out the corresponding values in DEF where ABC has
elem and store them *separately*. The code that I am using is:

for i in range(len(elem)):
     DEF_distr = DEF[ABC==elem[i]]

DEF_distr gets used for further processing before it gets cleared from
memory and the next round of the above loop begins. The loop above
currently takes about 20 minutes! I think the bottle neck is where elem is
getting searched repeatedly in ABC. So I am looking for a solution where
all elem can get processed in a single call and the indices of ABC be
stored in another variable (separately). I would appreciate if you suggest
any faster method for getting DEF_distr.

Thanks,
Naresh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20120206/f04691ad/attachment.html 


More information about the NumPy-Discussion mailing list