Multi-dimensions without for loop ? [message #38766] |
Thu, 25 March 2004 02:47 |
Emmanuel Christophe
Messages: 11 Registered: March 2004
|
Junior Member |
|
|
Hi,
I'm trying to optimize some IDL code, removing for loops.
I'm using the mean function to get the average of each line (this is for
the example, could be another function). From a 2 dimensional array, I
want to remove the mean of each column.
Here is a sample using a loop:
--------------------------------
for j=0,size-1 do begin
vect=data[j,*]
datac[j,*]=vect-mean(vect)
endfor
--------------------------------
How to do it in one instruction: if i'm using something like
'mean(data)', i'll get the average for the whole array, and not line by
line.
the instruction 'total' give me something similar to what I want:
'total(data,1)' will make the sum in only one direction.
How to get that with ordinary function ? and is it possible ? I'm
thinking of something like 'data[0:size-1,*]'...
Thanks,
Emmanuel
|
|
|