summaryrefslogtreecommitdiff
path: root/lib/Data/Packed.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Data/Packed.hs')
-rw-r--r--lib/Data/Packed.hs70
1 files changed, 70 insertions, 0 deletions
diff --git a/lib/Data/Packed.hs b/lib/Data/Packed.hs
new file mode 100644
index 0000000..668d2f7
--- /dev/null
+++ b/lib/Data/Packed.hs
@@ -0,0 +1,70 @@
1{-# OPTIONS_GHC -fglasgow-exts #-}
2-----------------------------------------------------------------------------
3{- |
4Module : Data.Packed
5Copyright : (c) Alberto Ruiz 2006-7
6License : GPL-style
7
8Maintainer : Alberto Ruiz (aruiz at um dot es)
9Stability : provisional
10Portability : uses ffi
11
12The Vector and Matrix types and some utilities.
13
14-}
15-----------------------------------------------------------------------------
16
17module Data.Packed (
18 module Data.Packed.Vector,
19 module Data.Packed.Matrix,
20 module Data.Complex,
21 Container(..)
22) where
23
24import Data.Packed.Vector
25import Data.Packed.Matrix
26import Data.Complex
27import Data.Packed.Internal
28
29-- | conversion utilities
30class (Field e) => Container c e where
31 toComplex :: RealFloat e => (c e, c e) -> c (Complex e)
32 fromComplex :: RealFloat e => c (Complex e) -> (c e, c e)
33 comp :: RealFloat e => c e -> c (Complex e)
34 conj :: RealFloat e => c (Complex e) -> c (Complex e)
35 real :: c Double -> c e
36 complex :: c e -> c (Complex Double)
37
38instance Container Vector Double where
39 toComplex = Data.Packed.Internal.toComplex
40 fromComplex = Data.Packed.Internal.fromComplex
41 comp = Data.Packed.Internal.comp
42 conj = Data.Packed.Internal.conj
43 real = id
44 complex = Data.Packed.comp
45
46instance Container Vector (Complex Double) where
47 toComplex = undefined -- can't match
48 fromComplex = undefined
49 comp = undefined
50 conj = undefined
51 real = Data.Packed.comp
52 complex = id
53
54instance Container Matrix Double where
55 toComplex = uncurry $ liftMatrix2 $ curry Data.Packed.toComplex
56 fromComplex z = (reshape c r, reshape c i)
57 where (r,i) = Data.Packed.fromComplex (cdat z)
58 c = cols z
59 comp = liftMatrix Data.Packed.Internal.comp
60 conj = liftMatrix Data.Packed.Internal.conj
61 real = id
62 complex = Data.Packed.comp
63
64instance Container Matrix (Complex Double) where
65 toComplex = undefined
66 fromComplex = undefined
67 comp = undefined
68 conj = undefined
69 real = Data.Packed.comp
70 complex = id