Documentation
¶
Overview ¶
Package fft provides numpy.fft-semantics discrete Fourier transforms over numgo arrays, backed by an own FFT: mixed-radix Cooley-Tukey + Bluestein for large primes.
Semantics follow numpy.fft (pocketfft): the forward transform is A_k = Σ_j a_j·exp(-2πi·jk/n), the last axis is transformed by default, arbitrary (mixed-radix) transform lengths are supported, n == 0 means "use the axis length" (Go's zero value stands in for numpy's None) and n > 0 zero-pads or truncates, and norm follows numpy's backward/ortho/forward modes with factors applied per transformed axis over the padded length n. IRFFT-family results are returned as float64 (the imaginary part is zero by construction, matching numpy's real output dtype). FFTShift/IFFTShift return pure copies, never views.
Index ¶
- func FFT[T numgo.Number](a *numgo.Array[T], n int, norm Norm, axes ...int) *numgo.Array[complex128]
- func FFT2[T numgo.Number](a *numgo.Array[T], s []int, norm Norm) *numgo.Array[complex128]
- func FFTFreq(n int, d float64) *numgo.Array[float64]
- func FFTN[T numgo.Number](a *numgo.Array[T], s []int, norm Norm, axes ...int) *numgo.Array[complex128]
- func FFTShift[T numgo.Number](a *numgo.Array[T], axes ...int) *numgo.Array[T]
- func HFFT(a *numgo.Array[complex128], n int, norm Norm, axes ...int) *numgo.Array[float64]
- func IFFT[T numgo.Number](a *numgo.Array[T], n int, norm Norm, axes ...int) *numgo.Array[complex128]
- func IFFT2[T numgo.Number](a *numgo.Array[T], s []int, norm Norm) *numgo.Array[complex128]
- func IFFTN[T numgo.Number](a *numgo.Array[T], s []int, norm Norm, axes ...int) *numgo.Array[complex128]
- func IFFTShift[T numgo.Number](a *numgo.Array[T], axes ...int) *numgo.Array[T]
- func IHFFT[T numgo.Float](a *numgo.Array[T], n int, norm Norm, axes ...int) *numgo.Array[complex128]
- func IRFFT(a *numgo.Array[complex128], n int, norm Norm, axes ...int) *numgo.Array[float64]
- func IRFFT2(a *numgo.Array[complex128], s []int, norm Norm) *numgo.Array[float64]
- func IRFFTN(a *numgo.Array[complex128], s []int, norm Norm, axes ...int) *numgo.Array[float64]
- func RFFT[T numgo.Float](a *numgo.Array[T], n int, norm Norm, axes ...int) *numgo.Array[complex128]
- func RFFT2[T numgo.Float](a *numgo.Array[T], s []int, norm Norm) *numgo.Array[complex128]
- func RFFTFreq(n int, d float64) *numgo.Array[float64]
- func RFFTN[T numgo.Float](a *numgo.Array[T], s []int, norm Norm, axes ...int) *numgo.Array[complex128]
- type Norm
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FFT ¶
FFT transforms a along one axis (default last). n == 0 uses the axis length; n > 0 zero-pads or truncates. Full-spectrum complex128 output.
func FFT2 ¶
FFT2 transforms the last two axes (numpy fft2's default (-2,-1)). s == nil or s[i] <= 0 uses the axis length; positive s[i] pads/truncates.
func FFTFreq ¶
FFTFreq returns n sample frequencies in cycles per unit of the sample spacing d: [0, 1, ..., n/2-1, -n/2, ..., -1] / (n*d).
func FFTN ¶
func FFTN[T numgo.Number](a *numgo.Array[T], s []int, norm Norm, axes ...int) *numgo.Array[complex128]
FFTN transforms along the given axes (default: all axes). s aligns with axes: s == nil or s[i] <= 0 uses the axis length; positive s[i] zero-pads or truncates that axis.
func FFTShift ¶
FFTShift shifts the zero-frequency component to the center by rolling each listed axis (default: all) by n//2. The result is a pure copy.
func HFFT ¶
HFFT is the inverse of IHFFT: a complex Hermitian half-spectrum in, real float64 output of length n (n == 0 means 2*(m-1)).
func IFFT ¶
func IFFT[T numgo.Number](a *numgo.Array[T], n int, norm Norm, axes ...int) *numgo.Array[complex128]
IFFT is the inverse of FFT. n == 0 uses the axis length; n > 0 zero-pads or truncates the input.
func IFFTN ¶
func IFFTN[T numgo.Number](a *numgo.Array[T], s []int, norm Norm, axes ...int) *numgo.Array[complex128]
IFFTN is the inverse of FFTN with the same s/axes conventions.
func IFFTShift ¶
IFFTShift is the inverse of FFTShift: it rolls each listed axis by -n/2. Identical to FFTShift for even-length axes. The result is a pure copy.
func IHFFT ¶
func IHFFT[T numgo.Float](a *numgo.Array[T], n int, norm Norm, axes ...int) *numgo.Array[complex128]
IHFFT is the inverse of HFFT: real input, complex conjugated half-spectrum output of length n//2+1 (numpy's ihfft; the input must be real, as in numpy where complex input raises TypeError).
func IRFFT ¶
IRFFT inverts RFFT: complex half-spectrum input, real float64 output of length n (n == 0 means 2*(m-1) for input length m along the axis).
func IRFFTN ¶
IRFFTN is the inverse of RFFTN; the last listed axis is the half-spectrum (default output length there is 2*(m-1)), the rest are full complex axes. The result is a real float64 array.
func RFFT ¶
RFFT is the FFT of real input along one axis, returning the non-negative frequency half-spectrum of length n//2+1 (including the Nyquist bin).
func RFFT2 ¶
RFFT2 is the two-dimensional real FFT along the last two axes; the last output axis holds the half-spectrum n//2+1.
func RFFTFreq ¶
RFFTFreq returns the non-negative frequencies of RFFT output: [0, 1, ..., n/2] / (n*d).
func RFFTN ¶
func RFFTN[T numgo.Float](a *numgo.Array[T], s []int, norm Norm, axes ...int) *numgo.Array[complex128]
RFFTN is the n-dimensional real FFT: RFFT along the last listed axis, then FFT along the others. Like numpy, the real-input RFFT runs first so the remaining transforms operate on the complex half-spectrum.
Types ¶
type Norm ¶
type Norm int
Norm selects the normalization of a forward/backward transform pair, mirroring numpy.fft's norm argument. Backward (numpy's default) scales the forward transform by 1 and the inverse by 1/n; Forward is the mirror image; Ortho scales both by 1/√n. n is the resolved transform length, including any zero padding.