knead-0.4.1: Repa-like array processing using LLVM JIT

Safe HaskellNone

Data.Array.Knead.Shape

Synopsis

Documentation

class (C sh, C (Index sh), Indexed sh) => C sh whereSource

Methods

intersectCode :: T sh -> T sh -> CodeGenFunction r (T sh)Source

size :: T sh -> CodeGenFunction r (Value Size)Source

sizeOffset :: T sh -> CodeGenFunction r (Value Size, T (Index sh) -> CodeGenFunction r (Value Size))Source

Result is (size, offset). size must equal the result of size. We use this for sharing intermediate results.

iterator :: Index sh ~ ix => T sh -> T r (T ix)Source

loop :: (Index sh ~ ix, C ix, Phi state) => (T ix -> state -> CodeGenFunction r state) -> T sh -> state -> CodeGenFunction r stateSource

Instances

C () 
(Integral n, ToSize n, Comparison n) => C (ZeroBased n)

Array dimensions and indexes cannot be negative, but computations in indices may temporarily yield negative values or we want to add negative values to indices.

So maybe, we would better have type Index (ZeroBased Word64) = Int64. This is not possible. Maybe we need an additional ZeroBased type for unsigned array sizes.

(Ix n, ToSize n, Comparison n) => C (Range n) 
(Integral n, ToSize n, Comparison n) => C (Shifted n) 
(Enum enum, Bounded enum, EnumBounded enum) => C (Enumeration enum) 
(C n, C m) => C (n, m) 
C sh => C (Tagged tag sh) 
(~ * tag ShapeTag, C sh) => C (T tag sh) 
(C n, C m, C l) => C (n, m, l) 

type family Index sh :: *

value :: (C sh, Value val) => sh -> val shSource

paramWith :: (Storable b, C b, Value val) => T p b -> (forall parameters. (Storable parameters, C parameters) => (p -> parameters) -> (T parameters -> val b) -> a) -> aSource

load :: C sh => f sh -> Value (Ptr (Struct sh)) -> CodeGenFunction r (T sh)Source

intersect :: C sh => Exp sh -> Exp sh -> Exp shSource

offset :: C sh => T sh -> T (Index sh) -> CodeGenFunction r (Value Size)Source

newtype ZeroBased n

ZeroBased denotes a range starting at zero and has a certain length.

Constructors

ZeroBased n 

Instances

Functor ZeroBased 
Applicative ZeroBased 
Eq n => Eq (ZeroBased n) 
Show n => Show (ZeroBased n) 
Storable n => Storable (ZeroBased n) 
Integral n => C (ZeroBased n) 
Integral n => Indexed (ZeroBased n) 
Integral n => InvIndexed (ZeroBased n) 
NFData n => NFData (ZeroBased n) 
C n => C (ZeroBased n) 
C n => C (ZeroBased n) 
Compose n => Compose (ZeroBased n) 
Decompose pn => Decompose (ZeroBased pn) 
Decompose pn => Decompose (ZeroBased pn) 
Compose n => Compose (ZeroBased n) 
(Integral n, ToSize n, Comparison n) => Sequence (ZeroBased n) 
(Integral n, ToSize n, Comparison n) => C (ZeroBased n)

Array dimensions and indexes cannot be negative, but computations in indices may temporarily yield negative values or we want to add negative values to indices.

So maybe, we would better have type Index (ZeroBased Word64) = Int64. This is not possible. Maybe we need an additional ZeroBased type for unsigned array sizes.

zeroBased :: Value val => val n -> val (ZeroBased n)Source

zeroBasedSize :: Value val => val (ZeroBased n) -> val nSource

data Range n

Range denotes an inclusive range like those of the Haskell 98 standard Array type from the array package. E.g. the shape type (Range Int32, Range Int64) is equivalent to the ix type (Int32, Int64) for Arrays.

Constructors

Range n n 

Instances

Functor Range 
Eq n => Eq (Range n) 
Show n => Show (Range n) 
Storable n => Storable (Range n) 
Ix n => C (Range n) 
Ix n => Indexed (Range n) 
Ix n => InvIndexed (Range n) 
NFData n => NFData (Range n) 
C n => C (Range n) 
C n => C (Range n) 
Compose n => Compose (Range n) 
Decompose pn => Decompose (Range pn) 
(Ix n, ToSize n, Comparison n) => C (Range n) 

range :: Value val => val n -> val n -> val (Range n)Source

rangeFrom :: Value val => val (Range n) -> val nSource

rangeTo :: Value val => val (Range n) -> val nSource

data Shifted n

Shifted denotes a range defined by the start index and the length.

Constructors

Shifted n n 

Instances

Functor Shifted 
Eq n => Eq (Shifted n) 
Show n => Show (Shifted n) 
Storable n => Storable (Shifted n) 
Integral n => C (Shifted n) 
Integral n => Indexed (Shifted n) 
Integral n => InvIndexed (Shifted n) 
NFData n => NFData (Shifted n) 
C n => C (Shifted n) 
C n => C (Shifted n) 
Compose n => Compose (Shifted n) 
Decompose pn => Decompose (Shifted pn) 
(Integral n, ToSize n, Comparison n) => C (Shifted n) 

shifted :: Value val => val n -> val n -> val (Shifted n)Source

shiftedOffset :: Value val => val (Shifted n) -> val nSource

shiftedSize :: Value val => val (Shifted n) -> val nSource

data Enumeration n

Enumeration denotes a shape of fixed size that is defined by Enum and Bounded methods. For correctness it is necessary that the Enum and Bounded instances are properly implemented. Automatically derived instances are fine.

Constructors

Enumeration 

Instances

Eq (Enumeration n) 
Show (Enumeration n) 
Storable (Enumeration n) 
(Enum n, Bounded n) => C (Enumeration n) 
(Enum n, Bounded n) => Indexed (Enumeration n) 
(Enum n, Bounded n) => InvIndexed (Enumeration n) 
(Enum n, Bounded n) => Static (Enumeration n) 
NFData (Enumeration n) 
(Enum enum, Bounded enum) => C (Enumeration enum) 
(Enum enum, Bounded enum) => C (Enumeration enum) 
(Enum enum, Bounded enum) => Compose (Enumeration enum) 
Decompose (Enumeration enum) 
Decompose (Enumeration enum) 
(Enum enum, Bounded enum) => Compose (Enumeration enum) 
(Enum enum, Bounded enum, EnumBounded enum) => C (Enumeration enum) 

class (Enum enum, Bounded enum) => EnumBounded enum whereSource

Instances

(ToSize w, Additive w, IsInteger w, IntegerConstant w, Num w, ~ * (Repr Value w) (Value w), CmpRet w, ~ * (CmpResult w) Bool, Enum e, Bounded e) => EnumBounded (T w e) 

class C sh => Scalar sh whereSource

Methods

scalar :: Value val => val shSource

zeroIndex :: Value val => f sh -> val (Index sh)Source

Instances

Scalar () 
(~ * tag ShapeTag, ~ * sh Z) => Scalar (T tag sh) 

class (C sh, IntegerConstant (Index sh), Additive (Index sh)) => Sequence sh whereSource

Instances

(Integral n, ToSize n, Comparison n) => Sequence (ZeroBased n)