PrimitiveArray 0.3.0.0 → 0.4.0.0
raw patch · 4 files changed
+78/−152 lines, 4 filesdep ~primitivedep ~vectorPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: primitive, vector
API changes (from Hackage documentation)
- Data.PrimitiveArray.Unboxed.VectorZero: Arr0 :: !sh -> !Vector elm -> Arr0 sh elm
- Data.PrimitiveArray.Unboxed.VectorZero: MArr0 :: !sh -> !MVector s elm -> MArr0 s sh elm
- Data.PrimitiveArray.Unboxed.VectorZero: data Arr0 sh elm
- Data.PrimitiveArray.Unboxed.VectorZero: data MArr0 s sh elm
- Data.PrimitiveArray.Unboxed.VectorZero: instance (Shape sh, ExtShape sh, Unbox elm) => MPrimArrayOps MArr0 sh elm
- Data.PrimitiveArray.Unboxed.VectorZero: instance (Shape sh, ExtShape sh, Unbox elm) => PrimArrayOps Arr0 sh elm
- Data.PrimitiveArray.Unboxed.Zero: Arr0 :: !sh -> !ByteArray -> Arr0 sh elm
- Data.PrimitiveArray.Unboxed.Zero: MArr0 :: !sh -> !MutableByteArray s -> MArr0 s sh elm
- Data.PrimitiveArray.Unboxed.Zero: data Arr0 sh elm
- Data.PrimitiveArray.Unboxed.Zero: data MArr0 s sh elm
- Data.PrimitiveArray.Unboxed.Zero: instance (Shape sh, ExtShape sh, Prim elm) => MPrimArrayOps MArr0 sh elm
- Data.PrimitiveArray.Unboxed.Zero: instance (Shape sh, ExtShape sh, Prim elm) => PrimArrayOps Arr0 sh elm
+ Data.PrimitiveArray.Zero.Unboxed: Arr0 :: !sh -> !(Vector elm) -> Arr0 sh elm
+ Data.PrimitiveArray.Zero.Unboxed: MArr0 :: !sh -> !(MVector s elm) -> MArr0 s sh elm
+ Data.PrimitiveArray.Zero.Unboxed: data Arr0 sh elm
+ Data.PrimitiveArray.Zero.Unboxed: data MArr0 s sh elm
+ Data.PrimitiveArray.Zero.Unboxed: instance (Shape sh, ExtShape sh, Unbox elm) => MPrimArrayOps MArr0 sh elm
+ Data.PrimitiveArray.Zero.Unboxed: instance (Shape sh, ExtShape sh, Unbox elm) => PrimArrayOps Arr0 sh elm
- Data.PrimitiveArray.Zero: Arr0 :: !sh -> !Array elm -> Arr0 sh elm
+ Data.PrimitiveArray.Zero: Arr0 :: !sh -> !(Array elm) -> Arr0 sh elm
- Data.PrimitiveArray.Zero: MArr0 :: !sh -> !MutableArray s elm -> MArr0 s sh elm
+ Data.PrimitiveArray.Zero: MArr0 :: !sh -> !(MutableArray s elm) -> MArr0 s sh elm
Files
- Data/PrimitiveArray/Unboxed/VectorZero.hs +0/−71
- Data/PrimitiveArray/Unboxed/Zero.hs +0/−70
- Data/PrimitiveArray/Zero/Unboxed.hs +71/−0
- PrimitiveArray.cabal +7/−11
− Data/PrimitiveArray/Unboxed/VectorZero.hs
@@ -1,71 +0,0 @@-{-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE TypeFamilies #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE FlexibleInstances #-}---- | Strict, unboxed arrays of primitive type. Uses unboxed vectors internally--- to provide tuple instances.--module Data.PrimitiveArray.Unboxed.VectorZero where--import Control.Monad-import Data.Array.Repa.Index-import Data.Array.Repa.Shape-import Control.Exception (assert)-import Data.Vector.Unboxed as VU hiding (forM_, length, zipWithM_)-import Data.Vector.Unboxed.Mutable as VUM hiding (length)--import Data.ExtShape-import Data.PrimitiveArray------ | Monadic arrays of primitive type.--data MArr0 s sh elm = MArr0 !sh !(MVector s elm)---- | Immutable arrays of primitive type.--data Arr0 sh elm = Arr0 !sh !(Vector elm)----type instance MutArray Arr0 = MArr0---- NOTE inLb, inUb is including bound, while exUb is excluding upper bound.--- Differentiates between largest included index, first excluded index.--instance (Shape sh, ExtShape sh, VU.Unbox elm) => MPrimArrayOps MArr0 sh elm where- boundsM (MArr0 exUb _) = (zeroDim,exUb `subDim` unitDim)- fromListM inLb inUb xs = do- ma <- newM inLb inUb- let exUb = inUb `addDim` unitDim- let (MArr0 _ mba) = ma- zipWithM_ (\k x -> assert (length xs == size exUb) $ unsafeWrite mba k x) [0.. toIndex exUb inUb] xs- return ma- newM inLb inUb = let exUb = inUb `addDim` unitDim in- unless (inLb == zeroDim) (error "MArr0 lb/=zeroDim") >>- MArr0 exUb `liftM` new (size exUb)- newWithM inLb inUb def = do- let exUb = inUb `addDim` unitDim- ma <- newM inLb inUb- let (MArr0 _ mba) = ma- forM_ [0 .. toIndex exUb inUb] $ \k -> unsafeWrite mba k def- return ma- readM (MArr0 exUb mba) idx = assert (inShape exUb idx) $ unsafeRead mba (toIndex exUb idx)- writeM (MArr0 exUb mba) idx elm = assert (inShape exUb idx) $ unsafeWrite mba (toIndex exUb idx) elm- {-# INLINE boundsM #-}- {-# INLINE fromListM #-}- {-# INLINE newM #-}- {-# INLINE newWithM #-}- {-# INLINE readM #-}- {-# INLINE writeM #-}--instance (Shape sh, ExtShape sh, VUM.Unbox elm) => PrimArrayOps Arr0 sh elm where- bounds (Arr0 exUb _) = (zeroDim,exUb `subDim` unitDim)- freeze (MArr0 exUb mba) = Arr0 exUb `liftM` unsafeFreeze mba- index (Arr0 exUb ba) idx = assert (inShape exUb idx) $ unsafeIndex ba (toIndex exUb idx)- {-# INLINE bounds #-}- {-# INLINE freeze #-}- {-# INLINE index #-}-
− Data/PrimitiveArray/Unboxed/Zero.hs
@@ -1,70 +0,0 @@-{-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE TypeFamilies #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE FlexibleInstances #-}---- | Strict, unboxed arrays of primitive type.--module Data.PrimitiveArray.Unboxed.Zero where--import Control.Monad-import Data.Array.Repa.Index-import Data.Array.Repa.Shape-import Data.Primitive-import Data.Primitive.Types-import Control.Exception (assert)--import Data.ExtShape-import Data.PrimitiveArray------ | Monadic arrays of primitive type.--data MArr0 s sh elm = MArr0 !sh !(MutableByteArray s)---- | Immutable arrays of primitive type.--data Arr0 sh elm = Arr0 !sh !ByteArray----type instance MutArray Arr0 = MArr0---- NOTE inLb, inUb is including bound, while exUb is excluding upper bound.--- Differentiates between largest included index, first excluded index.--instance (Shape sh, ExtShape sh, Prim elm) => MPrimArrayOps MArr0 sh elm where- boundsM (MArr0 exUb _) = (zeroDim,exUb `subDim` unitDim)- fromListM inLb inUb xs = do- ma <- newM inLb inUb- let exUb = inUb `addDim` unitDim- let (MArr0 _ mba) = ma- zipWithM_ (\k x -> assert (length xs == size exUb) $ writeByteArray mba k x) [0.. toIndex exUb inUb] xs- return ma- newM inLb inUb = let exUb = inUb `addDim` unitDim in- unless (inLb == zeroDim) (error "MArr0 lb/=zeroDim") >>- MArr0 exUb `liftM` newByteArray (size exUb * sizeOf (undefined :: elm))- newWithM inLb inUb def = do- let exUb = inUb `addDim` unitDim- ma <- newM inLb inUb- let (MArr0 _ mba) = ma- forM_ [0 .. toIndex exUb inUb] $ \k -> writeByteArray mba k def- return ma- readM (MArr0 exUb mba) idx = assert (inShape exUb idx) $ readByteArray mba (toIndex exUb idx)- writeM (MArr0 exUb mba) idx elm = assert (inShape exUb idx) $ writeByteArray mba (toIndex exUb idx) elm- {-# INLINE boundsM #-}- {-# INLINE fromListM #-}- {-# INLINE newM #-}- {-# INLINE newWithM #-}- {-# INLINE readM #-}- {-# INLINE writeM #-}--instance (Shape sh, ExtShape sh, Prim elm) => PrimArrayOps Arr0 sh elm where- bounds (Arr0 exUb _) = (zeroDim,exUb `subDim` unitDim)- freeze (MArr0 exUb mba) = Arr0 exUb `liftM` unsafeFreezeByteArray mba- index (Arr0 exUb ba) idx = assert (inShape exUb idx) $ indexByteArray ba (toIndex exUb idx)- {-# INLINE bounds #-}- {-# INLINE freeze #-}- {-# INLINE index #-}-
+ Data/PrimitiveArray/Zero/Unboxed.hs view
@@ -0,0 +1,71 @@+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE FlexibleInstances #-}++-- | Strict, unboxed arrays of primitive type. Uses unboxed vectors internally+-- to provide tuple instances.++module Data.PrimitiveArray.Zero.Unboxed where++import Control.Monad+import Data.Array.Repa.Index+import Data.Array.Repa.Shape+import Control.Exception (assert)+import Data.Vector.Unboxed as VU hiding (forM_, length, zipWithM_)+import Data.Vector.Unboxed.Mutable as VUM hiding (length)++import Data.ExtShape+import Data.PrimitiveArray++++-- | Monadic arrays of primitive type.++data MArr0 s sh elm = MArr0 !sh !(MVector s elm)++-- | Immutable arrays of primitive type.++data Arr0 sh elm = Arr0 !sh !(Vector elm)++++type instance MutArray Arr0 = MArr0++-- NOTE inLb, inUb is including bound, while exUb is excluding upper bound.+-- Differentiates between largest included index, first excluded index.++instance (Shape sh, ExtShape sh, VU.Unbox elm) => MPrimArrayOps MArr0 sh elm where+ boundsM (MArr0 exUb _) = (zeroDim,exUb `subDim` unitDim)+ fromListM inLb inUb xs = do+ ma <- newM inLb inUb+ let exUb = inUb `addDim` unitDim+ let (MArr0 _ mba) = ma+ zipWithM_ (\k x -> assert (length xs == size exUb) $ unsafeWrite mba k x) [0.. toIndex exUb inUb] xs+ return ma+ newM inLb inUb = let exUb = inUb `addDim` unitDim in+ unless (inLb == zeroDim) (error "MArr0 lb/=zeroDim") >>+ MArr0 exUb `liftM` new (size exUb)+ newWithM inLb inUb def = do+ let exUb = inUb `addDim` unitDim+ ma <- newM inLb inUb+ let (MArr0 _ mba) = ma+ forM_ [0 .. toIndex exUb inUb] $ \k -> unsafeWrite mba k def+ return ma+ readM (MArr0 exUb mba) idx = assert (inShape exUb idx) $ unsafeRead mba (toIndex exUb idx)+ writeM (MArr0 exUb mba) idx elm = assert (inShape exUb idx) $ unsafeWrite mba (toIndex exUb idx) elm+ {-# INLINE boundsM #-}+ {-# INLINE fromListM #-}+ {-# INLINE newM #-}+ {-# INLINE newWithM #-}+ {-# INLINE readM #-}+ {-# INLINE writeM #-}++instance (Shape sh, ExtShape sh, VUM.Unbox elm) => PrimArrayOps Arr0 sh elm where+ bounds (Arr0 exUb _) = (zeroDim,exUb `subDim` unitDim)+ freeze (MArr0 exUb mba) = Arr0 exUb `liftM` unsafeFreeze mba+ index (Arr0 exUb ba) idx = assert (inShape exUb idx) $ unsafeIndex ba (toIndex exUb idx)+ {-# INLINE bounds #-}+ {-# INLINE freeze #-}+ {-# INLINE index #-}+
PrimitiveArray.cabal view
@@ -1,5 +1,5 @@ Name: PrimitiveArray-Version: 0.3.0.0+Version: 0.4.0.0 License: BSD3 License-file: LICENSE Author: Christian Hoener zu Siederdissen@@ -25,12 +25,6 @@ always zero. . We have forked two repa modules: Shape and Index.- .- Unboxed vectors are available with implementations based on- "primitive" and "vector". The "primitive" version is probably- obsolete now, as I don't see any slowdowns anymore. If this- continues into GHC 7.6.1, I'll remove the old code (This will- probably not break user code using Unboxed.Zero). Library Exposed-modules:@@ -38,13 +32,15 @@ Data.Array.Repa.Shape Data.ExtShape Data.PrimitiveArray- Data.PrimitiveArray.Unboxed.Zero- Data.PrimitiveArray.Unboxed.VectorZero Data.PrimitiveArray.Zero+ Data.PrimitiveArray.Zero.Unboxed+-- Data.PrimitiveArray.UpperTriangular+-- Data.PrimitiveArray.UpperTriangular.Unboxed+-- Data.PrimitiveArray.FillTable Build-depends: base >= 4 && <5,- primitive >= 0.4,- vector >= 0.9+ primitive == 0.5 ,+ vector == 0.10 ghc-options: -O2 -funbox-strict-fields