signal::fft::freq
The frequencies of FFT bins, and moving the zero frequency to the middle.
Functions
fftfreqSource
pub fn fftfreq(n: usize, d: f64 = 1.0) throws (SignalError) -> Vector<f64> The frequency of each fft bin for n samples spaced d apart
(d = 1 / fs): [0, 1, .., n/2 - 1, -n/2, .., -1] / (d n) for even
n, as NumPy.
nabi
println(try signal::fft::fftfreq(4, d: 0.25)); // [0.0, 1.0, -2.0, -1.0]
rfftfreqSource
pub fn rfftfreq(n: usize, d: f64 = 1.0) throws (SignalError) -> Vector<f64> The frequency of each rfft bin: [0, 1, .., n/2] / (d n).
nabi
println(try signal::fft::rfftfreq(4, d: 0.25)); // [0.0, 1.0, 2.0]
fftshiftSource
pub fn fftshift<T, const N: usize>(x: Array<T, N>, axes: List<usize>? = none) -> Array<T, N> x with the zero-frequency bin moved to the middle of each axis in
axes (every axis by default), for plotting a spectrum. Axes at or
past the rank are ignored.
nabi
use core::array::Vector;
let f = try signal::fft::fftfreq(5);
println(signal::fft::fftshift(f)); // [-0.4, -0.2, 0.0, 0.2, 0.4]
ifftshiftSource
pub fn ifftshift<T, const N: usize>(x: Array<T, N>, axes: List<usize>? = none) -> Array<T, N> The inverse of fftshift (they differ for odd lengths).
nabi
use core::array::Vector;
let v: Vector<i64> = [1, 2, 3, 4, 5];
println(signal::fft::ifftshift(signal::fft::fftshift(v))); // [1, 2, 3, 4, 5]