fftw

package module
v0.0.0-...-37bfa0d Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2013 License: BSD-3-Clause Imports: 5 Imported by: 0

README

Go bindings for FFTW v3.2.2 Maintained by Jonathan Wills: runningwild@gmail.com Feel free to email me patches, suggestions or bugs.

FFTW homepage: http://www.fftw.org/ Documentation for the latest version: http://www.fftw.org/fftw3_doc/

These bindings are incomplete, but should include enough functionality that you can do whatever transforms you need (perhaps not as easily as you would like, for now). The function definitions do not mirror exactly what is written in the docs. For example, passing arrays does not require passing the size of the arrays, and there is no need to garbage collect plans.

Usage: Here is an example of doing a simple DFT with these bindings

data := fftw.Alloc1d(64)  // Similar to calling make([]complex128, 64)
forward  := fftw.PlanDft1d(data, data, fftw.Forward, fftw.Estimate)
backward := fftw.PlanDft1d(data, data, fftw.Backward, fftw.Estimate)
// ... fill in data with something interesting
forward.Execute()  // Transforms data, in place, to frequency domain
// ... do something interesting with data
backward.Execute()  // Returns data, in place, to time domain

Calling fftw.Alloc1d(64) allows FFTW to allocate the memory so that it is properly aligned to take advantage of SIMDs. You could just use make([]complex128, size) if you want.

Installation: When installing fftw you must compile it as a shared library:

./configure --enable-shared
make
make install

Once installed properly, these bindings can be installed like so:

go get github.com/runningwild/go-fftw

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Alloc1d

func Alloc1d(n int) []complex128

func Alloc2d

func Alloc2d(n0, n1 int) [][]complex128

func Alloc3d

func Alloc3d(n0, n1, n2 int) [][][]complex128

func Dft1d

func Dft1d(in, out []complex128, dir Direction, flag Flag)

func Dft2d

func Dft2d(in, out [][]complex128, dir Direction, flag Flag)

func Dft3d

func Dft3d(in, out [][][]complex128, dir Direction, flag Flag)

func Free1d

func Free1d(x []complex128)

func Free2d

func Free2d(x [][]complex128)

func Free3d

func Free3d(x [][][]complex128)

Types

type Direction

type Direction int
var Backward Direction = C.FFTW_BACKWARD
var Forward Direction = C.FFTW_FORWARD

type Flag

type Flag uint
var Estimate Flag = C.FFTW_ESTIMATE
var Measure Flag = C.FFTW_MEASURE

type Plan

type Plan struct {
	// contains filtered or unexported fields
}

func PlanDft1d

func PlanDft1d(in, out []complex128, dir Direction, flag Flag) *Plan

func PlanDft2d

func PlanDft2d(in, out [][]complex128, dir Direction, flag Flag) *Plan

func PlanDft3d

func PlanDft3d(in, out [][][]complex128, dir Direction, flag Flag) *Plan

func PlanDftC2R1d

func PlanDftC2R1d(in []complex128, out []float64, flag Flag) *Plan

Note: Executing this plan will destroy the data contained by in

func PlanDftR2C1d

func PlanDftR2C1d(in []float64, out []complex128, flag Flag) *Plan

TODO: Once we can create go arrays out of pre-existing data we can do these real-to-complex and complex-to-real

transforms in-place.

The real-to-complex and complex-to-real transforms save roughly a factor of two in time and space, with the following caveats:

  1. The real array is of size N, the complex array is of size N/2+1.
  2. The output array contains only the non-redundant output, the complete output is symmetric and the last half is the complex conjugate of the first half.
  3. Doing a complex-to-real transform destroys the input signal.

func (*Plan) Execute

func (p *Plan) Execute()

Jump to

Keyboard shortcuts

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