comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Multi-dimensions without for loop ?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Multi-dimensions without for loop ? [message #38762 is a reply to message #38739] Thu, 25 March 2004 06:22 Go to previous messageGo to previous message
Andrea Pitacco is currently offline  Andrea Pitacco
Messages: 3
Registered: March 2004
Junior Member
On Thu, 25 Mar 2004 11:47:31 +0100, Emmanuel Christophe
<melaneum555@yahoo.fr> wrote:

> 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.

Hi Emmanuel,
I have not understood clearly if you like to have the column mean
being removed from the data column, or the row (line?) mean removed
from the data row. 'Seems more likely the first. Anyway:

In the first case you may want to try:

datac = data - Total(data,2) / (Size(data))[2] #
Replicate(1D,(Size(data))[2])

In the second:

datac = data - Total(data,1) / (Size(data))[1] ##
Replicate(1D,(Size(data))[1])

Regards, Andrea


Andrea Pitacco
University of Padova, Italy
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: not only google
Next Topic: Image structure

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Nov 29 18:22:33 PST 2025

Total time taken to generate the page: 0.07900 seconds