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