From 1925c123d7d8184a1d2ddc0a413e0fd2776e1083 Mon Sep 17 00:00:00 2001 From: Alberto Ruiz Date: Thu, 8 May 2014 08:48:12 +0200 Subject: empty hmatrix-base --- lib/Data/Packed/Vector.hs | 96 ----------------------------------------------- 1 file changed, 96 deletions(-) delete mode 100644 lib/Data/Packed/Vector.hs (limited to 'lib/Data/Packed/Vector.hs') diff --git a/lib/Data/Packed/Vector.hs b/lib/Data/Packed/Vector.hs deleted file mode 100644 index b5a4318..0000000 --- a/lib/Data/Packed/Vector.hs +++ /dev/null @@ -1,96 +0,0 @@ -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE CPP #-} ------------------------------------------------------------------------------ --- | --- Module : Data.Packed.Vector --- Copyright : (c) Alberto Ruiz 2007-10 --- License : GPL --- --- Maintainer : Alberto Ruiz --- Stability : provisional --- --- 1D arrays suitable for numeric computations using external libraries. --- --- This module provides basic functions for manipulation of structure. --- ------------------------------------------------------------------------------ -{-# OPTIONS_HADDOCK hide #-} - -module Data.Packed.Vector ( - Vector, - fromList, (|>), toList, buildVector, - dim, (@>), - subVector, takesV, vjoin, join, - mapVector, mapVectorWithIndex, zipVector, zipVectorWith, unzipVector, unzipVectorWith, - mapVectorM, mapVectorM_, mapVectorWithIndexM, mapVectorWithIndexM_, - foldLoop, foldVector, foldVectorG, foldVectorWithIndex -) where - -import Data.Packed.Internal.Vector -import Foreign.Storable - -------------------------------------------------------------------- - -#ifdef BINARY - -import Data.Binary -import Control.Monad(replicateM) - --- a 64K cache, with a Double taking 13 bytes in Bytestring, --- implies a chunk size of 5041 -chunk :: Int -chunk = 5000 - -chunks :: Int -> [Int] -chunks d = let c = d `div` chunk - m = d `mod` chunk - in if m /= 0 then reverse (m:(replicate c chunk)) else (replicate c chunk) - -putVector v = do - let d = dim v - mapM_ (\i -> put $ v @> i) [0..(d-1)] - -getVector d = do - xs <- replicateM d get - return $! fromList xs - -instance (Binary a, Storable a) => Binary (Vector a) where - put v = do - let d = dim v - put d - mapM_ putVector $! takesV (chunks d) v - get = do - d <- get - vs <- mapM getVector $ chunks d - return $! vjoin vs - -#endif - -------------------------------------------------------------------- - -{- | creates a Vector of the specified length using the supplied function to - to map the index to the value at that index. - -@> buildVector 4 fromIntegral -4 |> [0.0,1.0,2.0,3.0]@ - --} -buildVector :: Storable a => Int -> (Int -> a) -> Vector a -buildVector len f = - fromList $ map f [0 .. (len - 1)] - - --- | zip for Vectors -zipVector :: (Storable a, Storable b, Storable (a,b)) => Vector a -> Vector b -> Vector (a,b) -zipVector = zipVectorWith (,) - --- | unzip for Vectors -unzipVector :: (Storable a, Storable b, Storable (a,b)) => Vector (a,b) -> (Vector a,Vector b) -unzipVector = unzipVectorWith id - -------------------------------------------------------------------- - -{-# DEPRECATED join "use vjoin or Data.Vector.concat" #-} -join :: Storable t => [Vector t] -> Vector t -join = vjoin - -- cgit v1.2.3