Learn R Programming

torch (version 0.1.0)

torch_rfft: Rfft

Description

Rfft

Usage

torch_rfft(self, signal_ndim, normalized = FALSE, onesided = TRUE)

Arguments

self

(Tensor) the input tensor of at least signal_ndim 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

onesided

(bool, optional) controls whether to return half of results to avoid redundancy. Default: TRUE

rfft(input, signal_ndim, normalized=False, onesided=TRUE) -> Tensor

Real-to-complex Discrete Fourier Transform

This method computes the real-to-complex discrete Fourier transform. It is mathematically equivalent with torch_fft with differences only in formats of the input and output.

This method supports 1D, 2D and 3D real-to-complex transforms, indicated by signal_ndim. input must be a tensor with at least signal_ndim 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, where \(N_i\) is the size of signal dimension \(i\).

The real-to-complex Fourier transform results follow conjugate symmetry:

$$ X[\omega_1, \dots, \omega_d] = X^*[N_1 - \omega_1, \dots, N_d - \omega_d], $$ where the index arithmetic is computed modulus the size of the corresponding dimension, \(\ ^*\) is the conjugate operator, and \(d\) = signal_ndim. onesided flag controls whether to avoid redundancy in the output results. If set to TRUE (default), the output will not be full complex result of shape \((*, 2)\), where \(*\) is the shape of input, but instead the last dimension will be halfed as of size \(\lfloor \frac{N_d}{2} \rfloor + 1\).

The inverse of this function is torch_irfft.

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()) {

x = torch_randn(c(5, 5))
torch_rfft(x, 2)
torch_rfft(x, 2, onesided=FALSE)
}
# }

Run the code above in your browser using DataLab