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

Home » Public Forums » archive » Re: another request for help with getting rid of for loops...
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: another request for help with getting rid of for loops... [message #49763 is a reply to message #49762] Tue, 15 August 2006 07:10 Go to previous message
Benjamin Hornberger is currently offline  Benjamin Hornberger
Messages: 258
Registered: March 2004
Senior Member
davede10@gmail.com wrote:
> Hi everyone,
> i read alot about eliminating for loops in idl , and yet i can't get
> rid of this simple loop .
> here is what i'm trying to do (multiply each plane in a data cube by a
> number):
> any idea?
>
> A=fltarr(100,100,10) ;my data cube
> A(*,*,*)=1.
> b=findgen(10) ;just a culumn of numbers
> c=a
> for i=0.9 do c(*,*,i)=A(*,*,i)*B(i)
>
> thanks,
> david
>

Here is the solution:

http://www.dfanning.com/tips/rebin_magic.html

Keep in mind, however, that once the arrays reach a certain size, your
computer might not be able to allocate the memory for the intermediate
"blown-up" array any more and the loop is suddenly orders of magnitude
faster than the pure array operation.

And as a side note, you should better use [] instead of () for array
subscripting. Check the IDL help index for "subscripts" -> "syntax".

Good luck,
Benjamin
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: functions to access ETOPO2 or other bathymetric data sets?
Next Topic: Can these nested loops be made to run faster?

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

Current Time: Wed Oct 08 17:32:02 PDT 2025

Total time taken to generate the page: 0.01074 seconds