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

Home » Public Forums » archive » Re: For loops vs. matrix operations
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: For loops vs. matrix operations [message #37433 is a reply to message #37427] Wed, 17 December 2003 23:25 Go to previous messageGo to previous message
marc schellens[1] is currently offline  marc schellens[1]
Messages: 183
Registered: January 2000
Senior Member
Marshall Perrin wrote:
> Jonathan Greenberg <greenberg@ucdavis.edu> wrote:
>
>> I know some matrix programs perform better if you do straigh matrix math vs.
>> a for-next loop -- is idl this way? E.g. is:
>>
>> array=intarr(10000)
>> for i=0,(10000-1) do begin
>> array[i]=array[i]+1
>> endfor
>>
>> MUCH slower than:
>>
>> array=intarr(10000)
>> array=array+1
>>
>> ?
>
>
> Yes, the for loop version will be *vastly* slower. This is because IDL
> makes a seperate trip through the parse/interpret cycle for every pass
> through the for loop, greatly increasing the overhead.

Interpret cycle only. Parsing is only done once.


>> I'm trying to figure out how much time I should be using rewriting some code
>> to optimize the algorithm, which is why I'm asking (the code is more complex
>> than above, obviously, but I did notice I could "matricize" some of the code
>> in places)...
>
>
> Matricize as much as you possibly can!

True always and anyway.

marc
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: always widget!
Next Topic: Re: How to make IDL be quiet

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

Current Time: Wed Oct 08 15:21:39 PDT 2025

Total time taken to generate the page: 0.00645 seconds