diff options
Diffstat (limited to 'lib/Data/Packed/Vector.hs')
-rw-r--r-- | lib/Data/Packed/Vector.hs | 35 |
1 files changed, 6 insertions, 29 deletions
diff --git a/lib/Data/Packed/Vector.hs b/lib/Data/Packed/Vector.hs index 867b77b..9818d58 100644 --- a/lib/Data/Packed/Vector.hs +++ b/lib/Data/Packed/Vector.hs | |||
@@ -13,33 +13,17 @@ | |||
13 | ----------------------------------------------------------------------------- | 13 | ----------------------------------------------------------------------------- |
14 | 14 | ||
15 | module Data.Packed.Vector ( | 15 | module Data.Packed.Vector ( |
16 | Vector(dim), Field, | 16 | Vector, |
17 | fromList, toList, | 17 | fromList, (|>), toList, |
18 | (@>), | 18 | dim, (@>), |
19 | subVector, join, | 19 | subVector, join, |
20 | constant, | 20 | constant, linspace, |
21 | toComplex, comp, | 21 | |
22 | conj, | ||
23 | dot, | ||
24 | linspace, | ||
25 | liftVector, liftVector2 | 22 | liftVector, liftVector2 |
26 | ) where | 23 | ) where |
27 | 24 | ||
28 | import Data.Packed.Internal | 25 | import Data.Packed.Internal |
29 | import Complex | 26 | import Complex |
30 | --import GSL.Vector | ||
31 | |||
32 | -- | creates a complex vector from vectors with real and imaginary parts | ||
33 | toComplex :: (Vector Double, Vector Double) -> Vector (Complex Double) | ||
34 | toComplex (r,i) = asComplex $ cdat $ fromColumns [r,i] | ||
35 | |||
36 | -- | obtains the complex conjugate of a complex vector | ||
37 | conj :: Vector (Complex Double) -> Vector (Complex Double) | ||
38 | conj v = asComplex $ cdat $ reshape 2 (asReal v) `mulC` diag (fromList [1,-1]) | ||
39 | where mulC = multiply RowMajor | ||
40 | |||
41 | comp :: Vector Double -> Vector (Complex Double) | ||
42 | comp v = toComplex (v,constant 0 (dim v)) | ||
43 | 27 | ||
44 | {- | Creates a real vector containing a range of values: | 28 | {- | Creates a real vector containing a range of values: |
45 | 29 | ||
@@ -47,12 +31,5 @@ comp v = toComplex (v,constant 0 (dim v)) | |||
47 | 5 |> [-3.0,-0.5,2.0,4.5,7.0]@ | 31 | 5 |> [-3.0,-0.5,2.0,4.5,7.0]@ |
48 | -} | 32 | -} |
49 | linspace :: Int -> (Double, Double) -> Vector Double | 33 | linspace :: Int -> (Double, Double) -> Vector Double |
50 | linspace n (a,b) = fromList [a::Double,a+delta .. b] | 34 | linspace n (a,b) = fromList [a, a+delta .. b] |
51 | where delta = (b-a)/(fromIntegral n -1) | 35 | where delta = (b-a)/(fromIntegral n -1) |
52 | |||
53 | |||
54 | dot :: (Field t) => Vector t -> Vector t -> t | ||
55 | dot u v = dat (multiply RowMajor r c) `at` 0 | ||
56 | where r = matrixFromVector RowMajor (dim u) u | ||
57 | c = matrixFromVector RowMajor 1 v | ||
58 | |||