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