[R] Calling fft from C
ghellmund at gmail.com
Sun May 30 21:35:38 CEST 2010
Thanks for the reply, but ...
No, I am not interested in the convolution function defined in the
I want to use a fast fourier transform version implemented in C
returning values to another C function.
So the question is: How do I call the fft supplied by R in C? (just
like it is possible to use other R functions in C using #include
On Sun, May 30, 2010 at 8:12 PM, Gabor Grothendieck
<ggrothendieck at gmail.com> wrote:
> The Writing R Extensions manual specifically uses convolve as an
> example of calling C from R.
> On Sun, May 30, 2010 at 2:08 PM, Gunnar Hellmund <ghellmund at gmail.com> wrote:
>> 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.”
>> R-help at r-project.org mailing list
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
Best wishes/bedste hilsner
PhD, Scientific Assistant
“If everyone is thinking alike, then somebody isn't thinking.”
More information about the R-help