Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell98 |
Synopsis
- class (C sh, C (Index sh), Indexed sh) => C sh where
- intersectCode :: T sh -> T sh -> CodeGenFunction r (T sh)
- size :: T sh -> CodeGenFunction r (Value Size)
- sizeOffset :: Index sh ~ ix => T sh -> CodeGenFunction r (Value Size, T ix -> CodeGenFunction r (Value Size))
- iterator :: Index sh ~ ix => T sh -> T r (T ix)
- loop :: (Index sh ~ ix, Phi state) => (T ix -> state -> CodeGenFunction r state) -> T sh -> state -> CodeGenFunction r state
- type family Index sh
- type Size = Word
- value :: (C sh, Value val) => sh -> val sh
- paramWith :: C b => T p b -> (forall parameters. C parameters => (p -> parameters) -> (forall val. Value val => T parameters -> val b) -> a) -> a
- load :: C sh => f sh -> Value (Ptr (Struct sh)) -> CodeGenFunction r (T sh)
- intersect :: C sh => Exp sh -> Exp sh -> Exp sh
- offset :: C sh => T sh -> T (Index sh) -> CodeGenFunction r (Value Size)
- newtype ZeroBased n = ZeroBased n
- zeroBased :: Value val => val n -> val (ZeroBased n)
- zeroBasedSize :: Value val => val (ZeroBased n) -> val n
- data Range n = Range n n
- range :: Value val => val n -> val n -> val (Range n)
- rangeFrom :: Value val => val (Range n) -> val n
- rangeTo :: Value val => val (Range n) -> val n
- data Shifted n = Shifted n n
- shifted :: Value val => val n -> val n -> val (Shifted n)
- shiftedOffset :: Value val => val (Shifted n) -> val n
- shiftedSize :: Value val => val (Shifted n) -> val n
- newtype Cyclic n = Cyclic n
- cyclic :: Value val => val n -> val (Cyclic n)
- cyclicSize :: Value val => val (Cyclic n) -> val n
- data Enumeration n = Enumeration
- class (Enum enum, Bounded enum) => EnumBounded enum where
- enumOffset :: T enum -> CodeGenFunction r (Value Size)
- class C sh => Scalar sh where
- class (C sh, IntegerConstant (Index sh), Additive (Index sh)) => Sequence sh where
- sequenceShapeFromIndex :: T (Index sh) -> CodeGenFunction r (T sh)
Documentation
class (C sh, C (Index sh), Indexed sh) => C sh where Source #
intersectCode :: T sh -> T sh -> CodeGenFunction r (T sh) Source #
size :: T sh -> CodeGenFunction r (Value Size) Source #
sizeOffset :: Index sh ~ ix => T sh -> CodeGenFunction r (Value Size, T ix -> 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, Phi state) => (T ix -> state -> CodeGenFunction r state) -> T sh -> state -> CodeGenFunction r state Source #
Instances
C () Source # | |
Defined in Data.Array.Knead.Shape intersectCode :: T () -> T () -> CodeGenFunction r (T ()) Source # size :: T () -> CodeGenFunction r (Value Size) Source # sizeOffset :: Index () ~ ix => T () -> CodeGenFunction r (Value Size, T ix -> CodeGenFunction r (Value Size)) Source # iterator :: Index () ~ ix => T () -> T r (T ix) Source # loop :: (Index () ~ ix, Phi state) => (T ix -> state -> CodeGenFunction r state) -> T () -> state -> CodeGenFunction r state Source # | |
(Integral n, ToSize n, Comparison n) => C (Cyclic n) Source # | |
Defined in Data.Array.Knead.Shape intersectCode :: T (Cyclic n) -> T (Cyclic n) -> CodeGenFunction r (T (Cyclic n)) Source # size :: T (Cyclic n) -> CodeGenFunction r (Value Size) Source # sizeOffset :: Index (Cyclic n) ~ ix => T (Cyclic n) -> CodeGenFunction r (Value Size, T ix -> CodeGenFunction r (Value Size)) Source # iterator :: Index (Cyclic n) ~ ix => T (Cyclic n) -> T r (T ix) Source # loop :: (Index (Cyclic n) ~ ix, Phi state) => (T ix -> state -> CodeGenFunction r state) -> T (Cyclic n) -> state -> CodeGenFunction r state Source # | |
(Enum enum, Bounded enum, EnumBounded enum) => C (Enumeration enum) Source # | |
Defined in Data.Array.Knead.Shape intersectCode :: T (Enumeration enum) -> T (Enumeration enum) -> CodeGenFunction r (T (Enumeration enum)) Source # size :: T (Enumeration enum) -> CodeGenFunction r (Value Size) Source # sizeOffset :: Index (Enumeration enum) ~ ix => T (Enumeration enum) -> CodeGenFunction r (Value Size, T ix -> CodeGenFunction r (Value Size)) Source # iterator :: Index (Enumeration enum) ~ ix => T (Enumeration enum) -> T r (T ix) Source # loop :: (Index (Enumeration enum) ~ ix, Phi state) => (T ix -> state -> CodeGenFunction r state) -> T (Enumeration enum) -> state -> CodeGenFunction r state Source # | |
(Ix n, ToSize n, Comparison n) => C (Range n) Source # | |
Defined in Data.Array.Knead.Shape intersectCode :: T (Range n) -> T (Range n) -> CodeGenFunction r (T (Range n)) Source # size :: T (Range n) -> CodeGenFunction r (Value Size) Source # sizeOffset :: Index (Range n) ~ ix => T (Range n) -> CodeGenFunction r (Value Size, T ix -> CodeGenFunction r (Value Size)) Source # iterator :: Index (Range n) ~ ix => T (Range n) -> T r (T ix) Source # loop :: (Index (Range n) ~ ix, Phi state) => (T ix -> state -> CodeGenFunction r state) -> T (Range n) -> state -> CodeGenFunction r state Source # | |
(Integral n, ToSize n, Comparison n) => C (Shifted n) Source # | |
Defined in Data.Array.Knead.Shape intersectCode :: T (Shifted n) -> T (Shifted n) -> CodeGenFunction r (T (Shifted n)) Source # size :: T (Shifted n) -> CodeGenFunction r (Value Size) Source # sizeOffset :: Index (Shifted n) ~ ix => T (Shifted n) -> CodeGenFunction r (Value Size, T ix -> CodeGenFunction r (Value Size)) Source # iterator :: Index (Shifted n) ~ ix => T (Shifted n) -> T r (T ix) Source # loop :: (Index (Shifted n) ~ ix, Phi state) => (T ix -> state -> CodeGenFunction r state) -> T (Shifted n) -> state -> CodeGenFunction r state Source # | |
(Integral n, ToSize n, Comparison n) => C (ZeroBased n) Source # | 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. |
Defined in Data.Array.Knead.Shape intersectCode :: T (ZeroBased n) -> T (ZeroBased n) -> CodeGenFunction r (T (ZeroBased n)) Source # size :: T (ZeroBased n) -> CodeGenFunction r (Value Size) Source # sizeOffset :: Index (ZeroBased n) ~ ix => T (ZeroBased n) -> CodeGenFunction r (Value Size, T ix -> CodeGenFunction r (Value Size)) Source # iterator :: Index (ZeroBased n) ~ ix => T (ZeroBased n) -> T r (T ix) Source # loop :: (Index (ZeroBased n) ~ ix, Phi state) => (T ix -> state -> CodeGenFunction r state) -> T (ZeroBased n) -> state -> CodeGenFunction r state Source # | |
(tag ~ ShapeTag, Natural rank) => C (T tag rank) Source # | |
Defined in Data.Array.Knead.Shape.Cubic intersectCode :: T0 (T tag rank) -> T0 (T tag rank) -> CodeGenFunction r (T0 (T tag rank)) Source # size :: T0 (T tag rank) -> CodeGenFunction r (Value Size) Source # sizeOffset :: Index (T tag rank) ~ ix => T0 (T tag rank) -> CodeGenFunction r (Value Size, T0 ix -> CodeGenFunction r (Value Size)) Source # iterator :: Index (T tag rank) ~ ix => T0 (T tag rank) -> T1 r (T0 ix) Source # loop :: (Index (T tag rank) ~ ix, Phi state) => (T0 ix -> state -> CodeGenFunction r state) -> T0 (T tag rank) -> state -> CodeGenFunction r state Source # | |
(C n, C m) => C (n, m) Source # | |
Defined in Data.Array.Knead.Shape intersectCode :: T (n, m) -> T (n, m) -> CodeGenFunction r (T (n, m)) Source # size :: T (n, m) -> CodeGenFunction r (Value Size) Source # sizeOffset :: Index (n, m) ~ ix => T (n, m) -> CodeGenFunction r (Value Size, T ix -> CodeGenFunction r (Value Size)) Source # iterator :: Index (n, m) ~ ix => T (n, m) -> T r (T ix) Source # loop :: (Index (n, m) ~ ix, Phi state) => (T ix -> state -> CodeGenFunction r state) -> T (n, m) -> state -> CodeGenFunction r state Source # | |
C sh => C (Tagged tag sh) Source # | |
Defined in Data.Array.Knead.Shape intersectCode :: T (Tagged tag sh) -> T (Tagged tag sh) -> CodeGenFunction r (T (Tagged tag sh)) Source # size :: T (Tagged tag sh) -> CodeGenFunction r (Value Size) Source # sizeOffset :: Index (Tagged tag sh) ~ ix => T (Tagged tag sh) -> CodeGenFunction r (Value Size, T ix -> CodeGenFunction r (Value Size)) Source # iterator :: Index (Tagged tag sh) ~ ix => T (Tagged tag sh) -> T r (T ix) Source # loop :: (Index (Tagged tag sh) ~ ix, Phi state) => (T ix -> state -> CodeGenFunction r state) -> T (Tagged tag sh) -> state -> CodeGenFunction r state Source # | |
(C n, C m, C l) => C (n, m, l) Source # | |
Defined in Data.Array.Knead.Shape intersectCode :: T (n, m, l) -> T (n, m, l) -> CodeGenFunction r (T (n, m, l)) Source # size :: T (n, m, l) -> CodeGenFunction r (Value Size) Source # sizeOffset :: Index (n, m, l) ~ ix => T (n, m, l) -> CodeGenFunction r (Value Size, T ix -> CodeGenFunction r (Value Size)) Source # iterator :: Index (n, m, l) ~ ix => T (n, m, l) -> T r (T ix) Source # loop :: (Index (n, m, l) ~ ix, Phi state) => (T ix -> state -> CodeGenFunction r state) -> T (n, m, l) -> state -> CodeGenFunction r state Source # |
Instances
paramWith :: C b => T p b -> (forall parameters. C parameters => (p -> parameters) -> (forall val. Value val => T parameters -> val b) -> a) -> a Source #
ZeroBased
denotes a range starting at zero and has a certain length.
>>>
Shape.indices (Shape.ZeroBased (7::Int))
[0,1,2,3,4,5,6]
Instances
zeroBasedSize :: Value val => val (ZeroBased n) -> val n Source #
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 Array
s.
>>>
Shape.indices (Shape.Range (-5) (5::Int))
[-5,-4,-3,-2,-1,0,1,2,3,4,5]>>>
Shape.indices (Shape.Range (-1,-1) (1::Int,1::Int))
[(-1,-1),(-1,0),(-1,1),(0,-1),(0,0),(0,1),(1,-1),(1,0),(1,1)]
Range n n |
Instances
Shifted
denotes a range defined by the start index and the length.
>>>
Shape.indices (Shape.Shifted (-4) (8::Int))
[-4,-3,-2,-1,0,1,2,3]
Shifted n n |
Instances
shiftedOffset :: Value val => val (Shifted n) -> val n Source #
shiftedSize :: Value val => val (Shifted n) -> val n Source #
Cyclic
is a shape, where the indices wrap around at the array boundaries.
E.g.
let shape = Shape.Cyclic (10::Int) in Shape.offset shape (-1) == Shape.offset shape 9
This also means that there are multiple indices that address the same array element.
>>>
Shape.indices (Shape.Cyclic (7::Int))
[0,1,2,3,4,5,6]
Cyclic n |
Instances
cyclicSize :: Value val => val (Cyclic n) -> val n Source #
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.
>>>
Shape.indices (Shape.Enumeration :: Shape.Enumeration Ordering)
[LT,EQ,GT]
Instances
class (Enum enum, Bounded enum) => EnumBounded enum where Source #
enumOffset :: T enum -> CodeGenFunction r (Value Size) Source #
Instances
(ToSize w, Additive w, IsInteger w, IntegerConstant w, Num w, Repr w ~ Value w, CmpRet w, IsPrimitive w, Enum e, Bounded e) => EnumBounded (T w e) Source # | |
Defined in Data.Array.Knead.Shape enumOffset :: T0 (T w e) -> CodeGenFunction r (Value Size) Source # |
class (C sh, IntegerConstant (Index sh), Additive (Index sh)) => Sequence sh where Source #
sequenceShapeFromIndex :: T (Index sh) -> CodeGenFunction r (T sh) Source #
Instances
(Integral n, ToSize n, Comparison n) => Sequence (ZeroBased n) Source # | |
Defined in Data.Array.Knead.Shape sequenceShapeFromIndex :: T (Index (ZeroBased n)) -> CodeGenFunction r (T (ZeroBased n)) Source # |