Skip to main content

Module fft

Module fft 

Source
Expand description

Discrete Fourier transforms following jax.numpy.fft.

The transforms compute what JAX’s compute, with the same primitives: the operand is sliced or padded with zeros to the lengths s, the axes are moved last, and up to three axes are transformed at a time (lax.fft). As elsewhere in ruxla, types are not promoted: fft takes complex numbers, rfft takes f32 or f64.

§Examples

use ruxla_core::{Array, Native, c64, jnp};

let x = Array::<Native, f32>::from_vec(vec![1.0, 2.0, 3.0, 4.0], [4]);
let y = jnp::fft::rfft(&x, None, -1, None);
assert_eq!(y.to_vec()[0], c64::new(10.0, 0.0));
let back = jnp::fft::irfft(&y, Some(4), -1, None);
for (a, b) in back.to_vec().iter().zip([1.0, 2.0, 3.0, 4.0]) {
    assert!((a - b).abs() < 1e-6);
}

Enums§

Norm
The normalization of a transform (norm of jax.numpy.fft). None stands for Norm::Backward.

Functions§

fft
The one-dimensional discrete Fourier transform along axis, of length n (the operand is sliced or padded with zeros; its length by default).
fft2
The two-dimensional transform of axes ([-2, -1] in JAX), of lengths s.
fftfreq
The frequencies of the coefficients of fft of length n with sample spacing d: [0, 1, ..., n / 2 - 1, -n / 2, ..., -1] / (d n) (for even n).
fftn
The transform of axes (every axis by default, or the last s.len()), of lengths s (those of the operand by default).
fftshift
Moves the zero frequency to the center of axes (every axis by default): a roll by half of each length.
ifft
The one-dimensional inverse transform (see fft).
ifft2
The two-dimensional inverse transform (see fft2).
ifftn
The inverse transform of axes (see fftn).
ifftshift
The inverse of fftshift.
irfft
The inverse of rfft: n real numbers (2 (m - 1) by default, for m coefficients).
irfft2
The two-dimensional inverse of rfft2.
irfftn
The inverse of rfftn: real numbers of lengths s (by default, those of the operand, and 2 (m - 1) along the last axis).
rfft
The one-dimensional transform of real numbers: the n / 2 + 1 nonnegative frequencies.
rfft2
The two-dimensional transform of real numbers (see rfftn).
rfftfreq
The frequencies of the coefficients of rfft of length n with sample spacing d: [0, 1, ..., n / 2] / (d n).
rfftn
The transform of real numbers along axes (see fftn): the last axis has s[-1] / 2 + 1 coefficients.