fftwRaw-0.1.0.0: Low level bindings to FFTW.

Safe HaskellSafe
LanguageHaskell2010

Numeric.FFTW

Contents

Description

Bindings to FFTW.

Example usage:

import Foreign.Marshal.Array
import Data.Complex
import Foreign.Storable.Complex
import FFTW

main = do
    inA  <- fftwAllocComplex 1024
    outA <- fftwAllocComplex 1024

    plan <- planDFT1d 1024 inA outA Forward fftwEstimate

    pokeArray inA $ map (:+ 0) [0..1023]
    execute plan
    res <- peekArray 1024 outA

    fftwFree inA
    fftwFree outA

    print res

Synopsis

Memory allocation functions

fftwMalloc Source

Arguments

:: Word32

size

-> IO (Ptr a) 

Like malloc, but ensures that the pointer obeys the alignment restrictions of FFTW (e.g. for SIMD acceleration). You probably want to use fftwAllocReal or fftwAllocComplex instead.

fftwFree Source

Arguments

:: Ptr a

the pointer to be freed

-> IO () 

Free a pointer returned by fftwMalloc, fftwAllocReal, or fftwAllocComplex

fftwFreePtr :: FunPtr (Ptr a -> IO ()) Source

A function pointer to fftwFree.

fftwAllocReal Source

Arguments

:: Word32

size

-> IO (Ptr CDouble) 

Allocates an array of Doubles. It ensures that the pointer obeys the alignment restrictions of FFTW (e.g. for SIMD acceleration).

fftwAllocComplex Source

Arguments

:: Word32

size

-> IO (Ptr (Complex CDouble)) 

Allocates an array of complex Doubles (i.e. the c type "double complex"). It ensures that the pointer obeys the alignment restrictions of FFTW (e.g. for SIMD acceleration).

FFT planning flags

data Direction Source

The direction of the transform: Forward for a normal transform, Backward for an inverse transform

Constructors

Forward 
Backward 

data Flag Source

FFTW planner flags. These flags affect the planning process. They can be combined using the Monoid instance. See the FFTW flag documentation: http://www.fftw.org/doc/Planner-Flags.html.

Instances

Planning rigor flags

Algorithm restriction flags

FFT planning

data FFTWPlan i o Source

A FFTWPlan i o contains all of the information necessary to perform a transform from an input array of type i to an output array of type o, including pointers to the input and output arrays.

planDFT1d Source

Arguments

:: Int

size

-> Ptr (Complex CDouble)

input pointer

-> Ptr (Complex CDouble)

output pointer

-> Direction

direction

-> Flag

planner flags

-> IO (FFTWPlan (Complex CDouble) (Complex CDouble)) 

Create a plan for a 1 dimensional complex to complex DFT. The plan stores pointers to the input and output arrays, and these will be used if you execute the plan in the future. They are required even if you intend to specify different input and output arrays in the future (i.e. using executeDFT)

planDFTR2C1d Source

Arguments

:: Int

size

-> Ptr CDouble

input pointer

-> Ptr (Complex CDouble)

output pointer

-> Flag

planner flags

-> IO (FFTWPlan CDouble (Complex CDouble)) 

Create a plan for a 1 dimensional real to complex DFT. The plan stores pointers to the input and output arrays, and these will be used if you execute the plan in the future. They are required even if you intend to specify different input and output arrays in the future (i.e. using executeDFTR2C)

FFT execution

execute Source

Arguments

:: FFTWPlan i o

the plan to execute

-> IO () 

Execute a plan. Performs an FFT. The input and output arrays are stored within the plan so do not need to be given.

executeDFT Source

Arguments

:: FFTWPlan (Complex CDouble) (Complex CDouble)

the plan to execute

-> Ptr (Complex CDouble)

input pointer

-> Ptr (Complex CDouble)

output pointer

-> IO () 

Execute a complex to complex DFT but on different input and output arrays to those specified when the plan was created.

executeDFTR2C Source

Arguments

:: FFTWPlan CDouble (Complex CDouble)

the plan to execute

-> Ptr CDouble

input pointer

-> Ptr (Complex CDouble)

output pointer

-> IO () 

Execute a real to complex DFT but on different input and output arrays to those specified when the plan was created.