Sliding FFT in R

Is there a function or package in R to calculate the sliding FFT sample? By this I mean that, given the output, fft(x[n:m]) effectively computes fft(x[1+(n:m)]) .

Ideally, I would find both the online version (where I do not have access to the full time series at the beginning, or it is too large to fit into the memory, and I am not going to save the whole FFT launch in memory) and the batch version (where I give give it the whole sample x and talk about the width of the working window w , which leads to a complex matrix of size c(w,length(x)/w) ).

An example of such an algorithm is presented here (but I never tried to implement it in any language):

http://cnx.org/content/m12029/latest/

If in R there is no such thing that does not look too complicated to implement, I think.

+8
r fft
source share
1 answer

As usual, when I post something here, I continued to work on it and came up with a solution:

 fft.up <- function(x1, xn, prev) { b <- length(prev) vec <- exp(2i*pi*seq.int(0,b-1)/b) (prev - x1 + xn) * vec } # Test it out x <- runif(6) all.equal(fft.up(x[1], x[6], fft(x[1:5])), fft(x[2:6])) # [1] TRUE 

It is still interesting to know if any library offers, because then it can offer other convenient things. =) But at the moment my problem is solved.

+5
source share

All Articles