diff options
Diffstat (limited to 'lib/Data/Packed/Vector.hs')
-rw-r--r-- | lib/Data/Packed/Vector.hs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/Data/Packed/Vector.hs b/lib/Data/Packed/Vector.hs index ed0e49c..6f1096f 100644 --- a/lib/Data/Packed/Vector.hs +++ b/lib/Data/Packed/Vector.hs | |||
@@ -18,6 +18,7 @@ module Data.Packed.Vector ( | |||
18 | dim, (@>), | 18 | dim, (@>), |
19 | subVector, join, | 19 | subVector, join, |
20 | constant, linspace, | 20 | constant, linspace, |
21 | vecdisp, | ||
21 | vectorMax, vectorMin, vectorMaxIndex, vectorMinIndex, | 22 | vectorMax, vectorMin, vectorMaxIndex, vectorMinIndex, |
22 | mapVector, zipVector, | 23 | mapVector, zipVector, |
23 | fscanfVector, fprintfVector, freadVector, fwriteVector, | 24 | fscanfVector, fprintfVector, freadVector, fwriteVector, |
@@ -74,3 +75,19 @@ constant = constantD -- about 2x faster | |||
74 | buildVector :: Element a => Int -> (Int -> a) -> Vector a | 75 | buildVector :: Element a => Int -> (Int -> a) -> Vector a |
75 | buildVector len f = | 76 | buildVector len f = |
76 | fromList $ map f [0 .. (len - 1)] | 77 | fromList $ map f [0 .. (len - 1)] |
78 | |||
79 | |||
80 | {- | Show a vector using a function for showing matrices. | ||
81 | |||
82 | @disp = putStr . vecdisp ('dispf' 2) | ||
83 | |||
84 | \> disp ('linspace' 10 (0,1)) | ||
85 | 10 |> 0.00 0.11 0.22 0.33 0.44 0.56 0.67 0.78 0.89 1.00 | ||
86 | @ | ||
87 | -} | ||
88 | vecdisp :: (Element t) => (Matrix t -> String) -> Vector t -> String | ||
89 | vecdisp f v | ||
90 | = ((show (dim v) ++ " |> ") ++) . (++"\n") | ||
91 | . unwords . lines . tail . dropWhile (not . (`elem` " \n")) | ||
92 | . f . trans . reshape 1 | ||
93 | $ v | ||