Safe Haskell | None |
---|---|
Language | Haskell98 |
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.
- type Transform sh a = Acc (Array sh a) -> Acc (Array sh a)
- transform :: (Slice sh, Shape sh, RealFloat a, FromIntegral Int a, Num a, Ord a) => Sign a -> Int -> Transform (sh :. Int) (Complex a)
- transformDecompose :: (Slice sh, Shape sh, RealFloat a, FromIntegral Int a, Num a, Ord a) => Sign a -> Int -> Transform (sh :. Int) (Complex a)
- transformChirp2 :: (Slice sh, Shape sh, RealFloat a, FromIntegral Int a, Num a, Ord a) => Sign a -> Int -> Transform (sh :. Int) (Complex a)
- transformChirp235 :: (Slice sh, Shape sh, RealFloat a, FromIntegral Int a, Num a, Ord a) => Sign a -> Int -> Transform (sh :. Int) (Complex a)
- 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)
- data Plan
- plan :: Integer -> Plan
- transformWithPlanner :: (Slice sh, Shape sh, RealFloat a, FromIntegral Int a, Num a, Ord a) => (Integer -> State PlanMap Plan) -> Sign a -> Int -> Transform (sh :. Int) (Complex a)
- type PlanMap = Map Integer Plan
- planWithMapUpdate :: Integer -> State PlanMap Plan
- planDecomposeWithMapUpdate :: Integer -> State PlanMap Plan
- planChirpWithMapUpdate :: (Integer -> Integer) -> Integer -> State PlanMap Plan
- smallPlanMap :: PlanMap
- data Cache a
- cache :: (RealFloat a, FromIntegral Int a, Num a, Ord a) => Sign a -> Int -> Cache (Complex a)
- cacheDuplex :: (a ~ Complex b, RealFloat b, FromIntegral Int b, Num b) => Int -> (Cache a, Cache a)
- transformWithCache :: (Slice sh, Shape sh, RealFloat a) => Cache (Complex a) -> Transform (sh :. Int) (Complex a)
- type CacheMap a = Map (Integer, Direction) (Cache a)
- data Direction
- cacheFromPlanWithMapUpdate :: (a ~ Complex b, RealFloat b, FromIntegral Int b, Num b) => Plan -> (Direction, Sign b) -> State (CacheMap a) (Cache a)
- directionMode :: (Num a, Ord a) => Sign a -> Int -> (Direction, Sign a)
- cacheFromPlanWithMapUpdate2 :: (a ~ Complex b, RealFloat b, FromIntegral Int b, Num b) => (Plan, Plan) -> ((Direction, Sign b), (Direction, Sign b)) -> State (CacheMap a) (Cache a, Cache a)
- directionModes :: Num a => Int -> ((Direction, Sign a), (Direction, Sign a))
- data Sign a
- forward :: Num a => Sign a
- inverse :: Num a => Sign a
Transforms
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 spectruminverse
: 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
Memorize factorizations of the data size and permutation vectors.
transformWithPlanner :: (Slice sh, Shape sh, RealFloat a, FromIntegral Int a, Num a, Ord a) => (Integer -> State PlanMap Plan) -> Sign a -> Int -> Transform (sh :. Int) (Complex a) Source #
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
Cache arrays of twiddle factors, i.e. powers of the primitive root of unity.
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.
cacheFromPlanWithMapUpdate :: (a ~ Complex b, RealFloat b, FromIntegral Int b, Num b) => Plan -> (Direction, Sign b) -> State (CacheMap a) (Cache a) Source #
cacheFromPlanWithMapUpdate2 :: (a ~ Complex b, RealFloat b, FromIntegral Int b, Num b) => (Plan, Plan) -> ((Direction, Sign b), (Direction, Sign b)) -> State (CacheMap a) (Cache a, Cache a) Source #
Miscellaneous
cst a => IsProduct cst (Sign a) Source # | |
(Lift Exp a, Elt (Plain a)) => Lift Exp (Sign a) Source # | |
Elt a => Unlift Exp (Sign (Exp a)) Source # | |
Eq a => Eq (Sign a) Source # | |
Show a => Show (Sign a) Source # | |
Num a => Arbitrary (Sign a) Source # | |
Elt a => Elt (Sign a) Source # | |
type EltRepr (Sign a) Source # | |
type ProdRepr (Sign a) Source # | |
type Plain (Sign a) Source # | |