[R] Calling fft from C

Gunnar Hellmund ghellmund at gmail.com
Sun May 30 20:08:06 CEST 2010


I have made a R function 'convolve2' for convolution of two real
valued vectors based on Rs 'convolve' with option type="open" - see
(exp.length and irf.length are variables set in another part of the program)

I wish to implement the function convolve2 in C and use it in a
function used from R with .Call - e.g. I need to call fft in C.
All I can find in the source code is do_fft in Internals.h - but how
do I use do_fft? Or should I call another C routine (and how)?

How do I solve the problem in the most appropriate way?

x<- c(rep.int(0,exp.length-1),x)
n <- length(y<-c(y, rep.int(0, irf.length -1)))
x <- fft(fft(x) * Conj(fft(y)), inverse=TRUE)

Best wishes/bedste hilsner

Gunnar Hellmund

cand. scient., PhD

“If everyone is thinking alike, then somebody isn't thinking.”

More information about the R-help mailing list