Help us shape the future of Go! Take the 2026 Go Developer Survey

fft

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package fft is numpy.fft for ndarray arrays: the discrete Fourier transforms of go-fft (github.com/go-fft/fft), applied along any axes of an N-dimensional array, with numpy's n/s, axes and norm arguments and its dtypes.

Every transform takes an array of any dtype. As in NumPy 2, float32 and complex64 inputs are transformed in single precision and give complex64 (or float32 for the real inverses); every other dtype is transformed in double precision. Problems NumPy reports with an exception — an axis out of range or repeated, a length below one — are errors here.

Index

Constants

View Source
const (
	Backward = gofft.NormBackward
	Ortho    = gofft.NormOrtho
	Forward  = gofft.NormForward
)

The three scalings.

Variables

View Source
var ErrArgs = errors.New("fft: invalid arguments")

ErrArgs is returned for arguments numpy.fft rejects: an axis out of range, a length below one, S and Axes of different lengths, or a complex input to a transform of real signals. An axis listed twice is accepted, as NumPy accepts it: the transform runs along it twice.

Functions

func FFT

func FFT(a *ndarray.Array) (*ndarray.Array, error)

FFT is numpy.fft.fft: the 1-D discrete Fourier transform along the last axis.

func FFT2

func FFT2(a *ndarray.Array) (*ndarray.Array, error)

FFT2 is numpy.fft.fft2: the transform over the last two axes.

func FFT2With

func FFT2With(a *ndarray.Array, o Options) (*ndarray.Array, error)

FFT2With is numpy.fft.fft2(a, s, axes, norm).

func FFTFreq

func FFTFreq(n int, d float64) (*ndarray.Array, error)

FFTFreq is numpy.fft.fftfreq: the sample frequencies of an n-point FFT with sample spacing d.

func FFTN

func FFTN(a *ndarray.Array) (*ndarray.Array, error)

FFTN is numpy.fft.fftn: the transform over every axis.

func FFTNWith

func FFTNWith(a *ndarray.Array, o Options) (*ndarray.Array, error)

FFTNWith is numpy.fft.fftn(a, s, axes, norm).

func FFTShift

func FFTShift(a *ndarray.Array, axes ...int) (*ndarray.Array, error)

FFTShift is numpy.fft.fftshift: it rotates each of the given axes (every axis when none is given) by half its length, moving the zero frequency to the centre.

func FFTWith

func FFTWith(a *ndarray.Array, o Options) (*ndarray.Array, error)

FFTWith is numpy.fft.fft(a, n, axis, norm).

func HFFT

func HFFT(a *ndarray.Array) (*ndarray.Array, error)

HFFT is numpy.fft.hfft: the transform of a signal with Hermitian symmetry, given by its first half, which is real.

func HFFTWith

func HFFTWith(a *ndarray.Array, o Options) (*ndarray.Array, error)

HFFTWith is numpy.fft.hfft(a, n, axis, norm).

func IFFT

func IFFT(a *ndarray.Array) (*ndarray.Array, error)

IFFT is numpy.fft.ifft: the inverse of FFT.

func IFFT2

func IFFT2(a *ndarray.Array) (*ndarray.Array, error)

IFFT2 is numpy.fft.ifft2.

func IFFT2With

func IFFT2With(a *ndarray.Array, o Options) (*ndarray.Array, error)

IFFT2With is numpy.fft.ifft2(a, s, axes, norm).

func IFFTN

func IFFTN(a *ndarray.Array) (*ndarray.Array, error)

IFFTN is numpy.fft.ifftn.

func IFFTNWith

func IFFTNWith(a *ndarray.Array, o Options) (*ndarray.Array, error)

IFFTNWith is numpy.fft.ifftn(a, s, axes, norm).

func IFFTShift

func IFFTShift(a *ndarray.Array, axes ...int) (*ndarray.Array, error)

IFFTShift is numpy.fft.ifftshift, the inverse of FFTShift.

func IFFTWith

func IFFTWith(a *ndarray.Array, o Options) (*ndarray.Array, error)

IFFTWith is numpy.fft.ifft(a, n, axis, norm).

func IHFFT

func IHFFT(a *ndarray.Array) (*ndarray.Array, error)

IHFFT is numpy.fft.ihfft: the inverse of HFFT.

func IHFFTWith

func IHFFTWith(a *ndarray.Array, o Options) (*ndarray.Array, error)

IHFFTWith is numpy.fft.ihfft(a, n, axis, norm).

func IRFFT

func IRFFT(a *ndarray.Array) (*ndarray.Array, error)

IRFFT is numpy.fft.irfft: the inverse of RFFT, a real signal of length 2*(m-1) for m bins unless Options.S says otherwise.

func IRFFT2

func IRFFT2(a *ndarray.Array) (*ndarray.Array, error)

IRFFT2 is numpy.fft.irfft2.

func IRFFT2With

func IRFFT2With(a *ndarray.Array, o Options) (*ndarray.Array, error)

IRFFT2With is numpy.fft.irfft2(a, s, axes, norm).

func IRFFTN

func IRFFTN(a *ndarray.Array) (*ndarray.Array, error)

IRFFTN is numpy.fft.irfftn.

func IRFFTNWith

func IRFFTNWith(a *ndarray.Array, o Options) (*ndarray.Array, error)

IRFFTNWith is numpy.fft.irfftn(a, s, axes, norm).

func IRFFTWith

func IRFFTWith(a *ndarray.Array, o Options) (*ndarray.Array, error)

IRFFTWith is numpy.fft.irfft(a, n, axis, norm).

func RFFT

func RFFT(a *ndarray.Array) (*ndarray.Array, error)

RFFT is numpy.fft.rfft: the transform of a real signal along the last axis, keeping the n/2+1 non-negative frequencies. A complex input is an error, as in NumPy 2.

func RFFT2

func RFFT2(a *ndarray.Array) (*ndarray.Array, error)

RFFT2 is numpy.fft.rfft2.

func RFFT2With

func RFFT2With(a *ndarray.Array, o Options) (*ndarray.Array, error)

RFFT2With is numpy.fft.rfft2(a, s, axes, norm).

func RFFTFreq

func RFFTFreq(n int, d float64) (*ndarray.Array, error)

RFFTFreq is numpy.fft.rfftfreq: the n/2+1 non-negative frequencies of an n-point RFFT.

func RFFTN

func RFFTN(a *ndarray.Array) (*ndarray.Array, error)

RFFTN is numpy.fft.rfftn: the real transform runs along the last axis.

func RFFTNWith

func RFFTNWith(a *ndarray.Array, o Options) (*ndarray.Array, error)

RFFTNWith is numpy.fft.rfftn(a, s, axes, norm).

func RFFTWith

func RFFTWith(a *ndarray.Array, o Options) (*ndarray.Array, error)

RFFTWith is numpy.fft.rfft(a, n, axis, norm).

Types

type Norm

type Norm = gofft.Norm

Norm selects how a forward/inverse pair is scaled, as numpy.fft's norm argument does. The zero value, Backward, is numpy's default: the forward transform is unscaled and the inverse divides by n.

type Options

type Options struct {
	// S is numpy's n (for the 1-D transforms, one entry) or s (for the
	// others): the length of each transformed axis. The input is truncated or
	// zero-padded to it along that axis. For the real inverses (IRFFT,
	// IRFFTN, HFFT) it is the length of the real output along the last
	// transformed axis. nil keeps the input's lengths (and, for the real
	// inverses, 2*(m-1) along the last axis, m being its number of bins).
	S []int

	// Axes are the axes to transform; negative values count from the end.
	// nil means numpy's default: the last axis for the 1-D transforms, the
	// last two for the 2-D ones, all of them for the N-D ones (or the last
	// len(S) when S is set).
	Axes []int

	// Norm scales the result.
	Norm Norm
}

Options carries numpy.fft's optional arguments. Its zero value is numpy's defaults, so FFTWith(a, Options{}) is FFT(a).

Jump to

Keyboard shortcuts

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