PrimitiveArray-0.8.0.1: Efficient multidimensional arrays

Safe HaskellNone
LanguageHaskell2010

Data.PrimitiveArray.Dense

Contents

Description

Dense primitive arrays where the lower index is zero (or the equivalent of zero for newtypes and enumerations).

Actual writes to data structures use a more safe write instead of the unsafe unsafeWrite. Writes also tend to occur much less in DP algorithms (say, N^2 writes for an N^3 time algorithm -- mostly reads are being executed).

TODO consider if we want to force the lower index to be zero, or allow non-zero lower indices. Will have to be considered together with the Index.Class module!

TODO while Unboxed is, in princile, Hashable, we'd need the corresponding VU.Vector instances ...

Synopsis

Unboxed, multidimensional arrays.

data Unboxed sh e Source #

Constructors

Unboxed !sh !sh !(Vector e) 

Instances

(Index sh, Unbox elm) => PrimArrayOps Unboxed sh elm Source # 

Methods

bounds :: Unboxed sh elm -> (sh, sh) Source #

unsafeFreeze :: PrimMonad m => MutArr m (Unboxed sh elm) -> m (Unboxed sh elm) Source #

unsafeThaw :: PrimMonad m => Unboxed sh elm -> m (MutArr m (Unboxed sh elm)) Source #

unsafeIndex :: Unboxed sh elm -> sh -> elm Source #

transformShape :: Index sh' => (sh -> sh') -> Unboxed sh elm -> Unboxed sh' elm Source #

(Index sh, Unbox elm) => MPrimArrayOps Unboxed sh elm Source # 

Methods

boundsM :: MutArr m (Unboxed sh elm) -> (sh, sh) Source #

fromListM :: PrimMonad m => sh -> sh -> [elm] -> m (MutArr m (Unboxed sh elm)) Source #

newM :: PrimMonad m => sh -> sh -> m (MutArr m (Unboxed sh elm)) Source #

newWithM :: PrimMonad m => sh -> sh -> elm -> m (MutArr m (Unboxed sh elm)) Source #

readM :: PrimMonad m => MutArr m (Unboxed sh elm) -> sh -> m elm Source #

writeM :: PrimMonad m => MutArr m (Unboxed sh elm) -> sh -> elm -> m () Source #

(Index sh, Unbox e, Unbox e') => PrimArrayMap Unboxed sh e e' Source # 

Methods

map :: (e -> e') -> Unboxed sh e -> Unboxed sh e' Source #

(Eq e, Eq sh, Unbox e) => Eq (Unboxed sh e) Source # 

Methods

(==) :: Unboxed sh e -> Unboxed sh e -> Bool #

(/=) :: Unboxed sh e -> Unboxed sh e -> Bool #

(Unbox e, Read e, Read sh) => Read (Unboxed sh e) Source # 
(Unbox e, Show e, Show sh) => Show (Unboxed sh e) Source # 

Methods

showsPrec :: Int -> Unboxed sh e -> ShowS #

show :: Unboxed sh e -> String #

showList :: [Unboxed sh e] -> ShowS #

Generic (MutArr m (Unboxed sh e)) Source # 

Associated Types

type Rep (MutArr m (Unboxed sh e)) :: * -> * #

Methods

from :: MutArr m (Unboxed sh e) -> Rep (MutArr m (Unboxed sh e)) x #

to :: Rep (MutArr m (Unboxed sh e)) x -> MutArr m (Unboxed sh e) #

Generic (Unboxed sh e) Source # 

Associated Types

type Rep (Unboxed sh e) :: * -> * #

Methods

from :: Unboxed sh e -> Rep (Unboxed sh e) x #

to :: Rep (Unboxed sh e) x -> Unboxed sh e #

(Hashable sh, Hashable e, Hashable (Vector e), Unbox e) => Hashable (Unboxed sh e) Source # 

Methods

hashWithSalt :: Int -> Unboxed sh e -> Int #

hash :: Unboxed sh e -> Int #

(ToJSON sh, ToJSON e, Unbox e) => ToJSON (Unboxed sh e) Source # 

Methods

toJSON :: Unboxed sh e -> Value #

toEncoding :: Unboxed sh e -> Encoding #

toJSONList :: [Unboxed sh e] -> Value #

toEncodingList :: [Unboxed sh e] -> Encoding #

(FromJSON sh, FromJSON e, Unbox e) => FromJSON (Unboxed sh e) Source # 

Methods

parseJSON :: Value -> Parser (Unboxed sh e) #

parseJSONList :: Value -> Parser [Unboxed sh e] #

(Binary sh, Binary e, Unbox e) => Binary (Unboxed sh e) Source # 

Methods

put :: Unboxed sh e -> Put #

get :: Get (Unboxed sh e) #

putList :: [Unboxed sh e] -> Put #

(Serialize sh, Serialize e, Unbox e) => Serialize (Unboxed sh e) Source # 

Methods

put :: Putter (Unboxed sh e) #

get :: Get (Unboxed sh e) #

NFData sh => NFData (MutArr m (Unboxed sh e)) Source # 

Methods

rnf :: MutArr m (Unboxed sh e) -> () #

NFData sh => NFData (Unboxed sh e) Source # 

Methods

rnf :: Unboxed sh e -> () #

data MutArr m (Unboxed sh e) Source # 
data MutArr m (Unboxed sh e) = MUnboxed !sh !sh !(MVector (PrimState m) e)
type Rep (MutArr m (Unboxed sh e)) Source # 
type Rep (MutArr m (Unboxed sh e)) = D1 (MetaData "MutArr" "Data.PrimitiveArray.Dense" "PrimitiveArray-0.8.0.1-H8L9mO6Qdgd6EjLRyswnkq" False) (C1 (MetaCons "MUnboxed" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 sh)) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 sh)) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (MVector (PrimState m) e))))))
type Rep (Unboxed sh e) Source # 
type Rep (Unboxed sh e) = D1 (MetaData "Unboxed" "Data.PrimitiveArray.Dense" "PrimitiveArray-0.8.0.1-H8L9mO6Qdgd6EjLRyswnkq" False) (C1 (MetaCons "Unboxed" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 sh)) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 sh)) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Vector e))))))

Boxed, multidimensional arrays.

data Boxed sh e Source #

Constructors

Boxed !sh !sh !(Vector e) 

Instances

Index sh => PrimArrayOps Boxed sh elm Source # 

Methods

bounds :: Boxed sh elm -> (sh, sh) Source #

unsafeFreeze :: PrimMonad m => MutArr m (Boxed sh elm) -> m (Boxed sh elm) Source #

unsafeThaw :: PrimMonad m => Boxed sh elm -> m (MutArr m (Boxed sh elm)) Source #

unsafeIndex :: Boxed sh elm -> sh -> elm Source #

transformShape :: Index sh' => (sh -> sh') -> Boxed sh elm -> Boxed sh' elm Source #

Index sh => MPrimArrayOps Boxed sh elm Source # 

Methods

boundsM :: MutArr m (Boxed sh elm) -> (sh, sh) Source #

fromListM :: PrimMonad m => sh -> sh -> [elm] -> m (MutArr m (Boxed sh elm)) Source #

newM :: PrimMonad m => sh -> sh -> m (MutArr m (Boxed sh elm)) Source #

newWithM :: PrimMonad m => sh -> sh -> elm -> m (MutArr m (Boxed sh elm)) Source #

readM :: PrimMonad m => MutArr m (Boxed sh elm) -> sh -> m elm Source #

writeM :: PrimMonad m => MutArr m (Boxed sh elm) -> sh -> elm -> m () Source #

Index sh => PrimArrayMap Boxed sh e e' Source # 

Methods

map :: (e -> e') -> Boxed sh e -> Boxed sh e' Source #

(Eq e, Eq sh) => Eq (Boxed sh e) Source # 

Methods

(==) :: Boxed sh e -> Boxed sh e -> Bool #

(/=) :: Boxed sh e -> Boxed sh e -> Bool #

(Read e, Read sh) => Read (Boxed sh e) Source # 

Methods

readsPrec :: Int -> ReadS (Boxed sh e) #

readList :: ReadS [Boxed sh e] #

readPrec :: ReadPrec (Boxed sh e) #

readListPrec :: ReadPrec [Boxed sh e] #

(Show e, Show sh) => Show (Boxed sh e) Source # 

Methods

showsPrec :: Int -> Boxed sh e -> ShowS #

show :: Boxed sh e -> String #

showList :: [Boxed sh e] -> ShowS #

Generic (MutArr m (Boxed sh e)) Source # 

Associated Types

type Rep (MutArr m (Boxed sh e)) :: * -> * #

Methods

from :: MutArr m (Boxed sh e) -> Rep (MutArr m (Boxed sh e)) x #

to :: Rep (MutArr m (Boxed sh e)) x -> MutArr m (Boxed sh e) #

Generic (Boxed sh e) Source # 

Associated Types

type Rep (Boxed sh e) :: * -> * #

Methods

from :: Boxed sh e -> Rep (Boxed sh e) x #

to :: Rep (Boxed sh e) x -> Boxed sh e #

(Hashable sh, Hashable e, Hashable (Vector e)) => Hashable (Boxed sh e) Source # 

Methods

hashWithSalt :: Int -> Boxed sh e -> Int #

hash :: Boxed sh e -> Int #

(ToJSON sh, ToJSON e) => ToJSON (Boxed sh e) Source # 

Methods

toJSON :: Boxed sh e -> Value #

toEncoding :: Boxed sh e -> Encoding #

toJSONList :: [Boxed sh e] -> Value #

toEncodingList :: [Boxed sh e] -> Encoding #

(FromJSON sh, FromJSON e) => FromJSON (Boxed sh e) Source # 

Methods

parseJSON :: Value -> Parser (Boxed sh e) #

parseJSONList :: Value -> Parser [Boxed sh e] #

(Binary sh, Binary e) => Binary (Boxed sh e) Source # 

Methods

put :: Boxed sh e -> Put #

get :: Get (Boxed sh e) #

putList :: [Boxed sh e] -> Put #

(Serialize sh, Serialize e) => Serialize (Boxed sh e) Source # 

Methods

put :: Putter (Boxed sh e) #

get :: Get (Boxed sh e) #

NFData sh => NFData (MutArr m (Boxed sh e)) Source # 

Methods

rnf :: MutArr m (Boxed sh e) -> () #

(NFData sh, NFData e) => NFData (Boxed sh e) Source # 

Methods

rnf :: Boxed sh e -> () #

data MutArr m (Boxed sh e) Source # 
data MutArr m (Boxed sh e) = MBoxed !sh !sh !(MVector (PrimState m) e)
type Rep (MutArr m (Boxed sh e)) Source # 
type Rep (MutArr m (Boxed sh e)) = D1 (MetaData "MutArr" "Data.PrimitiveArray.Dense" "PrimitiveArray-0.8.0.1-H8L9mO6Qdgd6EjLRyswnkq" False) (C1 (MetaCons "MBoxed" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 sh)) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 sh)) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedUnpack) (Rec0 (MVector (PrimState m) e))))))
type Rep (Boxed sh e) Source # 
type Rep (Boxed sh e) = D1 (MetaData "Boxed" "Data.PrimitiveArray.Dense" "PrimitiveArray-0.8.0.1-H8L9mO6Qdgd6EjLRyswnkq" False) (C1 (MetaCons "Boxed" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 sh)) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 sh)) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedUnpack) (Rec0 (Vector e))))))