Function rfft
pub fn rfft<B, const D: usize>(
signal: Tensor<B, D>,
dim: usize,
n: Option<usize>,
) -> (Tensor<B, D>, Tensor<B, D>)where
B: Backend,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$). For now, the autodiff is not yet supported
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.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_tensor::backend::Backend;
use burn_tensor::Tensor;
fn example<B: Backend>() {
let device = B::Device::default();
let signal = Tensor::<B, 1>::from_floats([1.0, 2.0, 3.0, 4.0], &device);
let (real, imag) = burn_tensor::signal::rfft(signal, 0, None);
}