Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell98 |
Shapes and Indices
- class Eq sh => Shape sh where
- rank :: sh -> Int
- zeroDim :: sh
- unitDim :: sh
- intersectDim :: sh -> sh -> sh
- addDim :: sh -> sh -> sh
- size :: sh -> Int
- inShapeRange :: sh -> sh -> sh -> Bool
- listOfShape :: sh -> [Int]
- shapeOfList :: [Int] -> Maybe sh
- 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)) | |
(Eq tail, Eq head) => Eq ((:.) tail head) | |
(Ord tail, Ord head) => Ord ((:.) tail head) | |
(Read tail, Read head) => Read ((:.) tail head) | |
(Show tail, Show head) => Show ((:.) tail head) | |
Shape sh => Shape ((:.) sh Int) | |
Slice sl => Slice ((:.) sl All) | |
Slice sl => Slice ((:.) sl Int) | |
data Name (RW ((:.) sh Int)) = RC (Name (RW sh)) | |
type Index (RW ((:.) sh Int)) = (:.) sh Int | |
type SliceShape ((:.) sl All) = (:.) (SliceShape sl) Int | |
type SliceShape ((:.) sl Int) = SliceShape sl | |
type FullShape ((:.) sl All) = (:.) (FullShape sl) Int | |
type FullShape ((:.) sl Int) = (:.) (FullShape sl) Int |
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.
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 B | Boxed arrays. |
Layout F | Foreign arrays. |
Layout U | Unboxed arrays. |
Layout N | Nested arrays. |
Layout L | Linear layout. |
(Layout (RW sh), (~) * (Index (RW sh)) sh) => Layout (RW ((:.) sh Int)) | |
Layout (RW Z) | |
Layout l => Layout (W l) | Windowed arrays. |
Layout l => Layout (D l) | Delayed arrays. |
((~) * (Index r) Int, Layout r, Layout l) => Layout (E r l) | Dense arrays. |
(Layout l1, Layout l2, (~) * (Index l1) (Index l2)) => Layout (D2 l1 l2) | Delayed arrays. |
((~) * (Index l1) (Index l2), Layout l1, Layout l2) => Layout (T2 l1 l2) |