diff options
Diffstat (limited to 'packages/gsl/src/Numeric/GSL/Fourier.hs')
-rw-r--r-- | packages/gsl/src/Numeric/GSL/Fourier.hs | 44 |
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 | {- | | ||
2 | Module : Numeric.GSL.Fourier | ||
3 | Copyright : (c) Alberto Ruiz 2006 | ||
4 | License : GPL | ||
5 | Maintainer : Alberto Ruiz | ||
6 | Stability : provisional | ||
7 | |||
8 | Fourier Transform. | ||
9 | |||
10 | <http://www.gnu.org/software/gsl/manual/html_node/Fast-Fourier-Transforms.html#Fast-Fourier-Transforms> | ||
11 | |||
12 | -} | ||
13 | |||
14 | module Numeric.GSL.Fourier ( | ||
15 | fft, | ||
16 | ifft | ||
17 | ) where | ||
18 | |||
19 | import Data.Packed | ||
20 | import Numeric.GSL.Internal | ||
21 | import Data.Complex | ||
22 | import Foreign.C.Types | ||
23 | import System.IO.Unsafe (unsafePerformIO) | ||
24 | |||
25 | genfft code v = unsafePerformIO $ do | ||
26 | r <- createVector (dim v) | ||
27 | app2 (c_fft code) vec v vec r "fft" | ||
28 | return r | ||
29 | |||
30 | foreign 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]) | ||
36 | fromList [10.0 :+ 0.0,(-2.0) :+ 2.0,(-2.0) :+ 0.0,(-2.0) :+ (-2.0)] | ||
37 | |||
38 | -} | ||
39 | fft :: Vector (Complex Double) -> Vector (Complex Double) | ||
40 | fft = genfft 0 | ||
41 | |||
42 | -- | The inverse of 'fft', using /gsl_fft_complex_inverse/. | ||
43 | ifft :: Vector (Complex Double) -> Vector (Complex Double) | ||
44 | ifft = genfft 1 | ||