torch.fft.fft#
- torch.fft.fft(input,n=None,dim=-1,norm=None,*,out=None)→Tensor#
Computes the one dimensional discrete Fourier transform of
input.Note
The Fourier domain representation of any real signal satisfies theHermitian property:X[i] = conj(X[-i]). This function always returns boththe positive and negative frequency terms even though, for real inputs, thenegative frequencies are redundant.
rfft()returns themore compact one-sided representation where only the positive frequenciesare returned.Note
Supports torch.half and torch.chalf on CUDA with GPU Architecture SM53 or greater.However it only supports powers of 2 signal length in every transformed dimension.
- Parameters:
input (Tensor) – the input tensor
n (int,optional) – Signal length. If given, the input will either be zero-paddedor trimmed to this length before computing the FFT.
dim (int,optional) – The dimension along which to take the one dimensional FFT.
norm (str,optional) –
Normalization mode. For the forward transform(
fft()), these correspond to:"forward"- normalize by1/n"backward"- no normalization"ortho"- normalize by1/sqrt(n)(making the FFT orthonormal)
Calling the backward transform (
ifft()) with the samenormalization mode will apply an overall normalization of1/nbetweenthe two transforms. This is required to makeifft()the exact inverse.Default is
"backward"(no normalization).
- Keyword Arguments:
out (Tensor,optional) – the output tensor.
Example
>>>t=torch.arange(4)>>>ttensor([0, 1, 2, 3])>>>torch.fft.fft(t)tensor([ 6.+0.j, -2.+2.j, -2.+0.j, -2.-2.j])
>>>t=torch.tensor([0.+1.j,2.+3.j,4.+5.j,6.+7.j])>>>torch.fft.fft(t)tensor([12.+16.j, -8.+0.j, -4.-4.j, 0.-8.j])