torch.fft.ihfftn¶
-
torch.fft.ihfftn(input, s=None, dim=None, norm=None, *, out=None) → Tensor¶ Computes the N-dimensional inverse discrete Fourier transform of real
input.inputmust be a real-valued signal, interpreted in the Fourier domain. The n-dimensional IFFT of a real signal is Hermitian-symmetric,X[i, j, ...] = conj(X[-i, -j, ...]).ihfftn()represents this in the one-sided form where only the positive frequencies below the Nyquist frequency are included in the last signal dimension. To compute the full output, useifftn().- Parameters
input (Tensor) – the input tensor
s (Tuple[int], optional) – Signal size in the transformed dimensions. If given, each dimension
dim[i]will either be zero-padded or trimmed to the lengths[i]before computing the Hermitian IFFT. If a length-1is specified, no padding is done in that dimension. Default:s = [input.size(d) for d in dim]dim (Tuple[int], optional) – Dimensions to be transformed. Default: all dimensions, or the last
len(s)dimensions ifsis given.norm (str, optional) –
Normalization mode. For the backward transform (
ihfftn()), these correspond to:"forward"- no normalization"backward"- normalize by1/n"ortho"- normalize by1/sqrt(n)(making the Hermitian IFFT orthonormal)
Where
n = prod(s)is the logical IFFT size. Calling the forward transform (hfftn()) with the same normalization mode will apply an overall normalization of1/nbetween the two transforms. This is required to makeihfftn()the exact inverse.Default is
"backward"(normalize by1/n).
- Keyword Arguments
out (Tensor, optional) – the output tensor.
Example
>>> T = torch.rand(10, 10) >>> ihfftn = torch.fft.ihfftn(T) >>> ihfftn.size() torch.Size([10, 6])
Compared against the full output from
ifftn(), we have all elements up to the Nyquist frequency.>>> ifftn = torch.fft.ifftn(t) >>> torch.allclose(ifftn[..., :6], ihfftn) True
The discrete Fourier transform is separable, so
ihfftn()here is equivalent to a combination ofihfft()andifft():>>> two_iffts = torch.fft.ifft(torch.fft.ihfft(t, dim=1), dim=0) >>> torch.allclose(ihfftn, two_iffts) True