PrimitiveArray-0.5.2.0: Efficient multidimensional arrays

Safe HaskellNone

Data.Array.Repa.Index.Subword

Description

Subwords span upper triangular tables. A subword (i,j) is legal iff i<=j.

NOTE Using more complicated shapes has a number of benefits. We don't need to specify triangular or rectangular tables anymore. A rectangular one-dimensional table with a subword as shape actually does create space as required for subwords.

TODO subword indexing is currently hardcoded to be zero-based. See subwordIndex.

TODO consider replacing (quot 2) with (shiftR 1)

TODO all the QuickCheck stuff is missing

Synopsis

Documentation

newtype Subword Source

A subword wraps a simple pair.

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) and (N,N) both point to the smallest. We do, however, use (0,0) as the smallest as (0,k) gives successively smaller upper triangular parts.

Constructors

Subword (Int :. Int) 

Instances

Eq Subword 
Ord Subword 
Show Subword 
Arbitrary Subword 
NFData Subword 
Unbox Subword 
Vector Vector Subword 
MVector MVector Subword 
(PrimMonad m, Stack m Subword xs, MPrimArrayOps arr (:. Z Subword) e) => Stack m Subword (:. xs (SubwordNonTerminal m arr e)) 
(Monad m, MPrimArrayOps arr (:. Z Subword) e, Stack m Subword (:. xs (SubwordNonTerminal m arr e))) => UpperTriS m (:. xs (SubwordNonTerminal m arr e)) 
Arbitrary z => Arbitrary (:. z Subword) 
Shape sh => Shape (:. sh Subword)

Some weird things are going on here. Adding subwords (i,j) and (k,l) yields (i+k,j+l). Normally i==k==0 when calculating space requirements. If you have a subword (3,10) and want the next outer one add (-1,1) and you get what you want. We make NO(!) check that the final subword contains only non-negative indices.

ExtShape sh => ExtShape (:. sh Subword) 

triangularNumber :: Int -> IntSource

triangular numbers

A000217

upperTri :: Subword -> IntSource

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

subwordIndex :: Subword -> Subword -> IntSource

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

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