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

Home » Public Forums » archive » How to increase the speed
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: How to increase the speed [message #85790 is a reply to message #85789] Mon, 09 September 2013 03:44 Go to previous messageGo to previous message
Moritz Fischer is currently offline  Moritz Fischer
Messages: 32
Registered: June 2013
Member
Hi!

Try the '#' operator (and some algebra to remove the multiplication):

result = exp( a#replicate(1d,2e5) - replicate(1d,250)#(b-c) )

You could use reform/rebin with the SAMPLE keyword to do somthing similar.


Am 09.09.2013 12:11, schrieb sivan:
> Hello everyone,
>
> I'll directly tell you the problem. I have three arrays, one of them
> contains hundreds of elements, the others have the same number of
> elements and contain much more.
>
> Let say (a is the first, b is the 2nd, and c is the 3rd array)
> a=findgen(250)+1 b=randomn(seed, 2e5) c=randomn(seed, 2e5)
>
> What I want to do is to calculate the following equation for each
> element of a and every element of b and c without using the for
> loop.
>
> exp(a(i) - b)*exp(c)
>
> The result should be a two dimensional array (array[250, 2e5]).
>
> Problem is also shown via this picture
> (http://oi42.tinypic.com/10zcx7p.jpg).
>
> I use the following code but it is very slow.
>
> result=dblarr(250, 2e5) for i=0, 249 do result(i,*)=exp(a(i) -
> b)*exp(c)
>
> Thanks in advice, Sivan.
>
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: How to re-use object methods
Next Topic: CONV_DOIT

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

Current Time: Wed Oct 08 19:59:25 PDT 2025

Total time taken to generate the page: 0.00375 seconds