Function cfft
pub fn cfft<B, const D: usize>(
signal_re: Tensor<B, D>,
signal_im: 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 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 not yet supported.
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 assignal_re.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.
§Returns
A tuple (re, im) representing the full complex spectrum, each with n
elements along dim.
§Example
use burn_tensor::backend::Backend;
use burn_tensor::Tensor;
fn example<B: Backend>() {
let device = B::Device::default();
let re = Tensor::<B, 1>::from_floats([1.0, 0.0, -1.0, 0.0], &device);
let im = Tensor::<B, 1>::from_floats([0.0, 1.0, 0.0, -1.0], &device);
let (spec_re, spec_im) = burn_tensor::signal::cfft(re, im, 0, None);
}