summaryrefslogtreecommitdiff
path: root/lib/Numeric/Container.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Numeric/Container.hs')
-rw-r--r--lib/Numeric/Container.hs10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/Numeric/Container.hs b/lib/Numeric/Container.hs
index b145a26..dea8a79 100644
--- a/lib/Numeric/Container.hs
+++ b/lib/Numeric/Container.hs
@@ -86,15 +86,19 @@ constant = constantD-- about 2x faster
86 86
87{- | Creates a real vector containing a range of values: 87{- | Creates a real vector containing a range of values:
88 88
89>>> linspace 5 (-3,7) 89>>> linspace 5 (-3,7::Double)
90fromList [-3.0,-0.5,2.0,4.5,7.0]@ 90fromList [-3.0,-0.5,2.0,4.5,7.0]@
91 91
92>>> linspace 5 (8,2+i) :: Vector (Complex Double)
93fromList [8.0 :+ 0.0,6.5 :+ 0.25,5.0 :+ 0.5,3.5 :+ 0.75,2.0 :+ 1.0]
94
92Logarithmic spacing can be defined as follows: 95Logarithmic spacing can be defined as follows:
93 96
94@logspace n (a,b) = 10 ** linspace n (a,b)@ 97@logspace n (a,b) = 10 ** linspace n (a,b)@
95-} 98-}
96linspace :: (Enum e, Container Vector e) => Int -> (e, e) -> Vector e 99linspace :: (Container Vector e) => Int -> (e, e) -> Vector e
97linspace n (a,b) = addConstant a $ scale s $ fromList [0 .. fromIntegral n-1] 100linspace 0 (a,b) = fromList[(a+b)/2]
101linspace n (a,b) = addConstant a $ scale s $ fromList $ map fromIntegral [0 .. n-1]
98 where s = (b-a)/fromIntegral (n-1) 102 where s = (b-a)/fromIntegral (n-1)
99 103
100-- | dot product: @cdot u v = 'udot' ('conj' u) v@ 104-- | dot product: @cdot u v = 'udot' ('conj' u) v@