uvector 0.1.0.5 → 0.1.1.0
raw patch · 5 files changed
+7/−127 lines, 5 files
Files
- Data/Array/Vector.hs +0/−3
- Data/Array/Vector/Prim/BUArr.hs +0/−62
- Data/Array/Vector/Strict/Basics.hs +3/−1
- Data/Array/Vector/UArr.hs +3/−60
- uvector.cabal +1/−1
Data/Array/Vector.hs view
@@ -174,9 +174,6 @@ -- randomU, randomRU, -} - -- * I\/O- UIO(..),- -- * Operations on mutable arrays newU, lengthMU, newMU, readMU, writeMU, unsafeFreezeMU, unsafeFreezeAllMU, copyMU, permuteMU, atomicUpdateMU, unstreamMU,
Data/Array/Vector/Prim/BUArr.hs view
@@ -81,9 +81,6 @@ -- * Conversions to\/from lists toBU, fromBU, - -- * I\/O- hPutBU, hGetBU- -- * Re-exporting some of GHC's internals that higher-level modules need -- Char#, Int#, Float#, Double#, Char(..), Int(..), Float(..), Double(..), ST, -- runST@@ -833,65 +830,6 @@ len_bytes = sizeBU len (undefined :: e) off_bytes = sizeBU off (undefined :: e) -}----------------------------------------------------------------------------- IO--- ------ host order , uninterpreted IO for BUArrays--hGetBU :: forall e. UAE e => Handle -> IO (BUArr e)-hGetBU h =- do- let elemSize = sizeBU 1 (undefined :: e)- n <- fmap ((`div`elemSize) . fromInteger) $ hFileSize h- marr@(MBUArr _ marr#) <- stToIO (newMBU n)- let bytes = sizeBU n (undefined :: e)- wantReadableHandle "hGetBU" h $- \handle@Handle__{ haFD=fd, haBuffer=ref, haIsStream=is_stream } -> do- buf@Buffer { bufBuf = raw, bufWPtr = w, bufRPtr = r } <- readIORef ref- let copied = bytes `min` (w - r)- remaining = bytes - copied- newr = r + copied- newbuf | newr == w = buf{ bufRPtr = 0, bufWPtr = 0 }- | otherwise = buf{ bufRPtr = newr }- --memcpy_ba_baoff marr# raw (fromIntegral r) (fromIntegral copied)- memcpy_ba_baoff marr# raw (fromIntegral r) (fromIntegral copied)- writeIORef ref newbuf- readChunkBU fd is_stream marr# copied remaining- stToIO (unsafeFreezeAllMBU marr)--readChunkBU :: FD -> Bool -> MutableByteArray# RealWorld -> Int -> Int -> IO ()-readChunkBU fd is_stream marr# off bytes = loop off bytes- where- loop off bytes | bytes <= 0 = return ()- loop off bytes = do- r' <- readRawBuffer "readChunkBU" (fromIntegral fd) is_stream marr#- (fromIntegral off) (fromIntegral bytes)- let r = fromIntegral r'- if r == 0- then error "readChunkBU: can't read"- else loop (off + r) (bytes - r)--hPutBU :: forall e. UAE e => Handle -> BUArr e -> IO ()-hPutBU h arr@(BUArr i n arr#) =- do- wantWritableHandle "hPutBU" h $- \handle@Handle__{ haFD=fd, haBuffer=ref, haIsStream=stream } -> do- old_buf <- readIORef ref- flushed_buf <- flushWriteBuffer fd stream old_buf- writeIORef ref flushed_buf- let this_buf = Buffer { bufBuf = unsafeCoerce# arr#- , bufState = WriteBuffer- , bufRPtr = off- , bufWPtr = off + size- , bufSize = size- }- flushWriteBuffer fd stream this_buf- return ()- where- off = sizeBU i (undefined :: e)- size = sizeBU n (undefined :: e) ----------------------------------------------------------------------------- -- Translation between elements and bytes
Data/Array/Vector/Strict/Basics.hs view
@@ -141,7 +141,9 @@ . replicateEachS n $ zipS (streamU ns) (streamU es) --- |/O(n)/. 'indexU' extracts an element out of an immutable unboxed array.+-- | 'indexU' extracts an element out of an immutable unboxed array.+--+-- TODO: use indexU, the non-streaming version. -- indexU :: UA e => UArr e -> Int -> e indexU arr n = indexS (streamU arr) n
Data/Array/Vector/UArr.hs view
@@ -42,9 +42,6 @@ memcpyMU, memcpyOffMU, memmoveOffMU, unsafeZipMU, unsafeUnzipMU, - -- * I\/O- UIO(..)- ) where -- standard libraries@@ -57,7 +54,7 @@ -- friends import Data.Array.Vector.Prim.BUArr ( BUArr, MBUArr, UAE,- lengthBU, indexBU, sliceBU, hGetBU, hPutBU,+ lengthBU, indexBU, sliceBU, lengthMBU, newMBU, readMBU, writeMBU, copyMBU, unsafeFreezeMBU, memcpyMBU, memcpyOffMBU, memmoveOffMBU) @@ -84,9 +81,10 @@ data UArr e data MUArr e :: * -> * - -- |/O(1?)/. Yield the length of an unboxed array.+ -- |/O(1)/. Yield the length of an unboxed array. lengthU :: UArr e -> Int + -- |/O(1)/. Read an element from the array. indexU :: UArr e -> Int -> e -- |/O(1)/. 'sliceU' restricts access to a subrange of the original array @@ -874,58 +872,3 @@ memcpyMU (MUARatio src) (MUARatio dst) l = memcpyMU src dst l memcpyOffMU (MUARatio src) (MUARatio dst) s d l = memcpyOffMU src dst s d l memmoveOffMU (MUARatio src) (MUARatio dst) s d l = memmoveOffMU src dst s d l------------------------------------------------------------------------------- * I\/O--- -------class UA a => UIO a where- hPutU :: Handle -> UArr a -> IO ()- hGetU :: Handle -> IO (UArr a)--primPutU :: UPrim a => Handle -> UArr a -> IO ()-primPutU h = hPutBU h . unUAPrim--primGetU :: UPrim a => Handle -> IO (UArr a)-primGetU = liftM mkUAPrim . hGetBU----------------------------------------------------------------------------instance UIO Bool where hPutU = primPutU; hGetU = primGetU-instance UIO Char where hPutU = primPutU; hGetU = primGetU-instance UIO Int where hPutU = primPutU; hGetU = primGetU-instance UIO Word where hPutU = primPutU; hGetU = primGetU-instance UIO Float where hPutU = primPutU; hGetU = primGetU-instance UIO Double where hPutU = primPutU; hGetU = primGetU--instance UIO Word8 where hPutU = primPutU; hGetU = primGetU-instance UIO Word16 where hPutU = primPutU; hGetU = primGetU-instance UIO Word32 where hPutU = primPutU; hGetU = primGetU-instance UIO Word64 where hPutU = primPutU; hGetU = primGetU--instance UIO Int8 where hPutU = primPutU; hGetU = primGetU-instance UIO Int16 where hPutU = primPutU; hGetU = primGetU-instance UIO Int32 where hPutU = primPutU; hGetU = primGetU-instance UIO Int64 where hPutU = primPutU; hGetU = primGetU----------------------------------------------------------------------------instance (UIO a, UIO b) => UIO (a :*: b) where- hPutU h (UAProd xs ys) = do hPutU h xs- hPutU h ys- hGetU h = do xs <- hGetU h- ys <- hGetU h- return (UAProd xs ys)--instance (RealFloat a, UIO a) => UIO (Complex a) where- hPutU h (UAComplex arr) = hPutU h arr- hGetU h = do arr <- hGetU h- return (UAComplex arr)--instance (Integral a, UIO a) => UIO (Ratio a) where- hPutU h (UARatio arr) = hPutU h arr- hGetU h = do arr <- hGetU h- return (UARatio arr)-
uvector.cabal view
@@ -1,5 +1,5 @@ name: uvector-version: 0.1.0.5+version: 0.1.1.0 license: BSD3 license-file: LICENSE author: Manuel Chakravarty, Gabriele Keller, Roman Leshchinskiy, Don Stewart