signal icon indicating copy to clipboard operation
signal copied to clipboard

rfft

Open braingineer opened this issue 7 years ago • 2 comments

Hi!

Cool library.

Is there a shortcut way to do rfft with your library (or how hard would it be to adapt it)?

Thanks

braingineer avatar May 20 '17 02:05 braingineer

After playing around with things for a bit, some additional things:

  • your imports aren't python 3 safe (specifically, import siglib in the __init__)
  • I had some issues with fftw3 and had to compile from source. maybe pointing at that could be good.
  • you don't allow for specifing the number of fft points (e.g. the N in https://docs.scipy.org/doc/numpy-1.10.4/reference/generated/numpy.fft.fft.html#numpy.fft.fft).

It's this last one that I am most interested in. I can't quite grok how I'd do this with the cufft library or I'd do it myself. the lua library you pointed at enforced the case that the output would be N/2+1, but in general, I'd like to specify the number of FFT points (for instance, spectrograms depend on this).

Finally, I'd also like to be able to do a r2r out. That's pretty trivial,right?

Thanks a ton

braingineer avatar May 20 '17 04:05 braingineer

Thanks Brian,

I am not sure about fftw3 problem since it's been very easy for me to install the library on Ubuntu. If you need certain number of fft points, I think you can always truncate the output to the desired frequency you want - discarding higher frequencies, numpy might just do the same thing.

Regarding y = rfft(x), (or R2C), since the input is real, the output is hermitian symmetric and thus we only need to keep (N/2 + 1) coefficients as you see in torch . However, if you want to compute the backward pass df/dx, it might be complicated since df/dy is likely not symmetric. In this case I would just fake the input as complex numbers with zero imaginarym, use C2C and discard the imaginary part of df/dx.

thuyen avatar May 21 '17 07:05 thuyen