Function rfft
pub fn rfft<const D: usize>(
signal: Tensor<D>,
dim: impl AsIndex,
n: Option<usize>,
) -> (Tensor<D>, Tensor<D>)Expand description
Computes the 1-dimensional discrete Fourier Transform of real-valued input.
Since the input is real, the Hermitian symmetry is exploited, and only the
first non-redundant values are returned ($N/2 + 1$).
Autodiff is supported when the autodiff feature is enabled.
X[k] = Σ x[n] * exp(-i*2πkn/N)
§Arguments
signal- The input tensor containing the real-valued signal.dim- The dimension along which to take the FFT. Negative dimensions are supported and count from the end.n- Optional FFT length. WhenNone, the signal must be a power of two alongdim. WhenSome(n),nmust also be a power of two; the signal is truncated or zero-padded to lengthn. Non-power-of-twonis rejected with a panic (true arbitrary-size DFT support via Bluestein’s algorithm is tracked as a follow-up).
§Returns
A tuple containing:
- The real part of the spectrum. Output length along
dimisn / 2 + 1(usingnorsignal_lenrespectively). - The imaginary part of the spectrum (same shape).
§Example
use burn_core::tensor::Tensor;
let device = Default::default();
let signal = Tensor::<1>::from_floats([1.0, 2.0, 3.0, 4.0], &device);
let (real, imag) = burn_signal::rfft(signal, 0, None);