Skip to main content

cfft

Function cfft 

pub fn cfft<const D: usize>(
    signal_re: Tensor<D>,
    signal_im: Tensor<D>,
    dim: impl AsIndex,
    n: Option<usize>,
) -> (Tensor<D>, Tensor<D>)
Expand description

Computes the 1-dimensional discrete Fourier Transform of complex-valued input.

Internally calls rfft on the real and imaginary parts separately, extends each half-spectrum to the full N-bin spectrum via Hermitian symmetry.

Autodiff is supported when the autodiff feature is enabled.

X[k] = Σ x[n] * exp(-i*2πkn/N)

§Arguments

  • signal_re - The real part of the complex input signal.
  • signal_im - The imaginary part of the complex input signal. Must have the same shape as signal_re.
  • dim - The dimension along which to take the FFT. Negative dimensions are supported and count from the end.
  • n - Optional FFT length. When None, the signal must be a power of two along dim. When Some(n), n must also be a power of two; the signal is truncated or zero-padded to length n.

§Returns

A tuple (re, im) representing the full complex spectrum, each with n elements along dim.

§Example

use burn_core::tensor::Tensor;

let device = Default::default();
let re = Tensor::<1>::from_floats([1.0, 0.0, -1.0, 0.0], &device);
let im = Tensor::<1>::from_floats([0.0, 1.0, 0.0, -1.0], &device);
let (spec_re, spec_im) = burn_signal::cfft(re, im, 0, None);