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
How to increase the speed [message #85789] Mon, 09 September 2013 03:11 Go to previous message
sivan is currently offline  sivan
Messages: 13
Registered: August 2012
Junior Member
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 15:33:25 PDT 2025

Total time taken to generate the page: 0.00390 seconds