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 (
normofjax.numpy.fft).Nonestands forNorm::Backward.
Functions§
- fft
- The one-dimensional discrete Fourier transform along
axis, of lengthn(the operand is sliced or padded with zeros; its length by default). - fft2
- The two-dimensional transform of
axes([-2, -1]in JAX), of lengthss. - fftfreq
- The frequencies of the coefficients of
fftof lengthnwith sample spacingd:[0, 1, ..., n / 2 - 1, -n / 2, ..., -1] / (d n)(for evenn). - fftn
- The transform of
axes(every axis by default, or the lasts.len()), of lengthss(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(seefftn). - ifftshift
- The inverse of
fftshift. - irfft
- The inverse of
rfft:nreal numbers (2 (m - 1)by default, formcoefficients). - irfft2
- The two-dimensional inverse of
rfft2. - irfftn
- The inverse of
rfftn: real numbers of lengthss(by default, those of the operand, and2 (m - 1)along the last axis). - rfft
- The one-dimensional transform of real numbers: the
n / 2 + 1nonnegative frequencies. - rfft2
- The two-dimensional transform of real numbers (see
rfftn). - rfftfreq
- The frequencies of the coefficients of
rfftof lengthnwith sample spacingd:[0, 1, ..., n / 2] / (d n). - rfftn
- The transform of real numbers along
axes(seefftn): the last axis hass[-1] / 2 + 1coefficients.