massiv 1.0.0.0 → 1.0.1.0
raw patch · 6 files changed
+145/−59 lines, 6 filesdep −template-haskellPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies removed: template-haskell
API changes (from Hackage documentation)
- Data.Massiv.Array.Mutable: computeInto :: (Size r', Load r' ix' e, Manifest r e, Index ix, MonadIO m) => MArray RealWorld r ix e -> Array r' ix' e -> m ()
+ Data.Massiv.Array.Mutable: computeInto :: (Load r' ix' e, Manifest r e, Index ix, MonadIO m) => MArray RealWorld r ix e -> Array r' ix' e -> m ()
Files
- CHANGELOG.md +5/−0
- massiv.cabal +9/−8
- src/Data/Massiv/Array/Manifest/Boxed.hs +25/−3
- src/Data/Massiv/Array/Mutable.hs +4/−3
- src/Data/Massiv/Vector.hs +101/−44
- tests/doctests.hs +1/−1
CHANGELOG.md view
@@ -1,3 +1,8 @@+# 1.0.1++* Relax constraint on `computeInto` by removing requirement for `Size`+* Fix `BL`, which due to a forgotten `seq` was not lazy.+ # 1.0.0 * Addition of `sumArrays'`, `sumArraysM` and `productArrays'`, `productArraysM`.
massiv.cabal view
@@ -1,5 +1,5 @@ name: massiv-version: 1.0.0.0+version: 1.0.1.0 synopsis: Massiv (Массив) is an Array Library. description: Multi-dimensional Arrays with fusion, stencils and parallel computation. homepage: https://github.com/lehins/massiv@@ -107,15 +107,16 @@ main-is: doctests.hs build-depends: base , doctest >=0.15- , QuickCheck- , massiv- , mersenne-random-pure64- , random >= 1.2.0- , mwc-random >= 0.15.0.1- , splitmix >= 0.0.1- , template-haskell+ if impl(ghc >= 8.2) && impl(ghc < 8.10)+ build-depends: QuickCheck+ , massiv+ , mersenne-random-pure64+ , random >= 1.2.0+ , mwc-random >= 0.15.0.1+ , splitmix >= 0.0.1 default-language: Haskell2010 source-repository head type: git location: https://github.com/lehins/massiv+ subdir: massiv
src/Data/Massiv/Array/Manifest/Boxed.hs view
@@ -85,8 +85,30 @@ -- Boxed Lazy -- ---------------- --- | Array representation for Boxed elements. This data structure is lazy with respect to--- its elements, but is strict with respect to the spine.+-- | Array representation for Boxed elements. This data structure is lazy with+-- respect to its elements, but is strict with respect to the spine.+--+-- ====__Example__+--+-- Memoized version of a factorial that relies on laziness. Note that+-- computing memoized factorial of a million would likely overflow memory.+--+-- >>> import Data.Massiv.Array as A+-- >>> :{+-- mkMemoFactorial :: Int -> (Int -> Integer)+-- mkMemoFactorial n =+-- let arr = makeVectorR BL Seq (Sz1 n) fact+-- fact i | i == 0 = 1+-- | otherwise = (arr ! (i - 1)) * toInteger i+-- in (arr !)+-- :}+--+-- >>> let fact = mkMemoFactorial 1000001+-- >>> fact 50+-- 30414093201713378043612608166064768844377641568960512000000000000+-- >>> length $ show $ fact 5000+-- 16326+-- data BL = BL deriving Show data instance Array BL ix e = BLArray { blComp :: !Comp@@ -177,7 +199,7 @@ SafeSz . A.sizeofMutableArray, A.readArray) ma (i + o) {-# INLINE unsafeLinearRead #-} - unsafeLinearWrite (MBLArray _sz o ma) i e = e `seq`+ unsafeLinearWrite (MBLArray _sz o ma) i e = INDEX_CHECK("(Manifest BL ix e).unsafeLinearWrite", SafeSz . A.sizeofMutableArray, A.writeArray) ma (i + o) e {-# INLINE unsafeLinearWrite #-}
src/Data/Massiv/Array/Mutable.hs view
@@ -409,14 +409,15 @@ -- -- @since 0.1.3 computeInto ::- (Size r', Load r' ix' e, Manifest r e, Index ix, MonadIO m)+ (Load r' ix' e, Manifest r e, Index ix, MonadIO m) => MArray RealWorld r ix e -- ^ Target Array -> Array r' ix' e -- ^ Array to load -> m () computeInto !mArr !arr = liftIO $ do- unless (totalElem (sizeOfMArray mArr) == totalElem (size arr)) $- throwM $ SizeElementsMismatchException (sizeOfMArray mArr) (size arr)+ let sz = outerSize arr+ unless (totalElem (sizeOfMArray mArr) == totalElem sz) $+ throwM $ SizeElementsMismatchException (sizeOfMArray mArr) sz withMassivScheduler_ (getComp arr) $ \scheduler -> stToPrim $ iterArrayLinearST_ scheduler arr (unsafeLinearWrite mArr) {-# INLINE computeInto #-}
src/Data/Massiv/Vector.hs view
@@ -1131,7 +1131,7 @@ sunfoldrN n f = DSArray . S.unfoldrN n f {-# INLINE sunfoldrN #-} --- | /O(n)/ - Same as `unfoldr`, but with monadic generating function.+-- | /O(n)/ - Same as `sunfoldr`, but with monadic generating function. -- -- ==== __Examples__ --@@ -1148,7 +1148,7 @@ sunfoldrM f = fromStepsM . S.unfoldrM f {-# INLINE sunfoldrM #-} --- | /O(n)/ - Same as `unfoldrN`, but with monadic generating function.+-- | /O(n)/ - Same as `sunfoldrN`, but with monadic generating function. -- -- ==== __Examples__ --@@ -1174,7 +1174,7 @@ {-# INLINE sunfoldrNM #-} --- | /O(n)/ - Similar to `unfoldrN`, except the length of the resulting vector will be exactly @n@+-- | /O(n)/ - Similar to `sunfoldrN`, except the length of the resulting vector will be exactly @n@ -- -- ==== __Examples__ --@@ -1187,7 +1187,7 @@ sunfoldrExactN n f = fromSteps . S.unfoldrExactN n f {-# INLINE sunfoldrExactN #-} --- | /O(n)/ - Similar to `unfoldrNM`, except the length of the resulting vector will be exactly @n@+-- | /O(n)/ - Similar to `sunfoldrNM`, except the length of the resulting vector will be exactly @n@ -- -- ==== __Examples__ --@@ -1697,8 +1697,8 @@ --- | Zip two arrays in a row-major order together together into a flat vector. Resulting--- length of a vector will be the smallest number of elements of the supplied arrays.+-- | Zip two vectors together into a vector. The length of a resulting vector will+-- be the smallest length of the supplied vectors. -- -- ==== __Examples__ --@@ -1711,7 +1711,8 @@ szip = szipWith (,) {-# INLINE szip #-} --- |+-- | Zip three vectors together into a vector. The length of a resulting vector will+-- be the smallest length of the supplied vectors. -- -- @since 0.5.0 szip3 ::@@ -1723,7 +1724,8 @@ szip3 = szipWith3 (,,) {-# INLINE szip3 #-} --- |+-- | Zip four vectors together into a vector. The length of a resulting vector will+-- be the smallest length of the supplied vectors. -- -- @since 0.5.0 szip4 ::@@ -1737,7 +1739,8 @@ szip4 = szipWith4 (,,,) {-# INLINE szip4 #-} --- |+-- | Zip five vectors together into a vector. The length of a resulting vector will+-- be the smallest length of the supplied vectors. -- -- @since 0.5.0 szip5 ::@@ -1752,7 +1755,8 @@ szip5 = szipWith5 (,,,,) {-# INLINE szip5 #-} --- |+-- | Zip six vectors together into a vector. The length of a resulting vector will+-- be the smallest length of the supplied vectors. -- -- @since 0.5.0 szip6 ::@@ -1777,9 +1781,8 @@ ----- |+-- | Zip two vectors together with a binary function into a vector. The length+-- of a resulting vector will be the smallest length of the supplied vectors. -- -- ==== __Examples__ --@@ -1794,7 +1797,8 @@ szipWith f v1 v2 = fromSteps $ S.zipWith f (S.toStream v1) (S.toStream v2) {-# INLINE szipWith #-} --- |+-- | Zip three vectors together with a ternary function into a vector. The length+-- of a resulting vector will be the smallest length of the supplied vectors. -- -- @since 0.5.0 szipWith3 ::@@ -1808,7 +1812,8 @@ szipWith3 f v1 v2 v3 = fromSteps $ S.zipWith3 f (S.toStream v1) (S.toStream v2) (S.toStream v3) {-# INLINE szipWith3 #-} --- |+-- | Zip four vectors together with a quaternary function into a vector. The length+-- of a resulting vector will be the smallest length of the supplied vectors. -- -- @since 0.5.0 szipWith4 ::@@ -1824,7 +1829,8 @@ fromSteps $ S.zipWith4 f (S.toStream v1) (S.toStream v2) (S.toStream v3) (S.toStream v4) {-# INLINE szipWith4 #-} --- |+-- | Zip five vectors together with a quinary function into a vector. The length+-- of a resulting vector will be the smallest length of the supplied vectors. -- -- @since 0.5.0 szipWith5 ::@@ -1842,7 +1848,8 @@ S.zipWith5 f (S.toStream v1) (S.toStream v2) (S.toStream v3) (S.toStream v4) (S.toStream v5) {-# INLINE szipWith5 #-} --- |+-- | Zip six vectors together with a senary function into a vector. The length+-- of a resulting vector will be the smallest length of the supplied vectors. -- -- @since 0.5.0 szipWith6 ::@@ -1874,7 +1881,9 @@ (S.toStream v6) {-# INLINE szipWith6 #-} --- |+-- | Just like `szipWith`, zip two vectors together, but with an index aware+-- function. The length of a resulting vector will be the smallest length of the+-- supplied vectors. -- -- ==== __Examples__ --@@ -1889,7 +1898,9 @@ sizipWith f v1 v2 = fromSteps $ S.zipWith (uncurry f) (S.toStreamIx v1) (S.toStream v2) {-# INLINE sizipWith #-} --- |+-- | Just like `szipWith3`, zip three vectors together, but with an index aware+-- function. The length of a resulting vector will be the smallest length of the+-- supplied vectors. -- -- @since 0.5.0 sizipWith3 ::@@ -1904,7 +1915,9 @@ fromSteps $ S.zipWith3 (uncurry f) (S.toStreamIx v1) (S.toStream v2) (S.toStream v3) {-# INLINE sizipWith3 #-} --- |+-- | Just like `szipWith4`, zip four vectors together, but with an index aware+-- function. The length of a resulting vector will be the smallest+-- length of the supplied vectors. -- -- @since 0.5.0 sizipWith4 ::@@ -1921,7 +1934,9 @@ S.zipWith4 (uncurry f) (S.toStreamIx v1) (S.toStream v2) (S.toStream v3) (S.toStream v4) {-# INLINE sizipWith4 #-} --- |+-- | Just like `szipWith5`, zip five vectors together, but with an index aware+-- function. The length of a resulting vector will be the smallest length of the+-- supplied vectors. -- -- @since 0.5.0 sizipWith5 ::@@ -1945,7 +1960,9 @@ (S.toStream v5) {-# INLINE sizipWith5 #-} --- |+-- | Just like `szipWith6`, zip six vectors together, but with an index aware+-- function. The length of a resulting vector will be the smallest length of the+-- supplied vectors. -- -- @since 0.5.0 sizipWith6 ::@@ -1978,7 +1995,9 @@ {-# INLINE sizipWith6 #-} --- |+-- | Zip two vectors together with a binary monadic action into a vector. The+-- length of a resulting vector will be the smallest length of the supplied+-- vectors. -- -- ==== __Examples__ --@@ -1993,7 +2012,9 @@ szipWithM f v1 v2 = fromStepsM $ S.zipWithM f (toStreamM v1) (toStreamM v2) {-# INLINE szipWithM #-} --- |+-- | Zip three vectors together with a ternary monadic action into a vector. The+-- length of a resulting vector will be the smallest length of the supplied+-- vectors. -- -- @since 0.5.0 szipWith3M ::@@ -2007,7 +2028,9 @@ szipWith3M f v1 v2 v3 = fromStepsM $ S.zipWith3M f (toStreamM v1) (toStreamM v2) (toStreamM v3) {-# INLINE szipWith3M #-} --- |+-- | Zip four vectors together with a quaternary monadic action into a vector. The+-- length of a resulting vector will be the smallest length of the supplied+-- vectors. -- -- @since 0.5.0 szipWith4M ::@@ -2023,7 +2046,9 @@ fromStepsM $ S.zipWith4M f (toStreamM v1) (toStreamM v2) (toStreamM v3) (toStreamM v4) {-# INLINE szipWith4M #-} --- |+-- | Zip five vectors together with a quinary monadic action into a vector. The+-- length of a resulting vector will be the smallest length of the supplied+-- vectors. -- -- @since 0.5.0 szipWith5M ::@@ -2047,7 +2072,9 @@ S.zipWith5M f (toStreamM v1) (toStreamM v2) (toStreamM v3) (toStreamM v4) (toStreamM v5) {-# INLINE szipWith5M #-} --- |+-- | Zip six vectors together with a senary monadic action into a vector. The+-- length of a resulting vector will be the smallest length of the supplied+-- vectors. -- -- @since 0.5.0 szipWith6M ::@@ -2081,7 +2108,9 @@ {-# INLINE szipWith6M #-} --- |+-- | Just like `szipWithM`, zip two vectors together, but with an index aware+-- monadic action. The length of a resulting vector will be the smallest length of the+-- supplied vectors. -- -- ==== __Examples__ --@@ -2097,7 +2126,9 @@ {-# INLINE sizipWithM #-} --- |+-- | Just like `szipWith3M`, zip three vectors together, but with an index aware+-- monadic action. The length of a resulting vector will be the smallest length of the+-- supplied vectors. -- -- @since 0.5.0 sizipWith3M ::@@ -2112,7 +2143,9 @@ fromStepsM $ S.zipWith3M (uncurry f) (toStreamIxM v1) (toStreamM v2) (toStreamM v3) {-# INLINE sizipWith3M #-} --- |+-- | Just like `szipWith4M`, zip four vectors together, but with an index aware+-- monadic action. The length of a resulting vector will be the smallest length of the+-- supplied vectors. -- -- @since 0.5.0 sizipWith4M ::@@ -2129,7 +2162,9 @@ S.zipWith4M (uncurry f) (toStreamIxM v1) (toStreamM v2) (toStreamM v3) (toStreamM v4) {-# INLINE sizipWith4M #-} --- |+-- | Just like `szipWith6M`, zip five vectors together, but with an index aware+-- monadic action. The length of a resulting vector will be the smallest length of the+-- supplied vectors. -- -- @since 0.5.0 sizipWith5M ::@@ -2159,7 +2194,9 @@ (toStreamM v5) {-# INLINE sizipWith5M #-} --- |+-- | Just like `szipWith6M`, zip six vectors together, but with an index aware+-- monadic action. The length of a resulting vector will be the smallest length of the+-- supplied vectors. -- -- ==== __Examples__ --@@ -2195,7 +2232,9 @@ {-# INLINE sizipWith6M #-} --- |+-- | Similar to `szipWithM`, zip two vectors together with a binary monadic+-- action, while discarding its result. The action will be invoked as many times as+-- the length of the smallest vector. -- -- ==== __Examples__ --@@ -2209,7 +2248,9 @@ szipWithM_ f v1 v2 = S.zipWithM_ f (toStreamM v1) (toStreamM v2) {-# INLINE szipWithM_ #-} --- |+-- | Similar to `szipWith3M`, zip three vectors together with a ternary monadic+-- action, while discarding its result. The action will be invoked as many times as+-- the length of the smallest vector. -- -- @since 0.5.0 szipWith3M_ ::@@ -2223,7 +2264,9 @@ szipWith3M_ f v1 v2 v3 = S.zipWith3M_ f (toStreamM v1) (toStreamM v2) (toStreamM v3) {-# INLINE szipWith3M_ #-} --- |+-- | Similar to `szipWith4M`, zip four vectors together with a quaternary monadic+-- action, while discarding its result. The action will be invoked as many times as+-- the length of the smallest vector. -- -- @since 0.5.0 szipWith4M_ ::@@ -2239,7 +2282,9 @@ S.zipWith4M_ f (toStreamM v1) (toStreamM v2) (toStreamM v3) (toStreamM v4) {-# INLINE szipWith4M_ #-} --- |+-- | Similar to `szipWith5M`, zip five vectors together with a quinary monadic+-- action, while discarding its result. The action will be invoked as many times as+-- the length of the smallest vector. -- -- @since 0.5.0 szipWith5M_ ::@@ -2262,7 +2307,9 @@ S.zipWith5M_ f (toStreamM v1) (toStreamM v2) (toStreamM v3) (toStreamM v4) (toStreamM v5) {-# INLINE szipWith5M_ #-} --- |+-- | Similar to `szipWith6M`, zip six vectors together with a senary monadic+-- action, while discarding its result. The action will be invoked as many times as+-- the length of the smallest vector. -- -- @since 0.5.0 szipWith6M_ ::@@ -2296,8 +2343,9 @@ ---- |+-- | Same as `szipWithM_`, zip two vectors together, but with an index aware+-- monadic action. The action will be invoked as many times as the length of the+-- smallest vector. -- -- ==== __Examples__ --@@ -2312,7 +2360,9 @@ {-# INLINE sizipWithM_ #-} --- |+-- | Same as `szipWith3M_`, zip three vectors together, but with an index aware+-- monadic action. The action will be invoked as many times as the length of the+-- smallest vector. -- -- @since 0.5.0 sizipWith3M_ ::@@ -2326,7 +2376,9 @@ sizipWith3M_ f v1 v2 v3 = S.zipWith3M_ (uncurry f) (toStreamIxM v1) (toStreamM v2) (toStreamM v3) {-# INLINE sizipWith3M_ #-} --- |+-- | Same as `szipWith4M_`, zip four vectors together, but with an index aware+-- monadic action. The action will be invoked as many times as the length of the+-- smallest vector. -- -- @since 0.5.0 sizipWith4M_ ::@@ -2342,7 +2394,9 @@ S.zipWith4M_ (uncurry f) (toStreamIxM v1) (toStreamM v2) (toStreamM v3) (toStreamM v4) {-# INLINE sizipWith4M_ #-} --- |+-- | Same as `szipWith5M_`, zip five vectors together, but with an index aware+-- monadic action. The action will be invoked as many times as the length of the+-- smallest vector. -- -- @since 0.5.0 sizipWith5M_ ::@@ -2371,7 +2425,9 @@ (toStreamM v5) {-# INLINE sizipWith5M_ #-} --- |+-- | Same as `szipWith6M_`, zip six vectors together, but with an index aware+-- monadic action. The action will be invoked as many times as the length of the+-- smallest vector. -- -- @since 0.5.0 sizipWith6M_ ::@@ -2407,7 +2463,8 @@ --- | Strict left fold sequentially over a streamed array.+-- | Streaming fold over an array in a row-major fashion with a left biased+-- function and a strict accumulator. -- -- ==== __Examples__ --
tests/doctests.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE CPP #-} module Main where -#if __GLASGOW_HASKELL__ >= 802 && __GLASGOW_HASKELL__ != 810+#if __GLASGOW_HASKELL__ >= 802 && __GLASGOW_HASKELL__ < 810 import Test.DocTest (doctest)