Learn R Programming

torch (version 0.2.1)

torch_fft: Fft

Description

Fft

Usage

torch_fft(self, signal_ndim, normalized = FALSE)

Arguments

self

(Tensor) the input tensor of at least signal_ndim + 1 dimensions

signal_ndim

(int) the number of dimensions in each signal. signal_ndim can only be 1, 2 or 3

normalized

(bool, optional) controls whether to return normalized results. Default: FALSE

fft(input, signal_ndim, normalized=False) -> Tensor

Complex-to-complex Discrete Fourier Transform

This method computes the complex-to-complex discrete Fourier transform. Ignoring the batch dimensions, it computes the following expression:

$$ X[\omega_1, \dots, \omega_d] = \sum_{n_1=0}^{N_1-1} \dots \sum_{n_d=0}^{N_d-1} x[n_1, \dots, n_d] e^{-j\ 2 \pi \sum_{i=0}^d \frac{\omega_i n_i}{N_i}}, $$ where \(d\) = signal_ndim is number of dimensions for the signal, and \(N_i\) is the size of signal dimension \(i\).

This method supports 1D, 2D and 3D complex-to-complex transforms, indicated by signal_ndim. input must be a tensor with last dimension of size 2, representing the real and imaginary components of complex numbers, and should have at least signal_ndim + 1 dimensions with optionally arbitrary number of leading batch dimensions. If normalized is set to TRUE, this normalizes the result by dividing it with \(\sqrt{\prod_{i=1}^K N_i}\) so that the operator is unitary.

Returns the real and the imaginary parts together as one tensor of the same shape of input.

The inverse of this function is torch_ifft.

Warning

For CPU tensors, this method is currently only available with MKL. Use torch_backends.mkl.is_available to check if MKL is installed.

Examples

Run this code
# NOT RUN {
if (torch_is_installed()) {

# unbatched 2D FFT
x = torch_randn(c(4, 3, 2))
torch_fft(x, 2)
# batched 1D FFT
torch_fft(x, 1)
# arbitrary number of batch dimensions, 2D FFT
x = torch_randn(c(3, 3, 5, 5, 2))
torch_fft(x, 2)

}
# }

Run the code above in your browser using DataLab