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.hs13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/Data/Packed/Vector.hs b/lib/Data/Packed/Vector.hs
index 21f51e5..457da71 100644
--- a/lib/Data/Packed/Vector.hs
+++ b/lib/Data/Packed/Vector.hs
@@ -14,7 +14,7 @@
14 14
15module Data.Packed.Vector ( 15module Data.Packed.Vector (
16 Vector, 16 Vector,
17 fromList, (|>), toList, 17 fromList, (|>), toList, buildVector,
18 dim, (@>), 18 dim, (@>),
19 subVector, join, 19 subVector, join,
20 constant, linspace, 20 constant, linspace,
@@ -59,3 +59,14 @@ vectorMinIndex = round . toScalarR MinIdx
59constant :: Element a => a -> Int -> Vector a 59constant :: Element a => a -> Int -> Vector a
60-- constant x n = runSTVector (newVector x n) 60-- constant x n = runSTVector (newVector x n)
61constant = constantD -- about 2x faster 61constant = constantD -- about 2x faster
62
63{- | creates a Vector of the specified length using the supplied function to
64 to map the index to the value at that index.
65
66@> buildVector 4 fromIntegral
674 |> [0.0,1.0,2.0,3.0]@
68
69-}
70buildVector :: Element a => Int -> (Int -> a) -> Vector a
71buildVector len f =
72 fromList $ map f [0 .. (len - 1)]