[SciPy-User] Operations with matrices

Ramon Crehuet rcsqtc at iqac.csic.es
Wed Jan 19 05:50:37 EST 2011


Dear scipy users,
I would like to know if I can avoid the following double loop somehow, because I 
need to perform this operations may times and with relatively large matrices.
I have a two-dimensional array r whose elements I have to add (to calculate an 
histogram) into a vector c. And the index of c where an element r[i,j] goes is 
in an array d, so that:
c = zeros(n)
for (i,j) in d:
     k = d[i,j]
     c[k] += r[i,j]

Is there a way to avoid this loop?
Thanks for your attention.
Ramon




More information about the SciPy-User mailing list