diff options
author | Alberto Ruiz <aruiz@um.es> | 2008-11-05 14:01:11 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2008-11-05 14:01:11 +0000 |
commit | 2044be5a83d77536daed0f0f34d2baa6aa548dd1 (patch) | |
tree | e8ef80f329fe062ebc028e2fe4136cdce2ce8cb7 /lib/Data/Packed.hs | |
parent | 3161c13c508fb578bbc66156a609dbe4b991948d (diff) |
improved constant
Diffstat (limited to 'lib/Data/Packed.hs')
-rw-r--r-- | lib/Data/Packed.hs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/Data/Packed.hs b/lib/Data/Packed.hs index bb25c26..7d6d200 100644 --- a/lib/Data/Packed.hs +++ b/lib/Data/Packed.hs | |||
@@ -24,7 +24,7 @@ module Data.Packed ( | |||
24 | import Data.Packed.Vector | 24 | import Data.Packed.Vector |
25 | import Data.Packed.Matrix | 25 | import Data.Packed.Matrix |
26 | import Data.Complex | 26 | import Data.Complex |
27 | import Data.Packed.Internal(fromComplex,toComplex,comp,conj) | 27 | import Data.Packed.Internal(fromComplex,toComplex,conj) |
28 | 28 | ||
29 | -- | conversion utilities | 29 | -- | conversion utilities |
30 | class (Element e) => Container c e where | 30 | class (Element e) => Container c e where |
@@ -38,7 +38,7 @@ class (Element e) => Container c e where | |||
38 | instance Container Vector Double where | 38 | instance Container Vector Double where |
39 | toComplex = Data.Packed.Internal.toComplex | 39 | toComplex = Data.Packed.Internal.toComplex |
40 | fromComplex = Data.Packed.Internal.fromComplex | 40 | fromComplex = Data.Packed.Internal.fromComplex |
41 | comp = Data.Packed.Internal.comp | 41 | comp = internalcomp |
42 | conj = Data.Packed.Internal.conj | 42 | conj = Data.Packed.Internal.conj |
43 | real = id | 43 | real = id |
44 | complex = Data.Packed.comp | 44 | complex = Data.Packed.comp |
@@ -56,7 +56,7 @@ instance Container Matrix Double where | |||
56 | fromComplex z = (reshape c r, reshape c i) | 56 | fromComplex z = (reshape c r, reshape c i) |
57 | where (r,i) = Data.Packed.fromComplex (flatten z) | 57 | where (r,i) = Data.Packed.fromComplex (flatten z) |
58 | c = cols z | 58 | c = cols z |
59 | comp = liftMatrix Data.Packed.Internal.comp | 59 | comp = liftMatrix internalcomp |
60 | conj = liftMatrix Data.Packed.Internal.conj | 60 | conj = liftMatrix Data.Packed.Internal.conj |
61 | real = id | 61 | real = id |
62 | complex = Data.Packed.comp | 62 | complex = Data.Packed.comp |
@@ -68,3 +68,8 @@ instance Container Matrix (Complex Double) where | |||
68 | conj = undefined | 68 | conj = undefined |
69 | real = Data.Packed.comp | 69 | real = Data.Packed.comp |
70 | complex = id | 70 | complex = id |
71 | |||
72 | |||
73 | -- | converts a real vector into a complex representation (with zero imaginary parts) | ||
74 | internalcomp :: Vector Double -> Vector (Complex Double) | ||
75 | internalcomp v = Data.Packed.Internal.toComplex (v,constant 0 (dim v)) | ||