repa-array-4.1.0.1: Bulk array representations and operators.

Safe HaskellSafe-Inferred
LanguageHaskell98

Data.Repa.Array.Generic.Index

Contents

Description

Shapes and Indices

Synopsis

Shapes

class Eq sh => Shape sh where Source

Class of types that can be used as array shapes and indices.

Methods

rank :: sh -> Int Source

Get the number of dimensions in a shape.

zeroDim :: sh Source

The shape of an array of size zero, with a particular dimensionality.

unitDim :: sh Source

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

size :: sh -> Int Source

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

Instances

Shape Int 
Shape Z 
Shape sh => Shape (RW sh) 
Shape sh => Shape ((:.) sh Int) 

inShape :: Shape sh => sh -> sh -> Bool Source

Given an array shape and index, check whether the index is in the shape.

showShape :: Shape sh => sh -> String Source

Nicely format a shape as a string

Polymorphic Shapes

data Z Source

An index of dimension zero

Constructors

Z 

Instances

Eq Z 
Ord Z 
Read Z 
Show Z 
Shape Z 
Slice Z 
Eq (Name (RW Z)) 
Show (Name (RW Z)) 
Layout (RW Z) 
type SliceShape Z = Z 
type FullShape Z = Z 
data Name (RW Z) = RZ 
type Index (RW Z) = Z 

data tail :. head infixl 3 Source

Our index type, used for both shapes and indices.

Constructors

!tail :. !head infixl 3 

Instances

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.

type SH0 = Z Source

Helpers that constrain the coordinates to be Ints.

ish2 :: Int -> Int -> SH2 Source

ish3 :: Int -> Int -> Int -> SH3 Source

ish4 :: Int -> Int -> Int -> Int -> SH4 Source

ish5 :: Int -> Int -> Int -> Int -> Int -> SH5 Source

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.

Associated Types

data Name l Source

Short name for a layout which does not include details of the exact extent.

type Index l Source

Type used to index into this array layout.

Methods

name :: Name l Source

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.

Instances

Layout S 
Layout L

Linear layout.

Layout B

Boxed arrays.

Layout F

Foreign arrays.

Layout U

Unboxed arrays.

Layout N

Nested arrays.

Layout A 
Layout l => Layout (W l)

Windowed arrays.

(Layout (RW sh), (~) * (Index (RW sh)) sh) => Layout (RW ((:.) sh Int)) 
Layout (RW Z) 
Layout l => Layout (D l)

Delayed arrays.

(Layout l1, Layout l2, (~) * (Index l1) (Index l2)) => Layout (D2 l1 l2)

Delayed arrays.

((~) * (Index r) Int, Layout r, Layout l) => Layout (E r l)

Dense arrays.

((~) * (Index l1) (Index l2), Layout l1, Layout l2) => Layout (T2 l1 l2) 

type LayoutI l = (Layout l, Index l ~ Int) Source