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

Home » Public Forums » archive » Approximate convolution - for loop problem
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: Approximate convolution - for loop problem [message #64501 is a reply to message #64417] Fri, 02 January 2009 11:12 Go to previous message
David Gell is currently offline  David Gell
Messages: 29
Registered: January 2009
Junior Member
On Dec 21 2008, 11:32 am, samuel.le...@gmail.com wrote:
> Hello everyone, I'm trying to execute a 1-d convolution of an array,
> signal.
>
> Using an analytic approximation, obtaining the convolved bolometer
> signal, bolo_signal, at time step ii, is given by the following:
>
> nsamp=n_elements(signal)
> const1 = exp(-tsamp/taubolo)
> const2 = 1.-const1
>
> bolo_signal = const2*signal
> for ii= 1L,nsamp-1L do begin
>     bolo_signal[ii] += const1*bolo_signal[ii-1]
> endfor
>
> where tsamp and taubolo are scalars. Is there any way to avoid the for
> loop in this case? The hope is to speed up the execution.
>
> Many thanks for your help
>
> Sam Leach

An alternative way requires building an upper triangular matrix of
powers of the second constant


anA=[1.,2.,3.,4]
nConst1 = 1.0
nConst2 = 0.5

nEle=n_elements(anA)

;bulid a upper diagonal matrix from the constants
anMatrix = fltarr(nEle,nEle)
for nI=0,nEle-1 do anMatrix[nI:*,nI] = nConst2^indgen(nEle-nI)

;compute result
anResult = anA ## anMatrix
help, anResult
print, anResult
end

% Compiled module: $MAIN$.
ANRESULT FLOAT = Array[4]
1.00000 2.50000 4.25000 6.12500

The problem is building the upper triangular matrix.If that could be
done efficiently, then this might speed things up.

David Gell
Southwest Research Institute
San Antonio, TX
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: scatter plots make large PostScript files
Next Topic: Running IDL remotely - problems with xwindows

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

Current Time: Sun Oct 12 11:11:16 PDT 2025

Total time taken to generate the page: 1.44214 seconds