[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

*Subject*: Re: Convolution of Stick Spectra*From*: mole6e23(at)hotmail.com (Todd Clements)*Date*: Thu, 14 Sep 2000 09:22:50 -0700*Newsgroups*: comp.lang.idl-pvwave*Organization*: UCSD*References*: <tclement-0909001528490001@checont6.ucsd.edu> <39BAD985.47F881B9@phys.ucalgary.ca>*Xref*: news.doit.wisc.edu comp.lang.idl-pvwave:21397

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

**References**:**Convolution of Stick Spectra***From:*Todd Clements

**Re: Convolution of Stick Spectra***From:*bjackel

- Prev by Date:
**Re: multiple delimiters** - Next by Date:
**Re: Vectorization question** - Prev by thread:
**Re: Convolution of Stick Spectra** - Next by thread:
**Re: Convolution of Stick Spectra** - Index(es):