Hi,

the function stats::convolve does not mention efficient usage of the 
underlying FFT algorithm, such as

(a) if type="circular", then length(x)=length(y) should have many 
factors (e.g. length(x) = length(y) = 2^n)
(b) if type="open" or "filter", then length(x)+length(y)-1 should have 
many factors (e.g. length(x)+length(y)-1 = 2^n)

In particular the latter may not be obvious to first time users, who may 
think that stats::convolve is slow, even though it is fast, if applied 
correctly.

Moreover for zero padding, one may apply stats::nextn to (a) length(x) 
or (b)  length(x)+length(y)-1.


#Example:

#correct usage:
x <- rnorm(514289)
y <- rnorm(10000)
#length(x) + length(y) - 1 = 2^19
system.time(convolve(x, y, type="open"))

#   user  system elapsed
#   1.17    0.02    1.18


#incorrect usage:
x <- rnorm(300000)
y <- rnorm(10000)
system.time(convolve(x, y, type = "open"))

#   user  system elapsed
# 685.31    0.09  691.79




Thanks and Kind regards,
Michael Moers

        [[alternative HTML version deleted]]

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to