sparse 0.9.1 → 0.9.2
raw patch · 5 files changed
+24/−17 lines, 5 filesdep ~deepseqdep ~hybrid-vectorsdep ~primitive
Dependency ranges changed: deepseq, hybrid-vectors, primitive, vector-algorithms
Files
- CHANGELOG.markdown +5/−0
- sparse.cabal +5/−8
- src/Sparse/Matrix.hs +9/−9
- src/Sparse/Matrix/Internal/Array.hs +2/−0
- src/Sparse/Matrix/Internal/Key.hs +3/−0
CHANGELOG.markdown view
@@ -1,3 +1,8 @@+0.9.2+-----+* Rather dramatic memory usage reduction.+* Dependency bumps+ 0.9.1 ----- * `contravariant 1` support
sparse.cabal view
@@ -1,6 +1,6 @@ name: sparse category: Data, Vector-version: 0.9.1+version: 0.9.2 license: BSD3 cabal-version: >= 1.8 license-file: LICENSE@@ -60,13 +60,13 @@ build-depends: base >= 4 && < 5, contravariant >= 1 && < 2,- deepseq >= 1.1 && < 1.4,- hybrid-vectors >= 0.1 && < 1,+ deepseq >= 1.1 && < 1.5,+ hybrid-vectors >= 0.2 && < 3, lens >= 4 && < 5,- primitive >= 0.5 && < 0.6,+ primitive >= 0.5 && < 0.7, transformers >= 0.3 && < 0.5, vector >= 0.10 && < 0.11,- vector-algorithms >= 0.5 && < 0.7+ vector-algorithms >= 0.5 && < 0.8 hs-source-dirs: src @@ -146,9 +146,6 @@ mtl, semigroups >= 0.9, simple-reflect >= 0.3.1-- if impl(ghc<7.6.1)- ghc-options: -Werror -- matrix-matrix multiplication benchmark mm
src/Sparse/Matrix.hs view
@@ -67,8 +67,7 @@ import qualified Data.Vector.Hybrid as H import qualified Data.Vector.Hybrid.Internal as H import qualified Data.Vector.Unboxed as U-import Data.Vector.Fusion.Stream (Stream, sized)-import Data.Vector.Fusion.Stream.Size+import Data.Vector.Fusion.Stream (Stream) import Data.Word import Prelude hiding (head, last, null) import Sparse.Matrix.Internal.Fusion as Fusion@@ -176,12 +175,12 @@ (\(H.V (V_Key n xs ys) vs) -> Mat n xs ys vs) {-# INLINE _Mat #-} --- | Access the keys of a matrix+-- | Access the keys of the non-zero entries of our matrix keys :: Lens' (Mat a) (U.Vector Key) keys f (Mat n xs ys vs) = f (V_Key n xs ys) <&> \ (V_Key n' xs' ys') -> Mat n' xs' ys' vs {-# INLINE keys #-} --- | Access the keys of a matrix+-- | Access the values of the non-zero entries of our matrix values :: Lens (Mat a) (Mat b) (I.Array a) (I.Array b) values f (Mat n xs ys vs) = Mat n xs ys <$> f vs {-# INLINE values #-}@@ -336,14 +335,15 @@ multiplyWith times make x0 y0 = case compare (size x0) 1 of LT -> empty EQ | size y0 == 0 -> empty- | size y0 == 1 -> hinted $ go11 (lo x0) (head x0) (lo y0) (head y0)- | otherwise -> hinted $ go12 (lo x0) (head x0) (lo y0) y0 (hi y0)+ | size y0 == 1 -> unhinted $ go11 (lo x0) (head x0) (lo y0) (head y0)+ | otherwise -> unhinted $ go12 (lo x0) (head x0) (lo y0) y0 (hi y0) GT -> case compare (size y0) 1 of LT -> empty- EQ -> hinted $ go21 (lo x0) x0 (hi x0) (lo y0) (head y0)- GT -> hinted $ go22 (lo x0) x0 (hi x0) (lo y0) y0 (hi y0)+ EQ -> unhinted $ go21 (lo x0) x0 (hi x0) (lo y0) (head y0)+ GT -> unhinted $ go22 (lo x0) x0 (hi x0) (lo y0) y0 (hi y0) where- hinted x = _Mat # G.unstream (sized (make x) (Max (size x0 * size y0)))+ -- hinted x = _Mat # G.unstream (sized (make x) (Max (size x0 * size y0)))+ unhinted x = _Mat # G.unstream (make x) go11 (Key i j) a (Key j' k) b | j == j' = Just $ Heap.singleton (Key i k) (times a b)
src/Sparse/Matrix/Internal/Array.hs view
@@ -19,7 +19,9 @@ import Control.Monad import Data.Complex import Data.Int+#if __GLASGOW_HASKELL__ < 710 import Data.Monoid+#endif import qualified Data.Vector.Generic as G import qualified Data.Vector.Generic.Mutable as GM import qualified Data.Vector.Unboxed as U
src/Sparse/Matrix/Internal/Key.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE FlexibleInstances #-}@@ -48,7 +49,9 @@ import qualified Data.Vector.Generic as G import qualified Data.Vector.Generic.Mutable as GM import qualified Data.Vector.Unboxed as U+#if __GLASGOW_HASKELL__ < 710 import Data.Word+#endif -- * Morton Order