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

*Subject*: Re: Convolution of Stick Spectra*From*: Craig Markwardt <craigmnet(at)cow.physics.wisc.edu>*Date*: 17 Sep 2000 18:32:31 -0500*Newsgroups*: comp.lang.idl-pvwave*Organization*: U. Wisc. Madison Physics -- Compact Objects*References*: <tclement-0909001528490001@checont6.ucsd.edu> <onlmwr6o0i.fsf@cow.physics.wisc.edu> <mole6e23-1709001502510001@checont6.ucsd.edu>*Reply-To*: craigmnet(at)cow.physics.wisc.edu*Xref*: news.doit.wisc.edu comp.lang.idl-pvwave:21428

mole6e23@hotmail.com (Todd Clements) writes: > craigmnet@cow.physics.wisc.edu wrote: > > >After looking at your problem it looks like the widths of the lines > >are as wide as your energy range. I guess this would be appropriate > >[snip..] > >so many exponentiations. You could have gotten a pretty big savings > >if the lines were narrow, and you could restrict the computation to a > >narrow region around the line center (say +/- 10 sigma with WHERE). I > >recommend that anyway to get rid of underflow errors. > >[snip..] > >If for example your sigma term were > >(((.12*sqrt(stick[0,i]/1000))/1.6651)*10) [ note the last factor is > >smaller ] then things start to look interesting. > > That's because there's always a danger in taking code x and modifying it > into simpler example y! As you suggested, I actually DO have a sigma term > with a *10 instead of a *1000. > > I did what you suggested with the +/- 10*sigma with where (code below), > and it drastically improved running time. For the 5000 element array, the > running time went from 62.3 seconds to 4.9 seconds! I plot the error > associated with the method, and I was actually able to go down to +/- > 4*sigma before there was any noticable error. > > Thanks! > Todd You're welcome. But call me a pedant too. You can save yet more computations by precomputing the gaussian argument. Craig xx = convoluted(0,*) yy = convoluted(1,*) for i = 0L, n_elements(stick)/2 -1 do begin z1 = (xx-stick(0,i))/(((.12*sqrt(stick[0,i]/1000))/1.6651)*10)^2 wh = where(z1 LT (2.*4^2), ct) ;; Four sigma (remember the 1/2!) if ct GT 0 then yy(wh) = yy(wh) + stick(1,i)*exp(-z1) endfor convoluted(1,*) = yy I hope I got it all right, but you get the idea. By the way, as I note above, the definition of the gaussian is exp(-x^2/(2*sigma^2)). Is the 1/2 buried somewhere in your definition? -- -------------------------------------------------------------------------- Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response --------------------------------------------------------------------------

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

**Re: Convolution of Stick Spectra***From:*Craig Markwardt

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

- Prev by Date:
**Re: Convolution of Stick Spectra** - Next by Date:
**One plot line, different thicknesses** - Prev by thread:
**Re: Convolution of Stick Spectra** - Next by thread:
**Font problems in Linux** - Index(es):