diff options
Diffstat (limited to 'lib/Data/Packed/Vector.hs')
-rw-r--r-- | lib/Data/Packed/Vector.hs | 13 |
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 | ||
15 | module Data.Packed.Vector ( | 15 | module 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 | |||
59 | constant :: Element a => a -> Int -> Vector a | 59 | constant :: Element a => a -> Int -> Vector a |
60 | -- constant x n = runSTVector (newVector x n) | 60 | -- constant x n = runSTVector (newVector x n) |
61 | constant = constantD -- about 2x faster | 61 | constant = 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 | ||
67 | 4 |> [0.0,1.0,2.0,3.0]@ | ||
68 | |||
69 | -} | ||
70 | buildVector :: Element a => Int -> (Int -> a) -> Vector a | ||
71 | buildVector len f = | ||
72 | fromList $ map f [0 .. (len - 1)] | ||