kernels

package
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 15, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SIMDNone   = planner.SIMDNone
	SIMDSSE2   = planner.SIMDSSE2
	SIMDAVX2   = planner.SIMDAVX2
	SIMDAVX512 = planner.SIMDAVX512
	SIMDNEON   = planner.SIMDNEON
)
View Source
const (
	KernelTypeCore = planner.KernelTypeCore
	KernelTypeDIT  = planner.KernelTypeDIT
)

KernelType constants for codelet classification.

View Source
const (
	KernelAuto      = fftypes.KernelAuto
	KernelDIT       = fftypes.KernelDIT
	KernelStockham  = fftypes.KernelStockham
	KernelBluestein = fftypes.KernelBluestein
)

Strategy constants.

Variables

View Source
var (
	Registry64  = planner.Registry64
	Registry128 = planner.Registry128
)

Re-export planner registries and SIMD constants.

View Source
var (
	ForwardDITComplex64  = forwardDITComplex64
	InverseDITComplex64  = inverseDITComplex64
	ForwardDITComplex128 = forwardDITComplex128
	InverseDITComplex128 = inverseDITComplex128
)

Precision-specific exports.

View Source
var (
	// Size 4.
	ForwardDIT4Radix4Complex64 = func(dst, src, twiddle, scratch []complex64) bool {
		return forwardDIT4Radix4Complex64(dst, src, twiddle, scratch)
	}
	InverseDIT4Radix4Complex64 = func(dst, src, twiddle, scratch []complex64) bool {
		return inverseDIT4Radix4Complex64(dst, src, twiddle, scratch)
	}
	// Size 8.
	ForwardDIT8Complex64       = forwardDIT8Complex64
	InverseDIT8Complex64       = inverseDIT8Complex64
	ForwardDIT8Radix8Complex64 = forwardDIT8Complex64
	InverseDIT8Radix8Complex64 = inverseDIT8Complex64
	ForwardDIT8Radix2Complex64 = func(dst, src, twiddle, scratch []complex64) bool {
		return forwardDIT8Radix2Complex64(dst, src, twiddle, scratch)
	}
	InverseDIT8Radix2Complex64 = func(dst, src, twiddle, scratch []complex64) bool {
		return inverseDIT8Radix2Complex64(dst, src, twiddle, scratch)
	}
	ForwardDIT8Radix4Complex64 = func(dst, src, twiddle, scratch []complex64) bool {
		return forwardDIT8Radix4Complex64(dst, src, twiddle, scratch)
	}
	InverseDIT8Radix4Complex64 = func(dst, src, twiddle, scratch []complex64) bool {
		return inverseDIT8Radix4Complex64(dst, src, twiddle, scratch)
	}
	// Size 16.
	ForwardDIT16Complex64       = forwardDIT16Complex64
	InverseDIT16Complex64       = inverseDIT16Complex64
	ForwardDIT16Radix4Complex64 = forwardDIT16Complex64
	InverseDIT16Radix4Complex64 = inverseDIT16Complex64
	ForwardDIT16Radix2Complex64 = func(dst, src, twiddle, scratch []complex64) bool {
		return forwardDIT16Radix2Complex64(dst, src, twiddle, scratch)
	}
	InverseDIT16Radix2Complex64 = func(dst, src, twiddle, scratch []complex64) bool {
		return inverseDIT16Radix2Complex64(dst, src, twiddle, scratch)
	}
	// Size 32.
	ForwardDIT32Complex64 = func(dst, src, twiddle, scratch []complex64) bool {
		return forwardDIT32Complex64(dst, src, twiddle, scratch)
	}
	InverseDIT32Complex64 = func(dst, src, twiddle, scratch []complex64) bool {
		return inverseDIT32Complex64(dst, src, twiddle, scratch)
	}
	// Size 64.
	ForwardDIT64Complex64       = forwardDIT64Complex64
	InverseDIT64Complex64       = inverseDIT64Complex64
	ForwardDIT64Radix4Complex64 = forwardDIT64Radix4Complex64
	InverseDIT64Radix4Complex64 = inverseDIT64Radix4Complex64
	// Size 128.
	ForwardDIT128Complex64 = forwardDIT128Complex64
	InverseDIT128Complex64 = inverseDIT128Complex64
	// Size 256.
	ForwardDIT256Complex64       = forwardDIT256Complex64
	InverseDIT256Complex64       = inverseDIT256Complex64
	ForwardDIT256Radix4Complex64 = forwardDIT256Radix4Complex64
	InverseDIT256Radix4Complex64 = inverseDIT256Radix4Complex64
	// Size 512.
	ForwardDIT512Complex64        = forwardDIT512Complex64
	InverseDIT512Complex64        = inverseDIT512Complex64
	ForwardDIT512Mixed24Complex64 = forwardDIT512Mixed24Complex64
	InverseDIT512Mixed24Complex64 = inverseDIT512Mixed24Complex64

	// Complex128 variants.
	ForwardDIT4Radix4Complex128 = func(dst, src, twiddle, scratch []complex128) bool {
		return forwardDIT4Radix4Complex128(dst, src, twiddle, scratch)
	}
	InverseDIT4Radix4Complex128 = func(dst, src, twiddle, scratch []complex128) bool {
		return inverseDIT4Radix4Complex128(dst, src, twiddle, scratch)
	}
	// Size 8.
	ForwardDIT8Complex128       = forwardDIT8Complex128
	InverseDIT8Complex128       = inverseDIT8Complex128
	ForwardDIT8Radix8Complex128 = forwardDIT8Complex128
	InverseDIT8Radix8Complex128 = inverseDIT8Complex128
	ForwardDIT8Radix2Complex128 = func(dst, src, twiddle, scratch []complex128) bool {
		return forwardDIT8Radix2Complex128(dst, src, twiddle, scratch)
	}
	InverseDIT8Radix2Complex128 = func(dst, src, twiddle, scratch []complex128) bool {
		return inverseDIT8Radix2Complex128(dst, src, twiddle, scratch)
	}
	ForwardDIT8Radix4Complex128 = func(dst, src, twiddle, scratch []complex128) bool {
		return forwardDIT8Radix4Complex128(dst, src, twiddle, scratch)
	}
	InverseDIT8Radix4Complex128 = func(dst, src, twiddle, scratch []complex128) bool {
		return inverseDIT8Radix4Complex128(dst, src, twiddle, scratch)
	}
	// Size 16.
	ForwardDIT16Complex128       = forwardDIT16Complex128
	InverseDIT16Complex128       = inverseDIT16Complex128
	ForwardDIT16Radix4Complex128 = forwardDIT16Complex128
	InverseDIT16Radix4Complex128 = inverseDIT16Complex128
	ForwardDIT16Radix2Complex128 = func(dst, src, twiddle, scratch []complex128) bool {
		return forwardDIT16Radix2Complex128(dst, src, twiddle, scratch)
	}
	InverseDIT16Radix2Complex128 = func(dst, src, twiddle, scratch []complex128) bool {
		return inverseDIT16Radix2Complex128(dst, src, twiddle, scratch)
	}
	ForwardDIT32Complex128 = func(dst, src, twiddle, scratch []complex128) bool {
		return forwardDIT32Complex128(dst, src, twiddle, scratch)
	}
	InverseDIT32Complex128 = func(dst, src, twiddle, scratch []complex128) bool {
		return inverseDIT32Complex128(dst, src, twiddle, scratch)
	}
	ForwardDIT64Complex128         = forwardDIT64Complex128
	InverseDIT64Complex128         = inverseDIT64Complex128
	ForwardDIT64Radix4Complex128   = forwardDIT64Radix4Complex128
	InverseDIT64Radix4Complex128   = inverseDIT64Radix4Complex128
	ForwardDIT128Complex128        = forwardDIT128Complex128
	InverseDIT128Complex128        = inverseDIT128Complex128
	ForwardDIT256Complex128        = forwardDIT256Complex128
	InverseDIT256Complex128        = inverseDIT256Complex128
	ForwardDIT256Radix4Complex128  = forwardDIT256Radix4Complex128
	InverseDIT256Radix4Complex128  = inverseDIT256Radix4Complex128
	ForwardDIT512Complex128        = forwardDIT512Complex128
	InverseDIT512Complex128        = inverseDIT512Complex128
	ForwardDIT512Mixed24Complex128 = forwardDIT512Mixed24Complex128
	InverseDIT512Mixed24Complex128 = inverseDIT512Mixed24Complex128
)

Size-specific DIT exports for benchmarks and tests.

View Source
var (
	ForwardStockhamComplex64  = forwardStockhamComplex64
	InverseStockhamComplex64  = inverseStockhamComplex64
	ForwardStockhamComplex128 = forwardStockhamComplex128
	InverseStockhamComplex128 = inverseStockhamComplex128
)

Precision-specific exports.

View Source
var (
	IsPowerOf2 = mathpkg.IsPowerOf2
)

Re-export math utilities used by kernels.

Functions

func BluesteinConvolution

func BluesteinConvolution[T Complex](dst, x, filter, twiddles, scratch []T)

BluesteinConvolution performs the convolution y = x * b via FFT. dst is the output buffer of size m. x is the input sequence of size m (padded with zeros). filter is the frequency-domain filter (FFT of b) of size m. twiddles are for size m. scratch is a scratch buffer of size m.

func Butterfly2

func Butterfly2[T Complex](a, b, w T) (T, T)

Butterfly2 performs a radix-2 butterfly operation.

func Butterfly3Forward

func Butterfly3Forward[T Complex](a0, a1, a2 T) (T, T, T)

Public exports for internal/fft - generic wrappers.

func Butterfly3ForwardComplex128 added in v0.5.0

func Butterfly3ForwardComplex128(a0, a1, a2 complex128) (complex128, complex128, complex128)

func Butterfly3ForwardComplex64 added in v0.5.0

func Butterfly3ForwardComplex64(a0, a1, a2 complex64) (complex64, complex64, complex64)

Public exports for internal/fft - type-specific functions for direct calls.

func Butterfly3Inverse

func Butterfly3Inverse[T Complex](a0, a1, a2 T) (T, T, T)

func Butterfly3InverseComplex128 added in v0.5.0

func Butterfly3InverseComplex128(a0, a1, a2 complex128) (complex128, complex128, complex128)

func Butterfly3InverseComplex64 added in v0.5.0

func Butterfly3InverseComplex64(a0, a1, a2 complex64) (complex64, complex64, complex64)

func Butterfly4Forward

func Butterfly4Forward[T Complex](a0, a1, a2, a3 T) (T, T, T, T)

Public exports for internal/fft - generic wrappers.

func Butterfly4ForwardComplex128 added in v0.5.0

func Butterfly4ForwardComplex128(a0, a1, a2, a3 complex128) (complex128, complex128, complex128, complex128)

func Butterfly4ForwardComplex64 added in v0.5.0

func Butterfly4ForwardComplex64(a0, a1, a2, a3 complex64) (complex64, complex64, complex64, complex64)

Public exports for internal/fft - type-specific functions for direct calls.

func Butterfly4Inverse

func Butterfly4Inverse[T Complex](a0, a1, a2, a3 T) (T, T, T, T)

func Butterfly4InverseComplex128 added in v0.5.0

func Butterfly4InverseComplex128(a0, a1, a2, a3 complex128) (complex128, complex128, complex128, complex128)

func Butterfly4InverseComplex64 added in v0.5.0

func Butterfly4InverseComplex64(a0, a1, a2, a3 complex64) (complex64, complex64, complex64, complex64)

func Butterfly5Forward

func Butterfly5Forward[T Complex](a0, a1, a2, a3, a4 T) (T, T, T, T, T)

Public exports for internal/fft - generic wrappers.

func Butterfly5ForwardComplex128 added in v0.5.0

func Butterfly5ForwardComplex128(a0, a1, a2, a3, a4 complex128) (complex128, complex128, complex128, complex128, complex128)

func Butterfly5ForwardComplex64 added in v0.5.0

func Butterfly5ForwardComplex64(a0, a1, a2, a3, a4 complex64) (complex64, complex64, complex64, complex64, complex64)

Public exports for internal/fft - type-specific functions for direct calls.

func Butterfly5Inverse

func Butterfly5Inverse[T Complex](a0, a1, a2, a3, a4 T) (T, T, T, T, T)

func Butterfly5InverseComplex128 added in v0.5.0

func Butterfly5InverseComplex128(a0, a1, a2, a3, a4 complex128) (complex128, complex128, complex128, complex128, complex128)

func Butterfly5InverseComplex64 added in v0.5.0

func Butterfly5InverseComplex64(a0, a1, a2, a3, a4 complex64) (complex64, complex64, complex64, complex64, complex64)

func ComputeBitReversalIndicesMixed128 added in v0.4.2

func ComputeBitReversalIndicesMixed128(n int) []int

ComputeBitReversalIndicesMixed128 computes bit-reversal indices for the AVX2 size-128 kernel.

The AVX2 size-128 kernel expects inputs in a specific order:

work[0] = x(0)
work[1] = x(32)
work[2] = x(64)
work[3] = x(96)

Standard binary reversal gives:

0 -> 0
1 -> 64
2 -> 32
3 -> 96

To match the kernel's expectation, we need to swap indices 1 and 2. This corresponds to swapping Bit 5 and Bit 6 of the bit-reversed value.

func ComputeBluesteinFilter

func ComputeBluesteinFilter[T Complex](n, m int, chirp []T, twiddles []T, scratch []T) []T

ComputeBluesteinFilter computes the frequency-domain filter for Bluestein's algorithm. n is the original size, m is the padded size (power of 2 >= 2n-1). chirp is the sequence of length n computed by ComputeChirpSequence. twiddles are for size m. scratch is a pre-allocated buffer of size m for intermediate computations.

func ComputeChirpSequence

func ComputeChirpSequence[T Complex](n int) []T

ComputeChirpSequence computes the chirp sequence W_n^(k^2/2) = exp(-j * pi * k^2 / n) The sequence is of length n.

func ComputeTwiddleFactors

func ComputeTwiddleFactors[T Complex](n int) []T

ComputeTwiddleFactors is a wrapper for the generic math function.

func DITForward

func DITForward[T Complex](dst, src, twiddle, scratch []T) bool

Public exports for internal/fft re-export.

func DITInverse

func DITInverse[T Complex](dst, src, twiddle, scratch []T) bool

func ForwardEightStepComplex128

func ForwardEightStepComplex128(dst, src, twiddle, scratch []complex128) bool

ForwardEightStepComplex128 performs a forward eight-step FFT on complex128 data.

func ForwardEightStepComplex64

func ForwardEightStepComplex64(dst, src, twiddle, scratch []complex64) bool

ForwardEightStepComplex64 performs a forward eight-step FFT on complex64 data.

func ForwardSixStepComplex128

func ForwardSixStepComplex128(dst, src, twiddle, scratch []complex128) bool

ForwardSixStepComplex128 performs a forward six-step FFT on complex128 data.

func ForwardSixStepComplex64

func ForwardSixStepComplex64(dst, src, twiddle, scratch []complex64) bool

ForwardSixStepComplex64 performs a forward six-step FFT on complex64 data.

func GetRegistry

func GetRegistry[T Complex]() *planner.CodeletRegistry[T]

GetRegistry returns the appropriate registry for type T.

func InverseEightStepComplex128

func InverseEightStepComplex128(dst, src, twiddle, scratch []complex128) bool

InverseEightStepComplex128 performs an inverse eight-step FFT on complex128 data.

func InverseEightStepComplex64

func InverseEightStepComplex64(dst, src, twiddle, scratch []complex64) bool

InverseEightStepComplex64 performs an inverse eight-step FFT on complex64 data.

func InverseSixStepComplex128

func InverseSixStepComplex128(dst, src, twiddle, scratch []complex128) bool

InverseSixStepComplex128 performs an inverse six-step FFT on complex128 data.

func InverseSixStepComplex64

func InverseSixStepComplex64(dst, src, twiddle, scratch []complex64) bool

InverseSixStepComplex64 performs an inverse six-step FFT on complex64 data.

func SameSlice

func SameSlice[T any](a, b []T) bool

SameSlice checks if two slices point to the same underlying array and have the same length. Useful for detecting in-place operations.

func StockhamForward

func StockhamForward[T Complex](dst, src, twiddle, scratch []T) bool

StockhamForward wraps the generic stockhamForward.

func StockhamInverse

func StockhamInverse[T Complex](dst, src, twiddle, scratch []T) bool

StockhamInverse wraps stockhamInverseComplex64/128.

Types

type CodeletEntry

type CodeletEntry[T Complex] = planner.CodeletEntry[T]

Type aliases for planner codelet types.

type CodeletFunc

type CodeletFunc[T Complex] = planner.CodeletFunc[T]

Type aliases for planner codelet types.

type Complex

type Complex = fftypes.Complex

Complex is a type alias for the complex number constraint.

type Kernel

type Kernel[T Complex] func(dst, src, twiddle, scratch []T) bool

Kernel reports whether it handled the transform. It returns false when no implementation is available.

type KernelFunc128

type KernelFunc128 func(dst, src, twiddle, scratch []complex128) bool

KernelFunc128 is the signature of existing complex128 kernels that return bool.

type KernelFunc64

type KernelFunc64 func(dst, src, twiddle, scratch []complex64) bool

KernelFunc64 is the signature of existing complex64 kernels that return bool.

type KernelStrategy

type KernelStrategy = fftypes.KernelStrategy

KernelStrategy is a type alias for the kernel strategy enum.

type Kernels

type Kernels[T Complex] struct {
	Forward Kernel[T]
	Inverse Kernel[T]
}

Kernels groups forward and inverse kernels for a given precision.

type RadixKernel

type RadixKernel[T Complex] struct {
	Name    string
	Radix   int
	Forward Kernel[T]
	Inverse Kernel[T]
}

RadixKernel describes a pluggable radix implementation for mixed-radix FFTs. Implementations should return false when they do not support the given length.

type SIMDLevel

type SIMDLevel = planner.SIMDLevel

Type aliases for planner codelet types.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL