Safe Haskell | Safe |
---|---|
Language | Haskell98 |
Shapes and Indices
- class Eq sh => Shape sh where
- inShape :: Shape sh => sh -> sh -> Bool
- showShape :: Shape sh => sh -> String
- data Z = Z
- data tail :. head = !tail :. !head
- type SH0 = Z
- type SH1 = SH0 :. Int
- type SH2 = SH1 :. Int
- type SH3 = SH2 :. Int
- type SH4 = SH3 :. Int
- type SH5 = SH4 :. Int
- ish0 :: SH0
- ish1 :: Int -> SH1
- ish2 :: Int -> Int -> SH2
- ish3 :: Int -> Int -> Int -> SH3
- ish4 :: Int -> Int -> Int -> Int -> SH4
- ish5 :: Int -> Int -> Int -> Int -> Int -> SH5
- class Shape (Index l) => Layout l where
- type LayoutI l = (Layout l, Index l ~ Int)
Shapes
class Eq sh => Shape sh where Source #
Class of types that can be used as array shapes and indices.
Get the number of dimensions in a shape.
The shape of an array of size zero, with a particular dimensionality.
The shape of an array with size one, with a particular dimensionality.
intersectDim :: sh -> sh -> sh Source #
Compute the intersection of two shapes.
addDim :: sh -> sh -> sh Source #
Add the coordinates of two shapes componentwise
Get the total number of elements in an array with this shape.
inShapeRange :: sh -> sh -> sh -> Bool Source #
Given a starting and ending index, check if some index is with that range.
listOfShape :: sh -> [Int] Source #
Convert a shape into its list of dimensions.
shapeOfList :: [Int] -> Maybe sh Source #
Convert a list of dimensions to a shape
inShape :: Shape sh => sh -> sh -> Bool Source #
Given an array shape and index, check whether the index is in the shape.
Polymorphic Shapes
An index of dimension zero
data tail :. head infixl 3 Source #
Our index type, used for both shapes and indices.
!tail :. !head infixl 3 |
Eq (Name (RW sh)) => Eq (Name (RW ((:.) sh Int))) # | |
Show (Name (RW sh)) => Show (Name (RW ((:.) sh Int))) # | |
(Layout (RW sh), (~) * (Index (RW sh)) sh) => Layout (RW ((:.) sh Int)) Source # | |
(Eq tail, Eq head) => Eq ((:.) tail head) Source # | |
(Ord tail, Ord head) => Ord ((:.) tail head) Source # | |
(Read tail, Read head) => Read ((:.) tail head) Source # | |
(Show tail, Show head) => Show ((:.) tail head) Source # | |
Shape sh => Shape ((:.) sh Int) Source # | |
Slice sl => Slice ((:.) sl All) Source # | |
Slice sl => Slice ((:.) sl Int) Source # | |
data Name (RW ((:.) sh Int)) Source # | |
type Index (RW ((:.) sh Int)) Source # | |
type SliceShape ((:.) sl All) Source # | |
type SliceShape ((:.) sl Int) Source # | |
type FullShape ((:.) sl All) Source # | |
type FullShape ((:.) sl Int) Source # | |
Synonyms for common layouts.
Helpers that constrain the coordinates to be Int
s.
Layouts
class Shape (Index l) => Layout l where Source #
A layout provides a total order on the elements of an index space.
We can talk about the n-th element of an array, independent of its shape and dimensionality.
Short name for a layout which does not include details of the exact extent.
Type used to index into this array layout.
O(1). Proxy for the layout name.
create :: Name l -> Index l -> l Source #
O(1). Create a default layout of the given extent.
extent :: l -> Index l Source #
O(1). Yield the extent of the layout.
toIndex :: l -> Index l -> Int Source #
O(1). Convert a polymorphic index to a linear one.
fromIndex :: l -> Int -> Index l Source #
O(1). Convert a linear index to a polymorphic one.
Layout L Source # | Linear layout. |
Layout B Source # | Boxed arrays. |
Layout F Source # | Foreign arrays. |
Layout U Source # | Unboxed arrays. |
Layout N Source # | Nested arrays. |
Layout A Source # | |
Layout l => Layout (W l) Source # | Windowed arrays. |
(Layout (RW sh), (~) * (Index (RW sh)) sh) => Layout (RW ((:.) sh Int)) Source # | |
Layout (RW Z) Source # | |
Layout l => Layout (D l) Source # | Delayed arrays. |
(Layout l1, Layout l2, (~) * (Index l1) (Index l2)) => Layout (D2 l1 l2) Source # | Delayed arrays. |
((~) * (Index r) Int, Layout r, Layout l) => Layout (E r l) Source # | Dense arrays. |
((~) * (Index l1) (Index l2), Layout l1, Layout l2) => Layout (T2 l1 l2) Source # | |