diff options
author | Alberto Ruiz <aruiz@um.es> | 2007-09-28 12:25:56 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2007-09-28 12:25:56 +0000 |
commit | 3815bc25f62124063e02af83fe3c907336dc86f5 (patch) | |
tree | 50fddcf4e66780272fdddf5515540e0f5d200feb /lib/Data/Packed.hs | |
parent | 74e7d42263b196c22d1f5da3d51beec69071600d (diff) |
algorithms interface reorganized
Diffstat (limited to 'lib/Data/Packed.hs')
-rw-r--r-- | lib/Data/Packed.hs | 70 |
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 | {- | | ||
4 | Module : Data.Packed | ||
5 | Copyright : (c) Alberto Ruiz 2006-7 | ||
6 | License : GPL-style | ||
7 | |||
8 | Maintainer : Alberto Ruiz (aruiz at um dot es) | ||
9 | Stability : provisional | ||
10 | Portability : uses ffi | ||
11 | |||
12 | The Vector and Matrix types and some utilities. | ||
13 | |||
14 | -} | ||
15 | ----------------------------------------------------------------------------- | ||
16 | |||
17 | module Data.Packed ( | ||
18 | module Data.Packed.Vector, | ||
19 | module Data.Packed.Matrix, | ||
20 | module Data.Complex, | ||
21 | Container(..) | ||
22 | ) where | ||
23 | |||
24 | import Data.Packed.Vector | ||
25 | import Data.Packed.Matrix | ||
26 | import Data.Complex | ||
27 | import Data.Packed.Internal | ||
28 | |||
29 | -- | conversion utilities | ||
30 | class (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 | |||
38 | instance 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 | |||
46 | instance 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 | |||
54 | instance 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 | |||
64 | instance 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 | ||