accelerate-fourier-0.0.1: Fast Fourier transform and convolution using the Accelerate framework

Safe HaskellNone
LanguageHaskell98

Data.Array.Accelerate.Fourier.Planned

Contents

Description

Like Data.Array.Accelerate.Fourier.Preprocessed this module allows to factor out some preprocessing. Additionally it gives you concrete objects (plans and caches) for sharing preprocessed data between transforms. You cannot only share the preprocessing between transforms of the same size, but across all array sizes. This implementation also has the largest collection of algorithms and thus should be generally fastest among all implementations in this package.

Synopsis

Transforms

type Transform sh a = Acc (Array sh a) -> Acc (Array sh a) Source

transform :: (Slice sh, Shape sh, RealFloat a, Elt a, IsFloating a) => Sign a -> Int -> Transform (sh :. Int) (Complex a) Source

Fourier transform of arbitrary size. Sign can be

  • forward: from time domain to frequency spectrum
  • inverse: from frequency spectrum to time domain

You may share transform sign n between several calls in order to run some preprocessing only once. You must make sure that the length is equal to the extent of the inner dimension of every transformed array.

transformDecompose :: (Slice sh, Shape sh, Elt a, IsFloating a, RealFloat a) => Sign a -> Int -> Transform (sh :. Int) (Complex a) Source

Transform using only Cooley-Tukey, Good-Thomas, Rader, Split-Radix, but no Bluestein. This is more for testing and benchmarking than for real use.

transformChirp2 :: (Slice sh, Shape sh, Elt a, IsFloating a, RealFloat a) => Sign a -> Int -> Transform (sh :. Int) (Complex a) Source

Fourier transform for arbitrary lengths based on the Bluestein transform or chirp z-transform on an array with power-of-two size. It may be faster than transform for certain prime factors. Find bad factors e.g. in http://oeis.org/A061092 and http://oeis.org/A059411 and nicer factors in http://oeis.org/A061303.

transformChirp235 :: (Slice sh, Shape sh, Elt a, IsFloating a, RealFloat a) => Sign a -> Int -> Transform (sh :. Int) (Complex a) Source

Fourier transform for arbitrary lengths based on the Bluestein transform on an array with 5-smooth size. (5-smooth = all prime factors are at most 5)

convolveCyclic :: (Shape sh, Slice sh, a ~ Complex b, Elt b, IsFloating b, RealFloat b) => Int -> Acc (Array (sh :. Int) a) -> Acc (Array (sh :. Int) a) -> Acc (Array (sh :. Int) a) Source

Signals must have equal size and must not be empty.

Planning

data Plan Source

Memorize factorizations of the data size and permutation vectors.

Instances

plan :: Integer -> Plan Source

Plan transform algorithms for a certain array size.

planWithMapUpdate :: Integer -> State PlanMap Plan Source

Too many nested Rader transformations slow down the transform, up to quadratic time in the worst case. As a heuristic we allow at most nesting depth two, and switch to Bluestein transformation otherwise. We could compute more precise operation counts and base our decision on these, but we found that the actual execution time differs considerably from the operation counts.

smallPlanMap :: PlanMap Source

Map of primitive transforms. You should use this as the initial map when evaluating a planning sequence using evalState.

Caching

data Cache a Source

Cache arrays of twiddle factors, i.e. powers of the primitive root of unity.

Instances

Elt a => Show (Cache a) 

cache :: (RealFloat a, Elt a, IsFloating a) => Sign a -> Int -> Cache (Complex a) Source

The expression cache sign len precomputes all data that is needed for Fourier transforms for signals of length len. You can use this cache in transformWithCache.

cacheDuplex :: (a ~ Complex b, RealFloat b, Elt b, IsFloating b) => Int -> (Cache a, Cache a) Source

It is (cache inverse x, cache forward x) = cacheDuplex x but cacheDuplex shares common data of both caches.

transformWithCache :: (Slice sh, Shape sh, Elt a, IsFloating a) => Cache (Complex a) -> Transform (sh :. Int) (Complex a) Source

The size and type of the signal must match the parameters, that the cache was generated for.

directionMode :: (Num a, Ord a) => Sign a -> Int -> (Direction, Sign a) Source

Miscellaneous

data Sign a Source

Instances

(Lift Exp a, Elt (Plain a)) => Lift Exp (Sign a) 
Elt a => Unlift Exp (Sign (Exp a)) 
Eq a => Eq (Sign a) 
Show a => Show (Sign a) 
Num a => Arbitrary (Sign a) 
IsTuple (Sign a) 
Elt a => Elt (Sign a) 
Typeable (* -> *) Sign 
type TupleRepr (Sign a) = ((), a) 
type EltRepr' (Sign a) = EltRepr' a 
type EltRepr (Sign a) = EltRepr a 
type Plain (Sign a) = Sign (Plain a)