-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Algorithms using the Repa array library.
--
-- NOTE: You must use the GHC head branch > 6.13.20100309 to get
-- decent performance. Reusable algorithms using the Repa array library.
@package repa-algorithms
@version 1.1.0.0
-- | Algorithms operating on matrices.
--
-- These functions should give performance comparable with nested loop C
-- implementations, but not block-based, cache friendly, SIMD using,
-- vendor optimised implementions. If you care deeply about runtime
-- performance then you may be better off using a binding to LAPACK, such
-- as hvector.
module Data.Array.Repa.Algorithms.Matrix
-- | Matrix-matrix multiply.
multiplyMM :: Array DIM2 Double -> Array DIM2 Double -> Array DIM2 Double
-- | Strict complex doubles.
module Data.Array.Repa.Algorithms.Complex
-- | Strict complex doubles.
type Complex = Double :*: Double
-- | Take the magnitude of a complex number.
mag :: Complex -> Double
-- | Take the argument (phase) of a complex number, in the range [-pi ..
-- pi].
arg :: Complex -> Double
-- | Strict pair
data (:*:) a b :: * -> * -> *
(:*:) :: !a -> !b -> :*: a b
instance Fractional Complex
instance Num Complex
-- | Calculation of roots of unity for the forward and inverse DFT/FFT.
module Data.Array.Repa.Algorithms.DFT.Roots
-- | Calculate roots of unity for the forward transform.
calcRootsOfUnity :: (Shape sh) => (sh :. Int) -> Array (sh :. Int) Complex
-- | Calculate roots of unity for the inverse transform.
calcInverseRootsOfUnity :: (Shape sh) => (sh :. Int) -> Array (sh :. Int) Complex
-- | Compute the Discrete Fourier Transform (DFT) along the low order
-- dimension of an array.
--
-- This uses the naive algorithm and takes O(n^2) time. However, you can
-- transform an array with an arbitray extent, unlike with FFT which
-- requires each dimension to be a power of two.
--
-- The dft and idft functions also compute the roots of
-- unity needed. If you need to transform several arrays with the same
-- extent then it is faster to compute the roots once using
-- calcRootsOfUnity or calcInverseRootsOfUnity, then call
-- dftWithRoots directly.
--
-- You can also compute single values of the transform using
-- dftWithRootsSingle.
module Data.Array.Repa.Algorithms.DFT
-- | Compute the DFT along the low order dimension of an array.
dft :: (Shape sh) => Array (sh :. Int) Complex -> Array (sh :. Int) Complex
-- | Compute the inverse DFT along the low order dimension of an array.
idft :: (Shape sh) => Array (sh :. Int) Complex -> Array (sh :. Int) Complex
-- | Generic function for computation of forward or inverse DFT. This
-- function is also useful if you transform many arrays with the same
-- extent, and don't want to recompute the roots for each one. The extent
-- of the given roots must match that of the input array, else
-- error.
dftWithRoots :: (Shape sh) => Array (sh :. Int) Complex -> Array (sh :. Int) Complex -> Array (sh :. Int) Complex
-- | Compute a single value of the DFT. The extent of the given roots must
-- match that of the input array, else error.
dftWithRootsSingle :: (Shape sh) => Array (sh :. Int) Complex -> Array (sh :. Int) Complex -> (sh :. Int) -> Complex
-- | Applying these transforms to the input of a DFT causes the output to
-- be centered so that the zero frequency is in the middle.
module Data.Array.Repa.Algorithms.DFT.Center
-- | Apply the centering transform to a vector.
centerVector :: Array DIM1 Complex -> Array DIM1 Complex
-- | Apply the centering transform to a matrix.
centerMatrix :: Array DIM2 Complex -> Array DIM2 Complex
-- | Fast computation of Discrete Fourier Transforms using the
-- Cooley-Tuckey algorithm.
--
-- Time complexity is O(n log n) in the size of the input.
--
-- Input dimensions must be powers of two, else error.
--
-- The fft and ifft functions (and friends) also compute
-- the roots of unity needed. If you need to transform several arrays
-- with the same extent then it is faster to compute the roots once using
-- calcRootsOfUnity or calcInverseRootsOfUnity, then call
-- fftWithRoots directly.
--
-- The inverse transforms provided also perform post-scaling so that
-- ifft is the true inverse of fft. If you don't want that
-- then call fftWithRoots directly.
--
-- The functions fft2d and fft3d require their inputs to be
-- squares (and cubes) respectively. This allows them to reuse the same
-- roots-of-unity when transforming along each axis. If you need to
-- transform rectanglular arrays then call fftWithRoots directly.
module Data.Array.Repa.Algorithms.FFT
-- | Compute the DFT along the low order dimension of an array.
fft :: (Shape sh) => Array (sh :. Int) Complex -> Array (sh :. Int) Complex
-- | Compute the inverse DFT along the low order dimension of an array.
ifft :: (Shape sh) => Array (sh :. Int) Complex -> Array (sh :. Int) Complex
-- | Compute the DFT of a square matrix. If the matrix is not square then
-- error.
fft2d :: Array DIM2 Complex -> Array DIM2 Complex
-- | Compute the inverse DFT of a square matrix.
ifft2d :: Array DIM2 Complex -> Array DIM2 Complex
-- | Compute the DFT of a 3d cube. If the array is not a cube then
-- error.
fft3d :: Array DIM3 Complex -> Array DIM3 Complex
-- | Compute the inverse DFT of a 3d cube. If the array is not a cube then
-- error.
ifft3d :: Array DIM3 Complex -> Array DIM3 Complex
-- | Generic function for computation of forward or inverse Discrete
-- Fourier Transforms. Computation is along the low order dimension of
-- the array.
fftWithRoots :: (Shape sh) => Array (sh :. Int) Complex -> Array (sh :. Int) Complex -> Array (sh :. Int) Complex