From 7c5adb83c9cb632c39eb2d844a1496e2a7a23e8b Mon Sep 17 00:00:00 2001 From: Alberto Ruiz Date: Wed, 23 Apr 2014 14:19:34 +0200 Subject: join -> vjoin --- lib/Data/Packed/Internal/Matrix.hs | 2 +- lib/Data/Packed/Internal/Vector.hs | 14 +++++++------- lib/Data/Packed/Matrix.hs | 2 +- lib/Data/Packed/Vector.hs | 4 ++-- lib/Numeric/LinearAlgebra/Algorithms.hs | 2 +- lib/Numeric/LinearAlgebra/Util.hs | 4 ++-- lib/Numeric/LinearAlgebra/Util/Convolution.hs | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) (limited to 'lib') diff --git a/lib/Data/Packed/Internal/Matrix.hs b/lib/Data/Packed/Internal/Matrix.hs index 7504b39..5e6e649 100644 --- a/lib/Data/Packed/Internal/Matrix.hs +++ b/lib/Data/Packed/Internal/Matrix.hs @@ -154,7 +154,7 @@ toLists m = splitEvery (cols m) . toList . flatten $ m fromRows :: Element t => [Vector t] -> Matrix t fromRows vs = case compatdim (map dim vs) of Nothing -> error "fromRows applied to [] or to vectors with different sizes" - Just c -> reshape c . Data.Packed.Internal.Vector.join . map (adapt c) $ vs + Just c -> reshape c . vjoin . map (adapt c) $ vs where adapt c v | dim v == c = v | otherwise = constantD (v@>0) c diff --git a/lib/Data/Packed/Internal/Vector.hs b/lib/Data/Packed/Internal/Vector.hs index c99f4f0..e5c3196 100644 --- a/lib/Data/Packed/Internal/Vector.hs +++ b/lib/Data/Packed/Internal/Vector.hs @@ -16,7 +16,7 @@ module Data.Packed.Internal.Vector ( Vector, dim, fromList, toList, (|>), - Data.Packed.Internal.Vector.join, (@>), safe, at, at', subVector, takesV, + vjoin, (@>), safe, at, at', subVector, takesV, mapVector, mapVectorWithIndex, zipVectorWith, unzipVectorWith, mapVectorM, mapVectorM_, mapVectorWithIndexM, mapVectorWithIndexM_, foldVector, foldVectorG, foldLoop, foldVectorWithIndex, @@ -183,16 +183,16 @@ infixl 9 @> (@>) = at -{- | creates a new Vector by joining a list of Vectors +{- | concatenate a list of vectors -@> join [fromList [1..5], constant 1 3] +@> vjoin [fromList [1..5], constant 1 3] 8 |> [1.0,2.0,3.0,4.0,5.0,1.0,1.0,1.0]@ -} -join :: Storable t => [Vector t] -> Vector t -join [] = error "joining zero vectors" -join [v] = v -join as = unsafePerformIO $ do +vjoin :: Storable t => [Vector t] -> Vector t +vjoin [] = error "vjoin zero vectors" +vjoin [v] = v +vjoin as = unsafePerformIO $ do let tot = sum (map dim as) r <- createVector tot unsafeWith r $ \ptr -> diff --git a/lib/Data/Packed/Matrix.hs b/lib/Data/Packed/Matrix.hs index 1b67820..ab02670 100644 --- a/lib/Data/Packed/Matrix.hs +++ b/lib/Data/Packed/Matrix.hs @@ -103,7 +103,7 @@ breakAt c l = (a++[c],tail b) where joinVert :: Element t => [Matrix t] -> Matrix t joinVert ms = case common cols ms of Nothing -> error "(impossible) joinVert on matrices with different number of columns" - Just c -> reshape c $ join (map flatten ms) + Just c -> reshape c $ vjoin (map flatten ms) -- | creates a matrix from a horizontal list of matrices joinHoriz :: Element t => [Matrix t] -> Matrix t diff --git a/lib/Data/Packed/Vector.hs b/lib/Data/Packed/Vector.hs index dad5d28..a705ce4 100644 --- a/lib/Data/Packed/Vector.hs +++ b/lib/Data/Packed/Vector.hs @@ -19,7 +19,7 @@ module Data.Packed.Vector ( Vector, fromList, (|>), toList, buildVector, dim, (@>), - subVector, takesV, join, + subVector, takesV, vjoin, mapVector, mapVectorWithIndex, zipVector, zipVectorWith, unzipVector, unzipVectorWith, mapVectorM, mapVectorM_, mapVectorWithIndexM, mapVectorWithIndexM_, foldLoop, foldVector, foldVectorG, foldVectorWithIndex @@ -61,7 +61,7 @@ instance (Binary a, Storable a) => Binary (Vector a) where get = do d <- get vs <- mapM getVector $ chunks d - return $! join vs + return $! vjoin vs #endif diff --git a/lib/Numeric/LinearAlgebra/Algorithms.hs b/lib/Numeric/LinearAlgebra/Algorithms.hs index 4823cec..a3f541b 100644 --- a/lib/Numeric/LinearAlgebra/Algorithms.hs +++ b/lib/Numeric/LinearAlgebra/Algorithms.hs @@ -484,7 +484,7 @@ zh k v = fromList $ replicate (k-1) 0 ++ (1:drop k xs) where xs = toList v zt 0 v = v -zt k v = join [subVector 0 (dim v - k) v, konst 0 k] +zt k v = vjoin [subVector 0 (dim v - k) v, konst 0 k] unpackQR :: (Field t) => (Matrix t, Vector t) -> (Matrix t, Matrix t) diff --git a/lib/Numeric/LinearAlgebra/Util.hs b/lib/Numeric/LinearAlgebra/Util.hs index 532556e..f7c40d7 100644 --- a/lib/Numeric/LinearAlgebra/Util.hs +++ b/lib/Numeric/LinearAlgebra/Util.hs @@ -97,7 +97,7 @@ ones r c = konst 1 (r,c) -- | concatenation of real vectors infixl 3 & (&) :: Vector Double -> Vector Double -> Vector Double -a & b = Numeric.Container.join [a,b] +a & b = vjoin [a,b] -- | horizontal concatenation of real matrices infixl 3 ! @@ -206,7 +206,7 @@ vec = flatten . trans vech :: Element t => Matrix t -> Vector t -- ^ half-vectorization (of the lower triangular part) -vech m = Numeric.Container.join . zipWith f [0..] . toColumns $ m +vech m = vjoin . zipWith f [0..] . toColumns $ m where f k v = subVector k (dim v - k) v diff --git a/lib/Numeric/LinearAlgebra/Util/Convolution.hs b/lib/Numeric/LinearAlgebra/Util/Convolution.hs index 32cb188..be9b1eb 100644 --- a/lib/Numeric/LinearAlgebra/Util/Convolution.hs +++ b/lib/Numeric/LinearAlgebra/Util/Convolution.hs @@ -46,7 +46,7 @@ fromList [-1.0,0.0,1.0] conv ker v = corr ker' v' where ker' = (flatten.fliprl.asRow) ker - v' | dim ker > 1 = join [z,v,z] + v' | dim ker > 1 = vjoin [z,v,z] | otherwise = v z = constant 0 (dim ker -1) -- cgit v1.2.3