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

Home » Public Forums » archive » Re: x*x versus x^2
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: x*x versus x^2 [message #61201 is a reply to message #61200] Wed, 09 July 2008 09:55 Go to previous messageGo to previous message
pgrigis is currently offline  pgrigis
Messages: 436
Registered: September 2007
Senior Member
Probably this happens because you raise to a floating point
exponent, and likely IDL computes an exponential function,
which is slower.
If you try x^2 (not x^2.0) it is possible that the compiler
optimizes it to x*x.

Ciao,
Paolo

Conor wrote:
> So I've been looking at execution time for various algorithms, and I
> found this interesting result:
>
> bigarr = fltarr(1000,1000)
>
> t1 = systime(/seconds)
> t = bigarr^2.0
> t2 = systime(/seconds)
> t = bigarr*bigarr
> t3 = systime(/seconds)
>
> print,t2-t1
> print,t3-t2
>
>
> IDL prints:
>
> 0.024163008
> 0.010262012
>
> Apparently multiplying an array by itself is twice as fast as using
> the carat operator! Anyone know why this is? Is it a memory issue or
> something?
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: newbie wants to call IDL from shell
Next Topic: Re: IDL Adventure!?

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

Current Time: Sat Oct 11 06:15:26 PDT 2025

Total time taken to generate the page: 0.40015 seconds