quickly totaling sections of an array [message #52558] |
Tue, 13 February 2007 07:05 |
Conor
Messages: 138 Registered: February 2007
|
Senior Member |
|
|
Hey Everyone,
I'm essentially trying to add together separate sections of an
array, and I need to do it in a very speedy fashion. Here's the
breakdown in IDL. I would want to take an array like this:
vals = [10, 15, 13, 12, 11, 14]
and imagine I have a mask (which I can easily make) like this:
mask = [ 0, 0, 0, 1, 1, 1 ]
I would then want to add together everything with the same mask value
and put it in a new array. So the result would be:
sums = [38, 37]
I'm generating images, and for each image I generate this will be done
1000 times, and there will be 1000 different mask values each time it
is done. I'll be generating a couple hundred images, so I'll be
running this task a couple hundred thounsand times - i.e. execution
speed is very important. Any suggestions on how to speed things up
would be highly appreciated.
Thanks in advanced,
Conor
|
|
|