summaryrefslogtreecommitdiff
path: root/lib/GSL/Fourier.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2007-06-16 15:52:07 +0000
committerAlberto Ruiz <aruiz@um.es>2007-06-16 15:52:07 +0000
commitb2af660f87a55dd15f4519b21e66837ec811dc25 (patch)
treef48a2dc5b1d996595e7cd69fbbff6397d3e7b600 /lib/GSL/Fourier.hs
parentcc2c8c39dc088dcace0d2749cfe9180bf5fdbfd2 (diff)
Fourier, minimization, polySolve
Diffstat (limited to 'lib/GSL/Fourier.hs')
-rw-r--r--lib/GSL/Fourier.hs46
1 files changed, 46 insertions, 0 deletions
diff --git a/lib/GSL/Fourier.hs b/lib/GSL/Fourier.hs
new file mode 100644
index 0000000..c8c79f0
--- /dev/null
+++ b/lib/GSL/Fourier.hs
@@ -0,0 +1,46 @@
1{-# OPTIONS_GHC -fglasgow-exts #-}
2-----------------------------------------------------------------------------
3{- |
4Module : 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 GSL.Fourier (
19 fft,
20 ifft
21) where
22
23import Data.Packed.Internal
24import Complex
25import Foreign
26
27genfft code v = unsafePerformIO $ do
28 r <- createVector (dim v)
29 c_fft code // vec v // vec r // check "fft" [v]
30 return r
31
32foreign import ccall "gsl-aux.h fft" c_fft :: Int -> Complex Double :> Complex Double :> IO Int
33
34
35{- | Fast 1D Fourier transform of a 'Vector' @(@'Complex' 'Double'@)@ using /gsl_fft_complex_forward/. It uses the same scaling conventions as GNU Octave.
36
37@> fft ('GSL.Matrix.fromList' [1,2,3,4])
38vector (4) [10.0 :+ 0.0,(-2.0) :+ 2.0,(-2.0) :+ 0.0,(-2.0) :+ (-2.0)]@
39
40-}
41fft :: Vector (Complex Double) -> Vector (Complex Double)
42fft = genfft 0
43
44-- | The inverse of 'fft', using /gsl_fft_complex_inverse/.
45ifft :: Vector (Complex Double) -> Vector (Complex Double)
46ifft = genfft 1