packages

signal::fft::nd

N-dimensional FFTs: one 1-d transform per chosen axis, each over every line of the array along that axis (row-column method).

Functions

fftnSource

pub fn fftn<const N: usize>(x: Array<Complex<f64>, N>, axes: List<usize>? = none, norm: Norm = Norm::Backward) throws (SignalError) -> Array<Complex<f64>, N>

The N-d DFT of x over axes (every axis by default), in the order given; an axis named twice is transformed twice.

nabi
use signal::fft::fftn;
use core::array::Array;
use core::num::Complex;

let x: Array<f64, 2> = [[1, 2], [3, 4]];
let y = try fftn(signal::complex(x));
println(signal::real(y)); // [[10.0, -2.0], [-4.0, 0.0]]
let rows = try fftn(signal::complex(x), axes: [1]);
println(signal::real(rows)); // [[3.0, -1.0], [7.0, -1.0]]

ifftnSource

pub fn ifftn<const N: usize>(x: Array<Complex<f64>, N>, axes: List<usize>? = none, norm: Norm = Norm::Backward) throws (SignalError) -> Array<Complex<f64>, N>

The inverse of fftn over the same axes.

nabi
use signal::fft::{fftn, ifftn};
use core::array::Array;

let x: Array<f64, 2> = [[1, 2], [3, 4]];
let back = try ifftn(try fftn(signal::complex(x)));
println(signal::real(back)); // [[1.0, 2.0], [3.0, 4.0]]

fft2Source

pub fn fft2(x: Matrix<Complex<f64>>, norm: Norm = Norm::Backward) throws (SignalError) -> Matrix<Complex<f64>>

The 2-d DFT of a matrix (fftn over both axes).

nabi
use signal::fft::fft2;
use core::array::Matrix;

let m: Matrix<f64> = [[1, 0], [0, 0]];
println(signal::real(try fft2(signal::complex(m)))); // [[1.0, 1.0], [1.0, 1.0]]

ifft2Source

pub fn ifft2(x: Matrix<Complex<f64>>, norm: Norm = Norm::Backward) throws (SignalError) -> Matrix<Complex<f64>>

The inverse of fft2.

nabi
use signal::fft::{fft2, ifft2};
use core::array::Matrix;

let m: Matrix<f64> = [[1, 2], [3, 4]];
println(signal::real(try ifft2(try fft2(signal::complex(m))))); // [[1.0, 2.0], [3.0, 4.0]]

rfftnSource

pub fn rfftn<const N: usize>(x: Array<f64, N>, norm: Norm = Norm::Backward) throws (SignalError) -> Array<Complex<f64>, N>

The N-d DFT of a real array: the last axis keeps bins 0..=n/2 (rfft), the others are full complex transforms.

nabi
use signal::fft::rfftn;
use core::array::Array;

let x: Array<f64, 2> = [[1, 2, 3, 4], [0, 0, 0, 0]];
println(try rfftn(x).shape()); // [2, 3]

irfftnSource

pub fn irfftn<const N: usize>(x: Array<Complex<f64>, N>, n: usize? = none, norm: Norm = Norm::Backward) throws (SignalError) -> Array<f64, N>

The inverse of rfftn: n is the length of the last axis of the result (default 2 * (bins - 1)).

nabi
use signal::fft::{rfftn, irfftn};
use core::array::Array;

let x: Array<f64, 2> = [[1, 2, 3], [4, 5, 6]];
println(try irfftn(try rfftn(x), n: 3)); // [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]] (to rounding)