Skip to content

fft

fn create_rfft_f32_plan #

fn create_rfft_f32_plan(length int) !RealFftPlanF32

create_rfft_f32_plan creates a reusable real f32 FFT plan that returns Complex32 output without promoting values to f64.

fn create_rfft_plan #

fn create_rfft_plan[T](length int) !RealFftPlan[T]

create_rfft_plan creates a reusable one-dimensional real FFT plan.

fn fft #

fn fft(input &vtl.Tensor[complex.Complex]) !&vtl.Tensor[complex.Complex]

fft computes a one-dimensional discrete Fourier transform of complex f64 values, returning all positive and negative frequencies in native order.

fn fft2 #

fn fft2(input &vtl.Tensor[complex.Complex]) !&vtl.Tensor[complex.Complex]

fft2 computes a two-dimensional complex discrete Fourier transform.

fn fft2_f32 #

fn fft2_f32(input &vtl.Tensor[Complex32]) !&vtl.Tensor[Complex32]

fft2_f32 computes a two-dimensional complex f32 DFT.

fn fft2_norm #

fn fft2_norm(input &vtl.Tensor[complex.Complex], norm FftNorm) !&vtl.Tensor[complex.Complex]

fft2_norm computes a two-dimensional complex FFT with explicit normalization.

fn fft2_norm_f32 #

fn fft2_norm_f32(input &vtl.Tensor[Complex32], norm FftNorm) !&vtl.Tensor[Complex32]

fft2_norm_f32 computes a 2-D complex f32 FFT with explicit normalization.

fn fft_axis #

fn fft_axis(input &vtl.Tensor[complex.Complex], axis int) !&vtl.Tensor[complex.Complex]

fft_axis transforms one axis of a complex tensor and preserves its shape. Negative axis values count backward from the final dimension.

fn fft_axis_f32 #

fn fft_axis_f32(input &vtl.Tensor[Complex32], axis int) !&vtl.Tensor[Complex32]

fft_axis_f32 transforms one axis of a complex f32 tensor.

fn fft_axis_norm #

fn fft_axis_norm(input &vtl.Tensor[complex.Complex], axis int, norm FftNorm) !&vtl.Tensor[complex.Complex]

fft_axis_norm transforms one complex tensor axis using an explicit normalization mode.

fn fft_axis_norm_f32 #

fn fft_axis_norm_f32(input &vtl.Tensor[Complex32], axis int, norm FftNorm) !&vtl.Tensor[Complex32]

fft_axis_norm_f32 transforms one complex f32 tensor axis with explicit normalization.

fn fft_f32 #

fn fft_f32(input &vtl.Tensor[Complex32]) !&vtl.Tensor[Complex32]

fft_f32 computes a one-dimensional DFT of single-precision complex values.

fn fft_norm #

fn fft_norm(input &vtl.Tensor[complex.Complex], norm FftNorm) !&vtl.Tensor[complex.Complex]

fft_norm computes a one-dimensional complex FFT with an explicit normalization mode.

fn fft_norm_f32 #

fn fft_norm_f32(input &vtl.Tensor[Complex32], norm FftNorm) !&vtl.Tensor[Complex32]

fft_norm_f32 computes a one-dimensional complex f32 FFT with explicit normalization.

fn fftfreq #

fn fftfreq(n int, d f64) !&vtl.Tensor[f64]

fftfreq returns the discrete Fourier Transform sample frequencies for a transform of length n and sample spacing d, in NumPy's native FFT order.

fn fftn #

fn fftn(input &vtl.Tensor[complex.Complex]) !&vtl.Tensor[complex.Complex]

fftn computes the complex discrete Fourier transform across every axis.

fn fftn_f32 #

fn fftn_f32(input &vtl.Tensor[Complex32]) !&vtl.Tensor[Complex32]

fftn_f32 transforms every axis of a complex f32 tensor.

fn fftn_norm #

fn fftn_norm(input &vtl.Tensor[complex.Complex], norm FftNorm) !&vtl.Tensor[complex.Complex]

fftn_norm transforms every complex tensor axis with an explicit normalization mode.

fn fftn_norm_f32 #

fn fftn_norm_f32(input &vtl.Tensor[Complex32], norm FftNorm) !&vtl.Tensor[Complex32]

fftn_norm_f32 transforms all complex f32 axes with explicit normalization.

fn fftshift #

fn fftshift[T](input &vtl.Tensor[T]) !&vtl.Tensor[T]

fftshift moves the zero-frequency component to the center of every axis.

fn fftshift_axis #

fn fftshift_axis[T](input &vtl.Tensor[T], axis int) !&vtl.Tensor[T]

fftshift_axis shifts one axis so its zero-frequency component is centered.

fn ifft #

fn ifft(input &vtl.Tensor[complex.Complex]) !&vtl.Tensor[complex.Complex]

ifft computes the normalized one-dimensional inverse transform of complex f64 values.

fn ifft2 #

fn ifft2(input &vtl.Tensor[complex.Complex]) !&vtl.Tensor[complex.Complex]

ifft2 computes the normalized two-dimensional complex inverse transform.

fn ifft2_f32 #

fn ifft2_f32(input &vtl.Tensor[Complex32]) !&vtl.Tensor[Complex32]

ifft2_f32 computes a normalized two-dimensional complex f32 inverse DFT.

fn ifft2_norm #

fn ifft2_norm(input &vtl.Tensor[complex.Complex], norm FftNorm) !&vtl.Tensor[complex.Complex]

ifft2_norm computes a two-dimensional complex inverse FFT with explicit normalization.

fn ifft2_norm_f32 #

fn ifft2_norm_f32(input &vtl.Tensor[Complex32], norm FftNorm) !&vtl.Tensor[Complex32]

ifft2_norm_f32 computes a 2-D complex f32 inverse FFT with explicit normalization.

fn ifft_axis #

fn ifft_axis(input &vtl.Tensor[complex.Complex], axis int) !&vtl.Tensor[complex.Complex]

ifft_axis computes a normalized inverse complex transform along one axis.

fn ifft_axis_f32 #

fn ifft_axis_f32(input &vtl.Tensor[Complex32], axis int) !&vtl.Tensor[Complex32]

ifft_axis_f32 computes a normalized inverse complex f32 transform on one axis.

fn ifft_axis_norm #

fn ifft_axis_norm(input &vtl.Tensor[complex.Complex], axis int, norm FftNorm) !&vtl.Tensor[complex.Complex]

ifft_axis_norm applies an explicit normalization mode to one complex inverse FFT axis.

fn ifft_axis_norm_f32 #

fn ifft_axis_norm_f32(input &vtl.Tensor[Complex32], axis int, norm FftNorm) !&vtl.Tensor[Complex32]

ifft_axis_norm_f32 applies explicit inverse normalization on one complex f32 axis.

fn ifft_f32 #

fn ifft_f32(input &vtl.Tensor[Complex32]) !&vtl.Tensor[Complex32]

ifft_f32 computes a normalized one-dimensional inverse complex f32 transform.

fn ifft_norm #

fn ifft_norm(input &vtl.Tensor[complex.Complex], norm FftNorm) !&vtl.Tensor[complex.Complex]

ifft_norm computes a one-dimensional complex inverse FFT with an explicit normalization mode.

fn ifft_norm_f32 #

fn ifft_norm_f32(input &vtl.Tensor[Complex32], norm FftNorm) !&vtl.Tensor[Complex32]

ifft_norm_f32 computes a normalized one-dimensional inverse complex f32 FFT.

fn ifftn #

fn ifftn(input &vtl.Tensor[complex.Complex]) !&vtl.Tensor[complex.Complex]

ifftn computes the normalized complex inverse transform across every axis.

fn ifftn_f32 #

fn ifftn_f32(input &vtl.Tensor[Complex32]) !&vtl.Tensor[Complex32]

ifftn_f32 computes a normalized inverse complex f32 transform over every axis.

fn ifftn_norm #

fn ifftn_norm(input &vtl.Tensor[complex.Complex], norm FftNorm) !&vtl.Tensor[complex.Complex]

ifftn_norm inversely transforms every complex tensor axis with an explicit normalization mode.

fn ifftn_norm_f32 #

fn ifftn_norm_f32(input &vtl.Tensor[Complex32], norm FftNorm) !&vtl.Tensor[Complex32]

ifftn_norm_f32 applies explicit inverse normalization across all complex f32 axes.

fn ifftshift #

fn ifftshift[T](input &vtl.Tensor[T]) !&vtl.Tensor[T]

ifftshift moves the zero-frequency component back to the start of every axis. It is the inverse of fftshift for odd and even dimensions.

fn ifftshift_axis #

fn ifftshift_axis[T](input &vtl.Tensor[T], axis int) !&vtl.Tensor[T]

ifftshift_axis reverses fftshift_axis for one axis.

fn irfft #

fn irfft(input &vtl.Tensor[complex.Complex], length int) !&vtl.Tensor[f64]

irfft reconstructs a real signal of length samples from its non-negative frequency components. The inverse transform is normalized by length.

fn irfft2 #

fn irfft2(input &vtl.Tensor[complex.Complex], shape []int) !&vtl.Tensor[f64]

irfft2 reconstructs a two-dimensional real tensor from rfft2 output.

fn irfft2_f32 #

fn irfft2_f32(input &vtl.Tensor[Complex32], shape []int) !&vtl.Tensor[f32]

irfft2_f32 reconstructs a two-dimensional f32 tensor from compact bins.

fn irfft2_norm #

fn irfft2_norm(input &vtl.Tensor[complex.Complex], shape []int, norm FftNorm) !&vtl.Tensor[f64]

irfft2_norm reconstructs a two-dimensional real tensor with explicit normalization.

fn irfft2_norm_f32 #

fn irfft2_norm_f32(input &vtl.Tensor[Complex32], shape []int, norm FftNorm) !&vtl.Tensor[f32]

irfft2_norm_f32 reconstructs a real f32 tensor with explicit 2-D normalization.

fn irfft_axis #

fn irfft_axis(input &vtl.Tensor[complex.Complex], axis int, length int) !&vtl.Tensor[f64]

irfft_axis reconstructs a real tensor from compact frequencies along one axis. length is the original real axis length, including for odd lengths.

fn irfft_axis_f32 #

fn irfft_axis_f32(input &vtl.Tensor[Complex32], axis int, length int) !&vtl.Tensor[f32]

irfft_axis_f32 reconstructs one real f32 tensor axis from compact bins.

fn irfft_axis_norm #

fn irfft_axis_norm(input &vtl.Tensor[complex.Complex], axis int, length int, norm FftNorm) !&vtl.Tensor[f64]

irfft_axis_norm reconstructs one real tensor axis with explicit normalization.

fn irfft_axis_norm_f32 #

fn irfft_axis_norm_f32(input &vtl.Tensor[Complex32], axis int, length int, norm FftNorm) !&vtl.Tensor[f32]

irfft_axis_norm_f32 applies inverse normalization when reconstructing one f32 axis.

fn irfft_f32 #

fn irfft_f32(input &vtl.Tensor[Complex32], length int) !&vtl.Tensor[f32]

irfft_f32 reconstructs a real f32 vector from compact f32 complex bins.

fn irfft_norm #

fn irfft_norm(input &vtl.Tensor[complex.Complex], length int, norm FftNorm) !&vtl.Tensor[f64]

irfft_norm reconstructs a real signal with an explicit inverse normalization mode.

fn irfft_norm_f32 #

fn irfft_norm_f32(input &vtl.Tensor[Complex32], length int, norm FftNorm) !&vtl.Tensor[f32]

irfft_norm_f32 reconstructs a real f32 signal with explicit inverse normalization.

fn irfftn #

fn irfftn(input &vtl.Tensor[complex.Complex], shape []int) !&vtl.Tensor[f64]

irfftn reconstructs a real tensor from a compact multidimensional spectrum. The original shape is required to disambiguate odd and even final axes.

fn irfftn_f32 #

fn irfftn_f32(input &vtl.Tensor[Complex32], shape []int) !&vtl.Tensor[f32]

irfftn_f32 reconstructs a real f32 tensor from its compact N-D spectrum.

fn irfftn_norm #

fn irfftn_norm(input &vtl.Tensor[complex.Complex], shape []int, norm FftNorm) !&vtl.Tensor[f64]

irfftn_norm reconstructs a real tensor with explicit N-dimensional normalization.

fn irfftn_norm_f32 #

fn irfftn_norm_f32(input &vtl.Tensor[Complex32], shape []int, norm FftNorm) !&vtl.Tensor[f32]

irfftn_norm_f32 reconstructs a real f32 tensor with explicit N-D normalization.

fn rfft #

fn rfft[T](input &vtl.Tensor[T]) !&vtl.Tensor[complex.Complex]

rfft computes the one-dimensional real-input discrete Fourier transform. It returns the non-negative frequencies as complex f64 values, matching the compact layout used by NumPy's rfft. Input tensors may contain f32 or f64.

fn rfft2 #

fn rfft2[T](input &vtl.Tensor[T]) !&vtl.Tensor[complex.Complex]

rfft2 computes a real-input two-dimensional Fourier transform.

fn rfft2_f32 #

fn rfft2_f32(input &vtl.Tensor[f32]) !&vtl.Tensor[Complex32]

rfft2_f32 computes a compact real f32 FFT for a two-dimensional tensor.

fn rfft2_norm #

fn rfft2_norm[T](input &vtl.Tensor[T], norm FftNorm) !&vtl.Tensor[complex.Complex]

rfft2_norm computes a compact two-dimensional real FFT with explicit normalization.

fn rfft2_norm_f32 #

fn rfft2_norm_f32(input &vtl.Tensor[f32], norm FftNorm) !&vtl.Tensor[Complex32]

rfft2_norm_f32 computes a normalized two-dimensional real f32 transform.

fn rfft_axis #

fn rfft_axis[T](input &vtl.Tensor[T], axis int) !&vtl.Tensor[complex.Complex]

rfft_axis computes a compact real-input Fourier transform along one axis. The selected dimension becomes floor(n/2)+1; other axes are unchanged.

fn rfft_axis_f32 #

fn rfft_axis_f32(input &vtl.Tensor[f32], axis int) !&vtl.Tensor[Complex32]

rfft_axis_f32 computes a compact real f32 FFT along one selected axis.

fn rfft_axis_norm #

fn rfft_axis_norm[T](input &vtl.Tensor[T], axis int, norm FftNorm) !&vtl.Tensor[complex.Complex]

rfft_axis_norm computes a selected-axis real FFT with explicit normalization.

fn rfft_axis_norm_f32 #

fn rfft_axis_norm_f32(input &vtl.Tensor[f32], axis int, norm FftNorm) !&vtl.Tensor[Complex32]

rfft_axis_norm_f32 computes a selected-axis real f32 FFT with normalization.

fn rfft_f32 #

fn rfft_f32(input &vtl.Tensor[f32]) !&vtl.Tensor[Complex32]

rfft_f32 computes a one-dimensional real f32 transform and returns compact f32 complex bins without promoting the spectrum to f64.

fn rfft_norm #

fn rfft_norm[T](input &vtl.Tensor[T], norm FftNorm) !&vtl.Tensor[complex.Complex]

rfft_norm computes a one-dimensional real FFT with an explicit normalization mode.

fn rfft_norm_f32 #

fn rfft_norm_f32(input &vtl.Tensor[f32], norm FftNorm) !&vtl.Tensor[Complex32]

rfft_norm_f32 computes a one-dimensional real f32 transform with normalization.

fn rfftfreq #

fn rfftfreq(n int, d f64) !&vtl.Tensor[f64]

rfftfreq returns the non-negative discrete Fourier Transform sample frequencies for a real-input transform of length n and sample spacing d.

fn rfftn #

fn rfftn[T](input &vtl.Tensor[T]) !&vtl.Tensor[complex.Complex]

rfftn computes a real-input Fourier transform across every tensor axis. The final axis is stored compactly, with length floor(n/2)+1.

fn rfftn_f32 #

fn rfftn_f32(input &vtl.Tensor[f32]) !&vtl.Tensor[Complex32]

rfftn_f32 computes a compact real f32 FFT over all tensor axes.

fn rfftn_norm #

fn rfftn_norm[T](input &vtl.Tensor[T], norm FftNorm) !&vtl.Tensor[complex.Complex]

rfftn_norm computes a compact real FFT over all input axes with explicit normalization.

fn rfftn_norm_f32 #

fn rfftn_norm_f32(input &vtl.Tensor[f32], norm FftNorm) !&vtl.Tensor[Complex32]

rfftn_norm_f32 computes a normalized real f32 transform over all axes.

fn (RealFftPlan[T]) forward #

fn (mut plan RealFftPlan[T]) forward(input &vtl.Tensor[T]) !&vtl.Tensor[complex.Complex]

forward computes a compact real FFT using the plan. The input length must match the plan length; a new output tensor is allocated for each call. The plan reuses an internal mutable work buffer, so calls on one plan must not run concurrently.

fn (RealFftPlan[T]) destroy #

fn (mut plan RealFftPlan[T]) destroy()

destroy releases the native PocketFFT plan. Repeated calls are safe.

enum FftNorm #

enum FftNorm {
	backward
	forward
	ortho
}

FftNorm selects the forward/inverse scaling convention used by NumPy.

struct Complex32 #

struct Complex32 {
pub:
	re f32
	im f32
}

Complex32 stores a single-precision complex value for FFT operations.

struct RealFftPlan #

struct RealFftPlan[T] {
pub:
	length int
mut:
	plan        vsl_fft.Fftplan
	destroyed   bool
	scratch_f32 []f32
	scratch_f64 []f64
}

RealFftPlan stores a reusable PocketFFT plan for one real input length. Call destroy when finished to release the native backend plan.

struct RealFftPlanF32 #

struct RealFftPlanF32 {
pub:
	length int
mut:
	plan      vsl_fft.Fftplan
	destroyed bool
	scratch   []f32
}

RealFftPlanF32 stores a reusable native plan for one real f32 vector length.

fn (RealFftPlanF32) forward #

fn (mut plan RealFftPlanF32) forward(input &vtl.Tensor[f32]) !&vtl.Tensor[Complex32]

forward computes a compact real f32 FFT, reusing the native plan and scratch. Calls on one plan are mutable and must not run concurrently.

fn (RealFftPlanF32) destroy #

fn (mut plan RealFftPlanF32) destroy()

destroy releases the native plan. Repeated calls are safe.