massiv 1.0.1.0 → 1.0.1.1
raw patch · 8 files changed
+66/−46 lines, 8 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Data.Massiv.Core: -- | State token type
+ Data.Massiv.Core: -- | State token type.
Files
- massiv.cabal +12/−6
- src/Data/Massiv/Array.hs +2/−2
- src/Data/Massiv/Array/Manifest/Boxed.hs +5/−6
- src/Data/Massiv/Array/Manifest/Storable.hs +7/−4
- src/Data/Massiv/Array/Ops/Transform.hs +4/−5
- src/Data/Massiv/Array/Unsafe.hs +2/−2
- src/Data/Massiv/Core/Common.hs +2/−2
- src/Data/Massiv/Vector.hs +32/−19
massiv.cabal view
@@ -1,5 +1,5 @@ name: massiv-version: 1.0.1.0+version: 1.0.1.1 synopsis: Massiv (Массив) is an Array Library. description: Multi-dimensional Arrays with fusion, stencils and parallel computation. homepage: https://github.com/lehins/massiv@@ -13,13 +13,12 @@ extra-source-files: README.md , CHANGELOG.md cabal-version: >=1.10-tested-with: GHC == 8.4.3+tested-with: GHC == 8.0.2+ , GHC == 8.2.2 , GHC == 8.4.4- , GHC == 8.6.3- , GHC == 8.6.4 , GHC == 8.6.5 , GHC == 8.8.4- , GHC == 8.10.2+ , GHC == 8.10.7 , GHC == 9.0.1 flag unsafe-checks@@ -97,9 +96,16 @@ default-language: Haskell2010 ghc-options: -Wall -Wincomplete-record-updates- -Wincomplete-uni-patterns -Wredundant-constraints+ if impl(ghc >= 8.2)+ ghc-options: -Wno-simplifiable-class-constraints+ -Wincomplete-uni-patterns+ else+ ghc-options:+ -Wno-incomplete-patterns+ -Wno-unused-imports+ -Wno-unrecognised-pragmas test-suite doctests type: exitcode-stdio-1.0
src/Data/Massiv/Array.hs view
@@ -20,11 +20,11 @@ -- element is a pointer to the actual value, therefore it is also the slowest -- representation. Elements are kept in a Weak Head Normal Form (WHNF). ----- * `BN` - Similar to `B`, is also a boxed type, except it's elements are always kept in a Normal+-- * `BN` - Similar to `B`, it is also a boxed type, except its elements are always kept in a Normal -- Form (NF). This property is very useful for parallel processing, i.e. when calling -- `compute` you do want all of your elements to be fully evaluated. ----- * `BL` - Similar to `B`, is also a boxed type, but lazy. It's elements are not evaluated when+-- * `BL` - Similar to `B`, it is also a boxed type, but lazy. Its elements are not evaluated when -- array is computed. -- -- * `S` - Is a type of array that is backed by pinned memory, therefore pointers to those arrays
src/Data/Massiv/Array/Manifest/Boxed.hs view
@@ -86,7 +86,7 @@ ---------------- -- | Array representation for Boxed elements. This data structure is lazy with--- respect to its elements, but is strict with respect to the spine.+-- respect to its elements. -- -- ====__Example__ --@@ -294,8 +294,8 @@ -- Boxed Strict -- ------------------ --- | Array representation for Boxed elements. This structure is element and--- spine strict, but elements are strict to Weak Head Normal Form (WHNF) only.+-- | Array representation for Boxed elements. Its elements are strict to Weak+-- Head Normal Form (WHNF) only. data B = B deriving Show newtype instance Array B ix e = BArray (Array BL ix e)@@ -458,9 +458,8 @@ -- Boxed Normal Form -- ----------------------- --- | Array representation for Boxed elements. This structure is element and--- spine strict, and elements are always in Normal Form (NF), therefore `NFData`--- instance is required.+ -- | Array representation for Boxed elements. Its elements are always in Normal+-- Form (NF), therefore `NFData` instance is required. data BN = BN deriving Show -- | Type and pattern `N` have been added for backwards compatibility and will be replaced
src/Data/Massiv/Array/Manifest/Storable.hs view
@@ -48,18 +48,18 @@ import Data.Massiv.Core.List import Data.Massiv.Core.Operations import Data.Massiv.Vector.Stream as S (isteps, steps)-import Data.Primitive.Ptr (setPtr) import Data.Primitive.ByteArray+import Data.Primitive.Ptr (setPtr)+import Data.Word import Foreign.ForeignPtr import Foreign.Marshal.Alloc import Foreign.Marshal.Array (advancePtr, copyArray) import Foreign.Ptr import Foreign.Storable-import GHC.Exts as GHC (IsList(..))+import GHC.Exts as GHC import GHC.ForeignPtr import Prelude hiding (mapM) import System.IO.Unsafe (unsafePerformIO)-import Data.Word import Unsafe.Coerce import qualified Data.Vector.Generic.Mutable as MVG@@ -104,8 +104,11 @@ setComp c arr = arr { sComp = c } {-# INLINE setComp #-} +plusFp :: ForeignPtr a -> Int -> ForeignPtr b+plusFp (ForeignPtr addr c) (I# d) = ForeignPtr (plusAddr# addr d) c+ advanceForeignPtr :: forall e . Storable e => ForeignPtr e -> Int -> ForeignPtr e-advanceForeignPtr fp i = plusForeignPtr fp (i * sizeOf (undefined :: e))+advanceForeignPtr fp i = plusFp fp (i * sizeOf (undefined :: e)) {-# INLINE advanceForeignPtr #-} indexForeignPtr :: Storable e => ForeignPtr e -> Int -> e
src/Data/Massiv/Array/Ops/Transform.hs view
@@ -77,8 +77,7 @@ import Data.Massiv.Array.Ops.Map import Data.Massiv.Core import Data.Massiv.Core.Index.Internal-import Data.Massiv.Core.Common (size, unsafeIndex, unsafeResize, evaluate', evaluateM)-import Data.Proxy+import Data.Massiv.Core.Common --(size, unsafeIndex, unsafeResize, evaluate', evaluateM) import Prelude as P hiding (concat, drop, mapM_, reverse, splitAt, take, traverse) @@ -796,7 +795,7 @@ -- | /O(1)/ - Split an array into two at an index along a specified dimension. ----- /Related/: `splitAt'`, `splitExtractM`, `Data.Massiv.Vector.sliceAt'`, `Data.Massiv.Vector.sliceAtM`+-- /Related/: 'splitAt'', `splitExtractM`, 'Data.Massiv.Vector.sliceAt'', `Data.Massiv.Vector.sliceAtM` -- -- /__Exceptions__/: `IndexDimensionException`, `SizeSubregionException` --@@ -819,7 +818,7 @@ -- | /O(1)/ - Split an array into two at an index along a specified dimension. Throws an -- error for a wrong dimension or incorrect indices. ----- /Related/: `splitAtM`, `splitExtractM`, `Data.Massiv.Vector.sliceAt'`, `Data.Massiv.Vector.sliceAtM`+-- /Related/: `splitAtM`, `splitExtractM`, 'Data.Massiv.Vector.sliceAt'', `Data.Massiv.Vector.sliceAtM` -- -- ==== __Examples__ --@@ -1173,7 +1172,7 @@ {-# INLINE transform2M #-} --- | Same as `transform'`, but operates on two arrays+-- | Same as 'transform'', but operates on two arrays -- -- @since 0.3.0 transform2' ::
src/Data/Massiv/Array/Unsafe.hs view
@@ -121,7 +121,7 @@ makeArray (getComp arr) sz $ \ !ix -> unsafeIndex arr (ixF ix) {-# INLINE unsafeBackpermute #-} --- | Same `Data.Array.transform'`, except no bounds checking is performed, thus making it faster,+-- | Same 'Data.Array.transform'', except no bounds checking is performed, thus making it faster, -- but unsafe. -- -- @since 0.3.0@@ -136,7 +136,7 @@ (sz, a) = getSz (size arr) {-# INLINE unsafeTransform #-} --- | Same `Data.Array.transform2'`, except no bounds checking is performed, thus making it faster,+-- | Same 'Data.Array.transform2'', except no bounds checking is performed, thus making it faster, -- but unsafe. -- -- @since 0.3.0
src/Data/Massiv/Core/Common.hs view
@@ -92,7 +92,7 @@ ) where #if !MIN_VERSION_base(4,11,0)-import Data.Semigroup+import Data.Semigroup (Semigroup((<>))) #endif import Control.Monad.Catch (MonadThrow(..)) import Control.Monad.IO.Unlift (MonadIO(liftIO), MonadUnliftIO(..))@@ -784,7 +784,7 @@ infixl 4 !, !?, ?? --- | /O(1)/ - Infix version of `index'`.+-- | /O(1)/ - Infix version of 'index''. -- -- ==== __Examples__ --
src/Data/Massiv/Vector.hs view
@@ -327,7 +327,7 @@ -- [@Data.Foldable.`Data.Foldable.length`@] For some data structures, like a list for -- example, it is an /O(n)/ operation, because there is a need to evaluate the full spine -- and possibly even the elements in order to get the full length. With `Stream` vectors--- that is rarely the case.+-- that is not always the case. -- -- [@Data.Vector.Generic.`Data.Vector.Generic.length`@] In the vector package this -- function will always break fusion, unless it is the only operation that is applied to@@ -352,7 +352,7 @@ -- | /O(1)/ - Get the first element of a `Source` vector. Throws an error on empty. ----- /Related/: `shead'`, `headM`, `sheadM`, `unconsM`.+-- /Related/: 'shead'', `headM`, `sheadM`, `unconsM`. -- -- ==== __Examples__ --@@ -378,7 +378,7 @@ -- | /O(1)/ - Get the first element of a `Source` vector. ----- /Related/: `head'`, `shead'`, `sheadM`, `unconsM`.+-- /Related/: 'head'', 'shead'', `sheadM`, `unconsM`. -- -- /__Throws Exceptions__/: `SizeEmptyException` when array is empty --@@ -411,7 +411,7 @@ -- | /O(1)/ - Get the first element of a `Stream` vector. Throws an error on empty. ----- /Related/: `head'`, `headM`, `sheadM`, `unconsM`.+-- /Related/: 'head'', `headM`, `sheadM`, `unconsM`. -- -- ==== __Examples__ --@@ -430,7 +430,7 @@ -- | /O(1)/ - Get the first element of a `Stream` vector. ----- /Related/: `head'`, `shead'`, `headM`, `unconsM`.+-- /Related/: 'head'', 'shead'', `headM`, `unconsM`. -- -- /__Throws Exceptions__/: `SizeEmptyException` --@@ -460,7 +460,7 @@ -- | /O(1)/ - Take one element off of the `Source` vector from the left side, as well as -- the remaining part of the vector in delayed `D` representation. ----- /Related/: `head'`, `shead'`, `headM`, `sheadM`, `cons`+-- /Related/: 'head'', 'shead'', `headM`, `sheadM`, `cons` -- -- /__Throws Exceptions__/: `SizeEmptyException` --@@ -490,7 +490,7 @@ -- | /O(1)/ - Take one element off of the vector from the right side, as well as the -- remaining part of the vector. ----- /Related/: `last'`, `lastM`, `snoc`+-- /Related/: 'last'', `lastM`, `snoc` -- -- /__Throws Exceptions__/: `SizeEmptyException` --@@ -539,7 +539,7 @@ -- | /O(1)/ - Get the last element of a `Source` vector. ----- /Related/: `last'`, `unsnocM`+-- /Related/: 'last'', `unsnocM` -- -- /__Throws Exceptions__/: `SizeEmptyException` --@@ -779,9 +779,8 @@ pure $ unsafeTail v {-# INLINE tailM #-} ----- | /O(1)/ - Get the vector with the first @n@ elements. Never fails+-- | /O(1)/ - Take first @n@ elements from a vector. This function never fails and has+-- similar semantics as the `Data.List.take` for lists. -- -- ==== __Examples__ --@@ -856,7 +855,7 @@ pure $ unsafeTake k v {-# INLINE takeM #-} --- | /O(1)/ - Get a `Stream` vector with the first @n@ elements. Never fails+-- | /O(1)/ - Create a `Stream` vector with the first @n@ elements. Never fails -- -- ==== __Examples__ --@@ -865,10 +864,23 @@ stake n = fromSteps . S.take n . S.toStream {-# INLINE stake #-} --- |+-- | /O(1)/ - Drop @n@ elements from a vector. This function never fails and has+-- similar semantics as the `Data.List.drop` for lists. -- -- ==== __Examples__ --+-- >>> import Data.Massiv.Array as A+-- >>> v = makeVectorR D Seq 10 id+-- >>> v+-- Array D Seq (Sz1 10)+-- [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]+-- >>> A.drop 5 v+-- Array D Seq (Sz1 5)+-- [ 5, 6, 7, 8, 9 ]+-- >>> A.drop 25 v+-- Array D Seq (Sz1 0)+-- [ ]+-- -- @since 0.5.0 drop :: forall r e. Source r e => Sz1 -> Vector r e -> Vector r e drop k = snd . sliceAt k@@ -898,7 +910,9 @@ sdrop n = fromSteps . S.drop n . S.toStream {-# INLINE sdrop #-} --- |+-- | /O(1)/ - Drop @n@ elements from a vector. Unlike `drop`, this function will+-- produce an error when supplied number of elements to drop is larger than size+-- of the supplied vector -- -- ==== __Examples__ --@@ -920,8 +934,7 @@ {-# INLINE dropM #-} --- | Samel as `sliceAt`, except it never fails.---+-- | Same as 'sliceAt'', except it never fails. -- -- ==== __Examples__ --@@ -933,7 +946,7 @@ !d = SafeSz (min k n) {-# INLINE sliceAt #-} --- | Same as `Data.Massiv.Array.splitAt'`, except for a flat vector.+-- | Same as 'Data.Massiv.Array.splitAt'', except for a flat vector. -- -- ==== __Examples__ --@@ -1209,7 +1222,7 @@ -- | /O(n)/ - Enumerate from a starting number @x@ exactly @n@ times with a step @1@. -- -- /Related/: `senumFromStepN`, `enumFromN`, `enumFromStepN`, `rangeSize`,--- `rangeStepSize`, `range`, `rangeStep'`+-- `rangeStepSize`, `range`, 'rangeStep'' -- -- ==== __Examples__ --@@ -2722,7 +2735,7 @@ -- | /O(n)/ - Find the smallest value in the array. ----- /Related/: `sminimum'`, `minimum`, `minimumM`.+-- /Related/: 'sminimum'', `minimum`, `minimumM`. -- -- /__Throws Exceptions__/: `SizeEmptyException` when array is empty --