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

Home » Public Forums » archive » Re: Convolution of Stick Spectra
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: Convolution of Stick Spectra [message #21768 is a reply to message #21721] Thu, 14 September 2000 00:00 Go to previous message
mole6e23 is currently offline  mole6e23
Messages: 31
Registered: December 1998
Member
bjackel@phys.ucalgary.ca wrote:

> It helps a bit to pre-calculate your variance term.
> Cuts execution time from 27 to 18 seconds on my PC.
>
> variance_term= ( ( (.12*sqrt(energy/1000))/1.6651)*1000)^2
> FOR indx=0L,nstick-1 DO BEGIN
> result = result + intensity[indx]* $
> exp(-((energy_scale - energy[indx])^2)/
> variance_term[indx] )
> ENDFOR
>

Actually, I was surprised to find that didn't change the timing any on my
sytem (alpha OSF unix 5.3 Nov 11 1999) to any appreciable degree. With the
code I first posted (attached below as a procedure), it took about 10.5
seconds either way.

IDL> test
time other: 10.706325
time precalc: 10.545039

Jumping up to 20,000 elements, the timing was still pretty much identical
(42.9 vs. 42.7 seconds).

Todd

----

pro test
convoluted = fltarr( 2, 2048 )
convoluted[0,*] = findgen( 2048 ) / 2047. * 4.

;; Let's fake a stick spectrum, we usually have at least this many elements
stick = abs(randomn( systime(1), 2, 5000 ))
stick[0,*] = stick[0,*] * 4.
stick[1,*] = stick[1,*] * 1000.

time = systime(1)

variance = (((.12*sqrt(stick[0,*]/1000))/1.6651)*1000)^2
for i=0L, n_elements( stick ) / 2 -1 do $
convoluted[1,*] = stick[1,i]*exp(-((convoluted[0,*] - stick[0,i])^2)/ $
variance[i]) $
+ convoluted[1,*]

time2 = systime(1)

for i=0L, n_elements( stick ) / 2 -1 do $
convoluted[1,*] = stick[1,i]*exp(-((convoluted[0,*] - stick[0,i])^2)/ $
(((.12*sqrt(stick[0,i]/1000))/1.6651)*1000)^2) $
+ convoluted[1,*]

print, 'time other: ', systime(1) - time2
print, 'time precalc: ', time2 - time

end
[Message index]
 
Read Message
Read Message
Previous Topic: Odd string/index problem
Next Topic: flow charts and IDL

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

Current Time: Thu Oct 09 20:37:01 PDT 2025

Total time taken to generate the page: 3.76156 seconds