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

Data.Array.Accelerate.Fourier.Planned

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, FromIntegral Int a, Num a, Ord 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, RealFloat a, FromIntegral Int a, Num a, Ord 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, RealFloat a, FromIntegral Int a, Num a, Ord 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, RealFloat a, FromIntegral Int a, Num a, Ord 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, RealFloat b, FromIntegral Int b, Num 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

 Source # MethodsshowsPrec :: Int -> Plan -> ShowS #show :: Plan -> String #showList :: [Plan] -> ShowS #

Plan transform algorithms for a certain array size.

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.

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) Source # MethodsshowsPrec :: Int -> Cache a -> ShowS #show :: Cache a -> String #showList :: [Cache a] -> ShowS #

cache :: (RealFloat a, FromIntegral Int a, Num a, Ord 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, FromIntegral Int b, Num 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, RealFloat 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.

data Direction Source #

Constructors

 Forward Inverse

Instances

 Source # Methods Source # Methods Source # MethodsshowList :: [Direction] -> ShowS #

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

# Miscellaneous

data Sign a Source #

Instances

 cst a => IsProduct cst (Sign a) Source # Associated Typestype ProdRepr (Sign a) :: * MethodsfromProd :: proxy cst -> Sign a -> ProdRepr (Sign a)toProd :: proxy cst -> ProdRepr (Sign a) -> Sign aprod :: proxy cst -> Sign a -> ProdR cst (ProdRepr (Sign a)) (Lift Exp a, Elt (Plain a)) => Lift Exp (Sign a) Source # Associated Typestype Plain (Sign a) :: * # Methodslift :: Sign a -> Exp (Plain (Sign a)) # Elt a => Unlift Exp (Sign (Exp a)) Source # Methodsunlift :: Exp (Plain (Sign (Exp a))) -> Sign (Exp a) # Eq a => Eq (Sign a) Source # Methods(==) :: Sign a -> Sign a -> Bool #(/=) :: Sign a -> Sign a -> Bool # Show a => Show (Sign a) Source # MethodsshowsPrec :: Int -> Sign a -> ShowS #show :: Sign a -> String #showList :: [Sign a] -> ShowS # Num a => Arbitrary (Sign a) Source # Methodsarbitrary :: Gen (Sign a) #shrink :: Sign a -> [Sign a] # Elt a => Elt (Sign a) Source # MethodseltType :: Sign a -> TupleType (EltRepr (Sign a))fromElt :: Sign a -> EltRepr (Sign a)toElt :: EltRepr (Sign a) -> Sign a type EltRepr (Sign a) Source # type EltRepr (Sign a) = EltRepr a type ProdRepr (Sign a) Source # type ProdRepr (Sign a) = ((), a) type Plain (Sign a) Source # type Plain (Sign a) = Sign (Plain a)

forward :: Num a => Sign a Source #

inverse :: Num a => Sign a Source #