Bug 408 - convolution bug
Summary: convolution bug
Status: NEW
Alias: None
Product: R
Classification: Unclassified
Component: Language (show other bugs)
Version: old
Hardware: All Linux
: P5 normal
Assignee: Jitterbug compatibility account
Depends on:
Reported: 2000-01-28 16:17 UTC by Jitterbug compatibility account
Modified: 2012-03-24 16:22 UTC (History)
1 user (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Jitterbug compatibility account 2000-01-28 16:17:36 UTC
From: wsimpson@gcal.ac.uk
Full_Name: Bill Simpson
Version: 65.1 , 0.90.1
OS: Linux
Submission from: (NULL) (

I reported this on r-help, but here is official bug report.

The present convolve() does not do convolution by default. Its default behaviour
correlation. This is a bug.

The default argument conj should be set to FALSE.

The zero-padding should be on the right for linear convolution (don't ask me
why you call this type="open"; I suggest type="linear").

Here is what I expect linear convolution to do:
myconvolve<-function (x,h) 
    nx <- length(x)
    nh <- length(h)
    #zero pad
       x <- c(x,rep(0, nh-1))
       h <- c(h,rep(0, nx-1))
    x <- fft(fft(x) * fft(h), inv = TRUE)
#I am not sure about this, the R IFFT is weird

What "circular" convolution should do is just
eliminate the zero-padding:

myconvolve2<-function (x,h)
#no padding, circular convolution
    nx <- length(x)
    nh <- length(h)
    x <- fft(fft(x) * fft(h), inv = TRUE)

I suggest that you create two functions, convolve() and correlate(), and get
of the conj argument in convolve().
Comment 1 Jitterbug compatibility account 2004-08-12 04:40:00 UTC
 Is this a bug?
Comment 2 Jitterbug compatibility account 2004-08-12 06:36:19 UTC
Audit (from Jitterbug):
Wed Feb 16 19:28:42 2000	ripley	moved from incoming to Language
Thu Aug 12 01:36:19 2004	thomas	changed notes