RustFFT Documentation

Compute FFTs in Julia using RustFFT. Some parts of this documentation have been quoted from the RustFFT docs.

RustFFT is a high-performance, SIMD-accelerated FFT library written in pure Rust. It can compute FFTs of any size, including prime-number sizes, in O(nlogn) time.

Usage

RustFFT.jl implements the generic FFT interface of AbstractFFTs.jl but only supports one-dimensional, contiguous, complex-valued arrays: Vector{ComplexF64} and Vector{ComplexF32}.

Forward and inverse FFT:

using RustFFT

data = ones(ComplexF64, 1)
fft!(data)
using RustFFT

data = ones(ComplexF64, 1)
ifft!(data)

You can set several options by planning the FFT:

using RustFFT

planner = new_planner(ComplexF64)
data = ones(ComplexF64, 1)
plan = plan_fft!(data;
    rustfft_checks=IgnoreArrayChecks(), # Don't track the array or check if its length is compatible
    rustfft_gcsafe=GcSafe(), # Don't block the GC while an FFT is computed with this plan
    rustfft_planner=planner) # Reuse an existing planner
plan * data

It's currently not possible to choose the specific algorithm that will be used to compute the transform.

RustFFT-specific API

RustFFT.AllArrayChecksType
AllArrayChecks()

Track the array and check if the length is compatible with the plan. This is the default.

source
RustFFT.new_plannerFunction
new_planner(::Type{ComplexF32})
new_planner(::Type{ComplexF64})

Returns a new planner. By default each plan creates a new planner but one can also be provided to the plan_*-functions as a keyword argument: rustfft_planner. By reusing the same planner, internal data is reused across different plans saving memory and setup time.

source

Internals

RustFFT.Internal.FftPlannerType
FftPlanner{T}

A planner for forward and inverse FFTs of Vector{T}, T must be ComplexF32 or ComplexF64. A new planner can be created by calling the zero-argument constructor. The aliases FftPlanner32 and FftPlanner64 are also available.

RustFFT.Internal.rustfft_fft!Function
rustfft_fft!(instance::FftInstance{T}, buffer::Vector{T})

Computes the planned FFT if buffer in-place. If the array is already tracked or the length is incompatible JlrsCore.JlrsError is thrown.

RustFFT.Internal.rustfft_fft_gcsafe!Function
rustfft_fft_gcsafe!(instance::FftInstance{T}, buffer::Vector{T})

Computes the planned FFT if buffer in-place. If buffer is already tracked or its length is incompatible JlrsCore.JlrsError is thrown. The GC is allowed to collect while this function is called.

RustFFT.Internal.rustfft_fft_unchecked_gcsafe!Function
rustfft_fft_unchecked_gcsafe!(instance::FftInstance{T}, buffer::Vector{T})

Computes the planned FFT if buffer in-place. The GC is allowed to collect while this function is called.

RustFFT.Internal.rustfft_fft_untracked!Function
rustfft_fft_untracked!(instance::FftInstance{T}, buffer::Vector{T})

Computes the planned FFT if buffer in-place. If the length of buffer is incompatible JlrsCore.JlrsError is thrown.

RustFFT.Internal.rustfft_fft_untracked_gcsafe!Function
rustfft_fft_untracked_gcsafe!(instance::FftInstance{T}, buffer::Vector{T})

Computes the planned FFT if buffer in-place. If the length of buffer is incompatible JlrsCore.JlrsError is thrown. The GC is allowed to collect while this function is called.

RustFFT.Internal.rustfft_plan_fft_forward!Function
rustfft_plan_fft_forward!(planner::FftPlanner{T}, len::UInt)

Plan a forward FFT for Vector{T} data of length len. If the planner is already tracked JlrsCore.BorrowError is thrown.

RustFFT.Internal.rustfft_plan_fft_inverse!Function
rustfft_plan_fft_inverse!(planner::FftPlanner{T}, len::UInt)

Plan an inverse FFT for Vector{T} data of length len. If the planner is already tracked JlrsCore.BorrowError is thrown.