|
efficient summation: msg#00003python.numeric.general
I am trying to effieciently sum over a subset of the elements of a matrix. In Matlab, this could be done like: a=[1,2,3,4,5,6,7,8,9,10] b = [1,0,0,0,0,0,0,0,0,1] res=sum(a(b)) %this sums the elements of a which have corresponding elements in b that are true Is there anything similar in numarray (or numeric)? I thought masked arrays looked promising, but I find that masking 90% of the elements results in marginal speedups (~5%, instead of 90%) over the unmasked array. Thanks! Darren ------------------------------------------------------- This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools! Get your free copy of BEA WebLogic Workshop 8.1 today. http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: sum of a masked array: 00003, Darren Dale |
|---|---|
| Next by Date: | Re: efficient summation: 00003, Stephen Walton |
| Previous by Thread: | sum of a masked arrayi: 00003, Darren Dale |
| Next by Thread: | Re: efficient summation: 00003, Stephen Walton |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |