PrimitiveArray-0.7.0.0: Efficient multidimensional arrays

Safe HaskellNone
LanguageHaskell2010

Data.PrimitiveArray.Index.Subword

Description

Index structure for context-free grammars on strings. A Subword captures a pair (i,j) with i<=j.

Synopsis

Documentation

newtype Subword t Source

A subword wraps a pair of Int indices i,j with i<=j.

Subwords always yield the upper-triangular part of a rect-angular array. This gives the quite curious effect that (0,N) points to the `largest' index, while (0,0) ... (1,1) ... (k,k) ... (N,N) point to the smallest. We do, however, use (0,0) as the smallest as (0,k) gives successively smaller upper triangular parts.

Constructors

Subword 

Fields

fromSubword :: Int :. Int
 

Instances

Vector Vector (Subword t) Source 
MVector MVector (Subword t) Source 
Eq (Subword t) Source 
Ord (Subword t) Source 
Read (Subword t) Source 
Show (Subword t) Source 
Generic (Subword t) Source 
Arbitrary (Subword t) Source 
ToJSON (Subword t) Source 
FromJSON (Subword t) Source 
Binary (Subword t) Source 
Serialize (Subword t) Source 
NFData (Subword t) Source 
Hashable (Subword t) Source 
Unbox (Subword t) Source 
IndexStream ((:.) Z (Subword t)) => IndexStream (Subword t) Source 
Index (Subword t) Source 
IndexStream z => IndexStream ((:.) z (Subword C)) Source 
IndexStream z => IndexStream ((:.) z (Subword O)) Source

Subword O (outside).

Note: streamUp really needs to use streamDownMk / streamDownStep for the right order of indices!

IndexStream z => IndexStream ((:.) z (Subword I)) Source

Subword I (inside)

data MVector s0 (Subword t0) = MV_Subword (MVector s (Int, Int)) Source 
type Rep (Subword t) Source 
data Vector (Subword t0) = V_Subword (Vector (Int, Int)) Source 

subword :: Int -> Int -> Subword t Source

Create a Subword t where t is inferred.

triangularNumber :: Int -> Int Source

triangular numbers

A000217

upperTri :: Subword t -> Int Source

Size of an upper triangle starting at i and ending at j. "(0,N)" what be the normal thing to use.

subwordIndex :: Subword s -> Subword t -> Int Source

Subword indexing. Given the longest subword and the current subword, calculate a linear index "[0,..]". "(l,n)" in this case means "l"ower bound, length "n". And "(i,j)" is the normal index.

TODO probably doesn't work right with non-zero base ?!

streamUpMk :: Monad m => t1 -> t -> m (t, t1, t1) Source

generic mk for streamUp / streamDown

streamUpStep :: Monad m => Int -> Int -> (t1, Int, Int) -> m (Step (t1, Int, Int) ((:.) t1 (Subword t))) Source

streamDownMk :: Monad m => t1 -> t2 -> t -> m (t, t1, t2) Source

streamDownStep :: Monad m => Int -> (t1, Int, Int) -> m (Step (t1, Int, Int) ((:.) t1 (Subword t))) Source