hcrisp

02-24-2011, 09:36 AM

I am using CONVOL1D to calculate the autocorrelation of a signal. I see there is a keyword DIRECT which overrides the default method (FFT) to compute the convolution directly. However the output vector lengths are not the same.

x = randomu(s, 512)

y1 = convol1d(x, x)

y2 = convol1d(x, x, /direct)

info, y1, y2

; Y1 (DWPLOTINTERPDATA) DOUBLE = Array(512)

; Y2 (DWPLOTINTERPDATA) DOUBLE = Array(511)

x = randomu(s, 5437)

y1 = convol1d(x, x)

y2 = convol1d(x, x, /direct)

info, y1, y2

; Y1 (DWPLOTINTERPDATA) DOUBLE = Array(10935)

; Y2 (DWPLOTINTERPDATA) DOUBLE = Array(10873)

The DIRECT method seems to give the correct length, while it appears that the FFT method is adding extra zeros to the end (probably due to POW235 padding). How can I reliably remove these extra zeros? Something like this?

npts = 5437

x = randomu(s, npts)

y1 = convol1d(x, x)

cnpts = (npts * 2) - 1

y1 = y1(0:cnpts-1)

info, y1

; Y1 (DWPLOTINTERPDATA) DOUBLE = Array(10873)

x = randomu(s, 512)

y1 = convol1d(x, x)

y2 = convol1d(x, x, /direct)

info, y1, y2

; Y1 (DWPLOTINTERPDATA) DOUBLE = Array(512)

; Y2 (DWPLOTINTERPDATA) DOUBLE = Array(511)

x = randomu(s, 5437)

y1 = convol1d(x, x)

y2 = convol1d(x, x, /direct)

info, y1, y2

; Y1 (DWPLOTINTERPDATA) DOUBLE = Array(10935)

; Y2 (DWPLOTINTERPDATA) DOUBLE = Array(10873)

The DIRECT method seems to give the correct length, while it appears that the FFT method is adding extra zeros to the end (probably due to POW235 padding). How can I reliably remove these extra zeros? Something like this?

npts = 5437

x = randomu(s, npts)

y1 = convol1d(x, x)

cnpts = (npts * 2) - 1

y1 = y1(0:cnpts-1)

info, y1

; Y1 (DWPLOTINTERPDATA) DOUBLE = Array(10873)