diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Data/Packed/Internal/Matrix.hs | 2 | ||||
-rw-r--r-- | lib/Data/Packed/Internal/Vector.hs | 2 | ||||
-rw-r--r-- | lib/Numeric/ContainerBoot.hs | 30 | ||||
-rw-r--r-- | lib/Numeric/LinearAlgebra/Util.hs | 4 |
4 files changed, 29 insertions, 9 deletions
diff --git a/lib/Data/Packed/Internal/Matrix.hs b/lib/Data/Packed/Internal/Matrix.hs index 255009c..7504b39 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 | |||
154 | fromRows :: Element t => [Vector t] -> Matrix t | 154 | fromRows :: Element t => [Vector t] -> Matrix t |
155 | fromRows vs = case compatdim (map dim vs) of | 155 | fromRows vs = case compatdim (map dim vs) of |
156 | Nothing -> error "fromRows applied to [] or to vectors with different sizes" | 156 | Nothing -> error "fromRows applied to [] or to vectors with different sizes" |
157 | Just c -> reshape c . join . map (adapt c) $ vs | 157 | Just c -> reshape c . Data.Packed.Internal.Vector.join . map (adapt c) $ vs |
158 | where | 158 | where |
159 | adapt c v | dim v == c = v | 159 | adapt c v | dim v == c = v |
160 | | otherwise = constantD (v@>0) c | 160 | | otherwise = constantD (v@>0) c |
diff --git a/lib/Data/Packed/Internal/Vector.hs b/lib/Data/Packed/Internal/Vector.hs index 85e7f4f..c99f4f0 100644 --- a/lib/Data/Packed/Internal/Vector.hs +++ b/lib/Data/Packed/Internal/Vector.hs | |||
@@ -16,7 +16,7 @@ | |||
16 | module Data.Packed.Internal.Vector ( | 16 | module Data.Packed.Internal.Vector ( |
17 | Vector, dim, | 17 | Vector, dim, |
18 | fromList, toList, (|>), | 18 | fromList, toList, (|>), |
19 | join, (@>), safe, at, at', subVector, takesV, | 19 | Data.Packed.Internal.Vector.join, (@>), safe, at, at', subVector, takesV, |
20 | mapVector, mapVectorWithIndex, zipVectorWith, unzipVectorWith, | 20 | mapVector, mapVectorWithIndex, zipVectorWith, unzipVectorWith, |
21 | mapVectorM, mapVectorM_, mapVectorWithIndexM, mapVectorWithIndexM_, | 21 | mapVectorM, mapVectorM_, mapVectorWithIndexM, mapVectorWithIndexM_, |
22 | foldVector, foldVectorG, foldLoop, foldVectorWithIndex, | 22 | foldVector, foldVectorG, foldLoop, foldVectorWithIndex, |
diff --git a/lib/Numeric/ContainerBoot.hs b/lib/Numeric/ContainerBoot.hs index d50dd36..dcb326c 100644 --- a/lib/Numeric/ContainerBoot.hs +++ b/lib/Numeric/ContainerBoot.hs | |||
@@ -510,20 +510,40 @@ type instance ElementOf (Matrix a) = a | |||
510 | class Build f where | 510 | class Build f where |
511 | build' :: BoundsOf f -> f -> ContainerOf f | 511 | build' :: BoundsOf f -> f -> ContainerOf f |
512 | 512 | ||
513 | type family BoundsOf x | ||
514 | 513 | ||
514 | #if MIN_VERSION_base(4,7,0) | ||
515 | -- ghc >= 7.7 considers: | ||
516 | -- | ||
517 | -- > a -> a | ||
518 | -- > b -> b -> b | ||
519 | -- | ||
520 | -- to overlap | ||
521 | type family BoundsOf x where | ||
522 | BoundsOf (a -> a) = Int | ||
523 | BoundsOf (a->a->a) = (Int,Int) | ||
524 | type family ContainerOf x where | ||
525 | ContainerOf (a->a) = Vector a | ||
526 | ContainerOf (a->a->a) = Matrix a | ||
527 | #else | ||
528 | type family BoundsOf x | ||
529 | type family ContainerOf x | ||
515 | type instance BoundsOf (a->a) = Int | 530 | type instance BoundsOf (a->a) = Int |
516 | type instance BoundsOf (a->a->a) = (Int,Int) | 531 | type instance BoundsOf (a->a->a) = (Int,Int) |
517 | |||
518 | type family ContainerOf x | ||
519 | |||
520 | type instance ContainerOf (a->a) = Vector a | 532 | type instance ContainerOf (a->a) = Vector a |
521 | type instance ContainerOf (a->a->a) = Matrix a | 533 | type instance ContainerOf (a->a->a) = Matrix a |
534 | #endif | ||
535 | |||
522 | 536 | ||
523 | instance (Element a, Num a) => Build (a->a) where | 537 | instance (Element a, Num a) => Build (a->a) where |
524 | build' = buildV | 538 | build' = buildV |
525 | 539 | ||
526 | instance (Element a, Num a) => Build (a->a->a) where | 540 | instance (Element a, |
541 | #if MIN_VERSION_base(4,7,0) | ||
542 | BoundsOf (a -> a -> a) ~ (Int,Int), | ||
543 | ContainerOf (a -> a -> a) ~ Matrix a, | ||
544 | #endif | ||
545 | Num a) | ||
546 | => Build (a->a->a) where | ||
527 | build' = buildM | 547 | build' = buildM |
528 | 548 | ||
529 | buildM (rc,cc) f = fromLists [ [f r c | c <- cs] | r <- rs ] | 549 | buildM (rc,cc) f = fromLists [ [f r c | c <- cs] | r <- rs ] |
diff --git a/lib/Numeric/LinearAlgebra/Util.hs b/lib/Numeric/LinearAlgebra/Util.hs index 39566ab..532556e 100644 --- a/lib/Numeric/LinearAlgebra/Util.hs +++ b/lib/Numeric/LinearAlgebra/Util.hs | |||
@@ -97,7 +97,7 @@ ones r c = konst 1 (r,c) | |||
97 | -- | concatenation of real vectors | 97 | -- | concatenation of real vectors |
98 | infixl 3 & | 98 | infixl 3 & |
99 | (&) :: Vector Double -> Vector Double -> Vector Double | 99 | (&) :: Vector Double -> Vector Double -> Vector Double |
100 | a & b = join [a,b] | 100 | a & b = Numeric.Container.join [a,b] |
101 | 101 | ||
102 | -- | horizontal concatenation of real matrices | 102 | -- | horizontal concatenation of real matrices |
103 | infixl 3 ! | 103 | infixl 3 ! |
@@ -206,7 +206,7 @@ vec = flatten . trans | |||
206 | 206 | ||
207 | vech :: Element t => Matrix t -> Vector t | 207 | vech :: Element t => Matrix t -> Vector t |
208 | -- ^ half-vectorization (of the lower triangular part) | 208 | -- ^ half-vectorization (of the lower triangular part) |
209 | vech m = join . zipWith f [0..] . toColumns $ m | 209 | vech m = Numeric.Container.join . zipWith f [0..] . toColumns $ m |
210 | where | 210 | where |
211 | f k v = subVector k (dim v - k) v | 211 | f k v = subVector k (dim v - k) v |
212 | 212 | ||