summaryrefslogtreecommitdiff
path: root/packages/hmatrix/src/Numeric/GSL/Fourier.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2014-05-08 08:48:12 +0200
committerAlberto Ruiz <aruiz@um.es>2014-05-08 08:48:12 +0200
commit1925c123d7d8184a1d2ddc0a413e0fd2776e1083 (patch)
treefad79f909d9c3be53d68e6ebd67202650536d387 /packages/hmatrix/src/Numeric/GSL/Fourier.hs
parenteb3f702d065a4a967bb754977233e6eec408fd1f (diff)
empty hmatrix-base
Diffstat (limited to 'packages/hmatrix/src/Numeric/GSL/Fourier.hs')
-rw-r--r--packages/hmatrix/src/Numeric/GSL/Fourier.hs47
1 files changed, 47 insertions, 0 deletions
diff --git a/packages/hmatrix/src/Numeric/GSL/Fourier.hs b/packages/hmatrix/src/Numeric/GSL/Fourier.hs
new file mode 100644
index 0000000..86aedd6
--- /dev/null
+++ b/packages/hmatrix/src/Numeric/GSL/Fourier.hs
@@ -0,0 +1,47 @@
1{-# LANGUAGE ForeignFunctionInterface #-}
2-----------------------------------------------------------------------------
3{- |
4Module : Numeric.GSL.Fourier
5Copyright : (c) Alberto Ruiz 2006
6License : GPL-style
7
8Maintainer : Alberto Ruiz (aruiz at um dot es)
9Stability : provisional
10Portability : uses ffi
11
12Fourier Transform.
13
14<http://www.gnu.org/software/gsl/manual/html_node/Fast-Fourier-Transforms.html#Fast-Fourier-Transforms>
15
16-}
17-----------------------------------------------------------------------------
18module Numeric.GSL.Fourier (
19 fft,
20 ifft
21) where
22
23import Data.Packed.Internal
24import Data.Complex
25import Foreign.C.Types
26import System.IO.Unsafe (unsafePerformIO)
27
28genfft code v = unsafePerformIO $ do
29 r <- createVector (dim v)
30 app2 (c_fft code) vec v vec r "fft"
31 return r
32
33foreign import ccall unsafe "gsl-aux.h fft" c_fft :: CInt -> TCVCV
34
35
36{- | Fast 1D Fourier transform of a 'Vector' @(@'Complex' 'Double'@)@ using /gsl_fft_complex_forward/. It uses the same scaling conventions as GNU Octave.
37
38>>> fft (fromList [1,2,3,4])
39fromList [10.0 :+ 0.0,(-2.0) :+ 2.0,(-2.0) :+ 0.0,(-2.0) :+ (-2.0)]
40
41-}
42fft :: Vector (Complex Double) -> Vector (Complex Double)
43fft = genfft 0
44
45-- | The inverse of 'fft', using /gsl_fft_complex_inverse/.
46ifft :: Vector (Complex Double) -> Vector (Complex Double)
47ifft = genfft 1