summaryrefslogtreecommitdiff
path: root/lib/Data/Packed/Vector.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Data/Packed/Vector.hs')
-rw-r--r--lib/Data/Packed/Vector.hs35
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
15module Data.Packed.Vector ( 15module 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
28import Data.Packed.Internal 25import Data.Packed.Internal
29import Complex 26import Complex
30--import GSL.Vector
31
32-- | creates a complex vector from vectors with real and imaginary parts
33toComplex :: (Vector Double, Vector Double) -> Vector (Complex Double)
34toComplex (r,i) = asComplex $ cdat $ fromColumns [r,i]
35
36-- | obtains the complex conjugate of a complex vector
37conj :: Vector (Complex Double) -> Vector (Complex Double)
38conj v = asComplex $ cdat $ reshape 2 (asReal v) `mulC` diag (fromList [1,-1])
39 where mulC = multiply RowMajor
40
41comp :: Vector Double -> Vector (Complex Double)
42comp 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))
475 |> [-3.0,-0.5,2.0,4.5,7.0]@ 315 |> [-3.0,-0.5,2.0,4.5,7.0]@
48-} 32-}
49linspace :: Int -> (Double, Double) -> Vector Double 33linspace :: Int -> (Double, Double) -> Vector Double
50linspace n (a,b) = fromList [a::Double,a+delta .. b] 34linspace 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
54dot :: (Field t) => Vector t -> Vector t -> t
55dot u v = dat (multiply RowMajor r c) `at` 0
56 where r = matrixFromVector RowMajor (dim u) u
57 c = matrixFromVector RowMajor 1 v
58