Skip to content

Instantly share code, notes, and snippets.

@fumieval
Last active August 27, 2015 02:08
Show Gist options
  • Save fumieval/873c7d0ebc7e40ace5b3 to your computer and use it in GitHub Desktop.
Save fumieval/873c7d0ebc7e40ace5b3 to your computer and use it in GitHub Desktop.
import qualified Data.Vector as V
import qualified Data.Vector.Generic as G
import qualified Data.Vector.Fusion.Bundle as Bundle
newtype Arr a = Arr [V.Vector a]
(<|) :: a -> Arr a -> Arr a
a <| Arr (v:w:xs)
| V.length v == V.length w = Arr (G.unstream (Bundle.cons a $ G.stream v Bundle.++ G.stream w) : xs)
a <| Arr xs = Arr (V.singleton a : xs)
index :: Int -> Arr a -> Maybe a
index i (Arr (v:vs))
| i < V.length v = Just (v V.! i)
| otherwise = index (i - V.length v) (Arr vs)
index _ _ = Nothing
@jamesdbrock
Copy link

data (Storable a) => MatrixChunk a = MatrixChunk { chunks :: V.Vector (LA.Matrix a) }

instance (Storable a) => Foldable (MatrixChunk a)
    where
    foldr f z t = undefined

mcLengthRow :: (Storable a) => MatrixChunk a -> Int

-- | In constant time, return a 'MatrixChunk' which consists of rows @ibegin@
-- through @iend - 1@.
mcSplit :: (Storable a) => Int -> Int -> MatrixChunk a -> MatrixChunk a
mcSplit ibegin iend mc = undefined

mcAppendRow :: (Storable a) => VS.Vector a -> MatrixChunk a -> MatrixChunk a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment