Re: [Numpy-discussion] Advice please on efficient subtotal function
![](https://secure.gravatar.com/avatar/54e8a8bca3caf1651ed048e9346dbecd.jpg?s=120&d=mm&r=g)
Dec. 30, 2006
2:45 p.m.
Hi Stephen,
It looks as if the values in your i and j columns come from a limited range, so you may consider encoding pairs of (i,j) values into one int using a suitable encoding function (e.g. ij = i+K*j if both i and j are non-negative and K=max(i)+1). You could then use bincount(ij, data) to get the sums per encoded (i,j) pair. This should be efficient, and the complexity is only in the encoding/decoding steps. Best regards, Andreas ---- Dr. Andreas Eisele Senior Researcher DFKI GmbH, Language Technology Lab eisele@dfki.de Stuhlsatzenhausweg 3 tel: +49-681-302-5285 D-66123 Saarbrücken fax: +49-681-302-5338
6623
Age (days ago)
6623
Last active (days ago)
0 comments
1 participants
participants (1)
-
Andreas Eisele