Safe Haskell | Safe-Infered |
---|

This module provides normalized versions of the transforms in `fftw`

.

All of the transforms are normalized so that

- Each transform is unitary, i.e., preserves the inner product and the sum-of-squares norm of its input.
- Each backwards transform is the inverse of the corresponding forwards transform.

(Both conditions only hold approximately, due to floating point precision.)

For more information on the underlying transforms, see http://www.fftw.org/fftw3_doc/What-FFTW-Really-Computes.html.

- run :: (Vector v a, Vector v b, Storable a, Storable b) => Transform a b -> v a -> v b
- plan :: (Storable a, Storable b) => Transform a b -> Int -> Plan a b
- execute :: (Vector v a, Vector v b, Storable a, Storable b) => Plan a b -> v a -> v b
- dft :: Transform (Complex Double) (Complex Double)
- idft :: Transform (Complex Double) (Complex Double)
- dftR2C :: Transform Double (Complex Double)
- dftC2R :: Transform (Complex Double) Double
- dct2 :: Transform Double Double
- idct2 :: Transform Double Double
- dct4 :: Transform Double Double

# Creating and executing `Plan`

s

run :: (Vector v a, Vector v b, Storable a, Storable b) => Transform a b -> v a -> v bSource

Create and run a `Plan`

for the given transform.

plan :: (Storable a, Storable b) => Transform a b -> Int -> Plan a bSource

Create a `Plan`

of a specific size. This function is equivalent to

.
`planOfType`

`Estimate`

execute :: (Vector v a, Vector v b, Storable a, Storable b) => Plan a b -> v a -> v bSource

Run a plan on the given `Vector`

.

If

, then calling
`planInputSize`

p /= length v`execute p v`

will throw an exception.

# Complex-to-complex transforms

dft :: Transform (Complex Double) (Complex Double)Source

A discrete Fourier transform. The output and input sizes are the same (`n`

).

y_k = (1/sqrt n) sum_(j=0)^(n-1) x_j e^(-2pi i j k/n)

idft :: Transform (Complex Double) (Complex Double)Source

An inverse discrete Fourier transform. The output and input sizes are the same (`n`

).

y_k = (1/sqrt n) sum_(j=0)^(n-1) x_j e^(2pi i j k/n)

# Real-to-complex transforms

dftR2C :: Transform Double (Complex Double)Source

A forward discrete Fourier transform with real data. If the input size is `n`

,
the output size will be `n `div` 2 + 1`

.

dftC2R :: Transform (Complex Double) DoubleSource

A normalized backward discrete Fourier transform which is the left inverse of
`dftR2C`

. (Specifically, `run dftC2R . run dftR2C == id`

.)

This `Transform`

behaves differently than the others:

- Calling
`plan dftC2R n`

creates a`Plan`

whose*output*size is`n`

, and whose*input*size is`n `div` 2 + 1`

. - If
`length v == n`

, then`length (run dftC2R v) == 2*(n-1)`

.

# Discrete cosine transforms

Some normalized real-even (DCT). The input and output sizes
are the same (`n`

).

dct2 :: Transform Double DoubleSource

A type-2 discrete cosine transform. Its inverse is `dct3`

.

`y_k = w(k) sum_(j=0)^(n-1) x_j cos(pi(j+1/2)k/n);`

where
`w(0)=1/sqrt n`

, and `w(k)=sqrt(2/n)`

for `k>0`

.