Safe Haskell | None |
---|---|
Language | Haskell2010 |
Comments for this modules
Synopsis
- class Layout form (rank :: Nat) | form -> rank where
- basicLogicalShape :: form -> Shape rank Int
- basicLogicalForm :: logicalForm ~ LayoutLogicalFormat form => form -> logicalForm
- transposedLayout :: (form ~ Transposed transform, transform ~ Transposed form) => form -> transform
- basicCompareIndex :: p form -> Shape rank Int -> Shape rank Int -> Ordering
- basicAddressRange :: address ~ LayoutAddress form => form -> Maybe (Range address)
- basicToAddress :: address ~ LayoutAddress form => form -> Index rank -> Maybe address
- basicToIndex :: address ~ LayoutAddress form => form -> address -> Index rank
- basicNextAddress :: address ~ LayoutAddress form => form -> address -> Maybe address
- basicNextIndex :: address ~ LayoutAddress form => form -> Index rank -> Maybe address -> Maybe (Index rank, address)
- basicAddressPopCount :: address ~ LayoutAddress form => form -> Range address -> Int
- basicAddressAsInt :: address ~ LayoutAddress form => form -> address -> Int
- basicAffineAddressShift :: address ~ LayoutAddress form => form -> address -> Int -> Maybe address
- class Layout form rank => DenseLayout form (rank :: Nat) | form -> rank where
- basicToDenseAddress :: form -> Index rank -> Address
- basicToDenseIndex :: form -> Address -> Index rank
- basicNextDenseAddress :: form -> Address -> Address
- basicNextDenseIndex :: form -> Index rank -> (Index rank, Address)
- class Layout form rank => RectilinearLayout form (rank :: Nat) (oriented :: MajorOrientation) | form -> rank oriented where
- formRectOrientation :: p form -> SMajorOrientation oriented
- rectlinearShape :: form -> Index rank
- unconsOuter :: S down ~ rank => p form -> Shape rank a -> (a, Shape down a)
- consOuter :: S down ~ rank => p form -> a -> Shape down a -> Shape rank a
- majorAxisSlice :: form -> (Int, Int) -> form
- majorAxisProject :: (RectilinearLayout downForm subRank oriented, rank ~ S subRank, downForm ~ RectDownRankForm form) => form -> Int -> downForm
- rectlinearSlice :: (RectilinearLayout icForm rank oriented, icForm ~ InnerContigForm form) => form -> Index rank -> Index rank -> icForm
- type family LayoutAddress (form :: *) :: *
- type family LayoutLogicalFormat (form :: *) :: *
- type family Transposed (form :: *) :: *
- type family FormatStorageRep (a :: *) :: *
- type family RectOrientationForm form :: MajorOrientation
- type family RectDownRankForm form :: *
- type family InnerContigForm form :: *
- data family Format lay (contiguity :: Locality) (rank :: Nat) rep
- newtype TaggedShape (form :: *) (rank :: Nat) = TaggedShape {
- unTagShape :: Shape rank Int
- data GDSlice (from :: Nat) (to :: Nat) :: * where
- data SMajorOrientation (o :: MajorOrientation) where
- data MajorOrientation
- majorCompareRightToLeft :: Ordering -> Ordering -> Ordering
- majorCompareLeftToRight :: Ordering -> Ordering -> Ordering
- shapeCompareRightToLeft :: (Foldable (Shape r), Applicative (Shape r), Ord a) => Shape r a -> Shape r a -> Ordering
- shapeCompareLeftToRight :: (Foldable (Shape r), Applicative (Shape r), Ord a) => Shape r a -> Shape r a -> Ordering
- module Numerical.Array.Storage
- module Numerical.Array.Locality
- module Numerical.Array.Shape
- module Numerical.Array.Range
- module Numerical.Array.Address
Documentation
class Layout form (rank :: Nat) | form -> rank where Source #
the Layout
type class
basicToAddress, basicToIndex, basicNextAddress, basicNextIndex, basicAddressRange, basicLogicalShape, basicCompareIndex, transposedLayout, basicAddressPopCount, basicLogicalForm, basicAffineAddressShift
basicLogicalShape :: form -> Shape rank Int Source #
basicLogicalShape
gives the extent of the format
basicLogicalForm :: logicalForm ~ LayoutLogicalFormat form => form -> logicalForm Source #
basicLogicalForm
converts a given format into its "contiguous" analogue
this is useful for supporting various address translation manipulation tricks
efficiently. Note that any valid simple format should strive to ensure this is an O(1) operation.
though certain composite Layout
instances may provide a slower implementation.
transposedLayout :: (form ~ Transposed transform, transform ~ Transposed form) => form -> transform Source #
transposedLayout
transposes the format data type
basicCompareIndex :: p form -> Shape rank Int -> Shape rank Int -> Ordering Source #
basicCompareIndex
lets you compare where two (presumably inbounds)
Index
values are in a formats ordering. The logical Shape
of the array
is not needed
basicAddressRange :: address ~ LayoutAddress form => form -> Maybe (Range address) Source #
the (possibly empty) min and max of the valid addresses for a given format.
minAddress = fmap _RangeMin . rangedFormatAddress
and maxAddress = fmap _RangeMax . rangedFormatAddress
FIXME : This also is a terrible name
basicToAddress :: address ~ LayoutAddress form => form -> Index rank -> Maybe address Source #
basicToAddress
takes an Index, and tries to translate it to an address if its in bounds
basicToIndex :: address ~ LayoutAddress form => form -> address -> Index rank Source #
basicToIndex
takes an address, and always successfully translates it to
a valid index. Behavior of invalid addresses constructed by a library user
is unspecified.
basicNextAddress :: address ~ LayoutAddress form => form -> address -> Maybe address Source #
basicNextAddress
takes an address, and tries to compute the next valid
address, or returns Nothing if there is no subsequent valid address.
basicNextIndex :: address ~ LayoutAddress form => form -> Index rank -> Maybe address -> Maybe (Index rank, address) Source #
computes the next valid index after
basicNextIndex
form ix mbeAddressix
if it exists. It takes a
as a hint for where to do the search for the successor.
If the index is in bounds and not the last index, it returns both the index and the associated address.Maybe
address
basicAddressPopCount :: address ~ LayoutAddress form => form -> Range address -> Int Source #
basicAddressAsInt :: address ~ LayoutAddress form => form -> address -> Int Source #
This operation is REALLY unsafe This should ONLY be used on Formats that are directly paired with a Buffer or Mutable Buffer (ie a Vector) This operation being in this class is also kinda a hack but lets leave it here for now
basicAffineAddressShift :: address ~ LayoutAddress form => form -> address -> Int -> Maybe address Source #
The semantics of
is that
when step > 0, its equivalent to iteratively computing basicAffineAddressShift
form addr stepbasicNextAddress
step
times.
However, the step size can be negative, which means it can
Instances
class Layout form rank => DenseLayout form (rank :: Nat) | form -> rank where Source #
DenseLayout
only has instances for Dense array formats.
this class will need some sprucing up for the beta,
but its ok for now. NB that DenseLayout
is really strictly meant to be used
for optimization purposes, and not meant as a default api
basicToDenseAddress :: form -> Index rank -> Address Source #
basicToDenseIndex :: form -> Address -> Index rank Source #
basicNextDenseAddress :: form -> Address -> Address Source #
basicNextDenseIndex :: form -> Index rank -> (Index rank, Address) Source #
Instances
class Layout form rank => RectilinearLayout form (rank :: Nat) (oriented :: MajorOrientation) | form -> rank oriented where Source #
RectilinearLayout
is the type class that supports the modle widely
usable class of slicing operations in Numerical.
for every instance
, a corresponding
RectilinearLayout
format rank orientation
, RectOrientationForm
form
and RectDownRankForm
form
type family instance should be definedInnerContigForm
form
The purpose of RectilinearLayout
class is to provide
formRectOrientation :: p form -> SMajorOrientation oriented Source #
formRectOrientation
provides a runtime mechanism for reflecting
the orientation of the format
rectlinearShape :: form -> Index rank Source #
For
, we always have that
rectlinearShape
form==shp
.
when basicLogicalShape
form weaklyDominates
shpstrictlyDominates
holds, that implies that the underlying array format
is a rectilinear layout whose "elements" are tiles of a fixed size array format.
For this initial release and initial set of applicable rectilinear array formats,
the following is always true
Should be basicLogicalShape
form == basicLogicalShape' form O(1)
always. Or more precisely O(rank)
unconsOuter :: S down ~ rank => p form -> Shape rank a -> (a, Shape down a) Source #
consOuter :: S down ~ rank => p form -> a -> Shape down a -> Shape rank a Source #
majorAxisSlice :: form -> (Int, Int) -> form Source #
requires that y-x>=1, ie that more than
one sub range wrt the major axis be selected, so that the logical
rank of the selected array stays the same. This operation also preserves
memory locality as applicable.
majorAxisSlice
fm (x,y)O(1)
/ O(rank)
majorAxisProject :: (RectilinearLayout downForm subRank oriented, rank ~ S subRank, downForm ~ RectDownRankForm form) => form -> Int -> downForm Source #
picks a "row" with respect to the outer most
dimension of the array format. This will
majorAxixProject
form xO(1)
or O(rank)
rectlinearSlice :: (RectilinearLayout icForm rank oriented, icForm ~ InnerContigForm form) => form -> Index rank -> Index rank -> icForm Source #
this is the nonstrided subset of general array slice notation.
Invoke as
,
where the least and greatest corners of the sub array are determined
by the rectilinearSlice
form leastCorner greatestCornerstrictlyDominates
partial order on the bounds of the sub array.
For Dense array formats, this should be O(1)
or more precisely O(rank)
For the basic Sparse array formats thus far the complexity should be
O(size of outermost dimension)
, which could be computed by
fst . unconsOuter [form] . rectilinearShape $ form
type family LayoutAddress (form :: *) :: * Source #
Instances
type LayoutAddress (Format DirectSparse Contiguous (S Z) rep) Source # | |
Defined in Numerical.Array.Layout.Sparse | |
type LayoutAddress (Format CompressedSparseRow Contiguous (S (S Z)) rep) Source # | |
Defined in Numerical.Array.Layout.Sparse | |
type LayoutAddress (Format Column locality rank rep) Source # | |
Defined in Numerical.Array.Layout.Dense | |
type LayoutAddress (Format Row locality rank rep) Source # | |
Defined in Numerical.Array.Layout.Dense | |
type LayoutAddress (Format Direct Contiguous (S Z) rep) Source # | |
Defined in Numerical.Array.Layout.Dense | |
type LayoutAddress (Format Direct Strided (S Z) rep) Source # | |
Defined in Numerical.Array.Layout.Dense |
type family LayoutLogicalFormat (form :: *) :: * Source #
every format has a "logical" sibling, that represents the address translation
when the underlying buffer layer is contiguous and packed. So it could be claimed
that any type that obeys a~
is one that an be a legal
instance of LayoutBuilder?LayoutLogicalFormat
a
Instances
type LayoutLogicalFormat (Format Column cont n rep) Source # | |
Defined in Numerical.Array.Layout.Dense | |
type LayoutLogicalFormat (Format Row cont n rep) Source # | |
Defined in Numerical.Array.Layout.Dense | |
type LayoutLogicalFormat (Format Direct cont (S Z) rep) Source # | |
Defined in Numerical.Array.Layout.Dense | |
type LayoutLogicalFormat (Format Direct Contiguous (S Z) rep) Source # | |
Defined in Numerical.Array.Layout.Dense |
type family Transposed (form :: *) :: * Source #
Instances
type family FormatStorageRep (a :: *) :: * Source #
Instances
type FormatStorageRep (Format lay ctg rnk rep) Source # | |
Defined in Numerical.Array.Layout.Base |
type family RectOrientationForm form :: MajorOrientation Source #
Every instance of RectilinearLayout
needs to have a corresponding
RectOrientationForm
, RectDownRankForm
, and InnerContigForm
type family RectDownRankForm form :: * Source #
type family InnerContigForm form :: * Source #
data family Format lay (contiguity :: Locality) (rank :: Nat) rep Source #
Instances
newtype TaggedShape (form :: *) (rank :: Nat) Source #
this is kinda a hack
TaggedShape | |
|
Instances
data GDSlice (from :: Nat) (to :: Nat) :: * where Source #
Generalized Dense Slice Projection notation, not sure if it should be defined in this module or elsewhere This provides a type safe interface for the classical general array slice notation. That said, its only useful for dense array formats, at least in general. For formats that aren't "rectilinear dense", this COULD be used as a description format for traversing over various rectilinear subsets of points though?
GDNil :: GDSlice Z Z | |
GDPick :: Int -> !(GDSlice from to) -> GDSlice (S from) to | |
GDRange :: (Int, Int, Int) -> !(GDSlice from to) -> GDSlice (S from) (S to) | |
GDAll :: !(GDSlice from to) -> GDSlice (S from) (S to) |
data SMajorOrientation (o :: MajorOrientation) where Source #
data MajorOrientation Source #
these names aren't ideal, but lets punt on bikeshedding till theres >= 2 serious users
Instances
Data MajorOrientation Source # | |
Defined in Numerical.Array.Layout.Base gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> MajorOrientation -> c MajorOrientation # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c MajorOrientation # toConstr :: MajorOrientation -> Constr # dataTypeOf :: MajorOrientation -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c MajorOrientation) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c MajorOrientation) # gmapT :: (forall b. Data b => b -> b) -> MajorOrientation -> MajorOrientation # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> MajorOrientation -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> MajorOrientation -> r # gmapQ :: (forall d. Data d => d -> u) -> MajorOrientation -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> MajorOrientation -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> MajorOrientation -> m MajorOrientation # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> MajorOrientation -> m MajorOrientation # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> MajorOrientation -> m MajorOrientation # |
shapeCompareRightToLeft :: (Foldable (Shape r), Applicative (Shape r), Ord a) => Shape r a -> Shape r a -> Ordering Source #
shapeCompareLeftToRight :: (Foldable (Shape r), Applicative (Shape r), Ord a) => Shape r a -> Shape r a -> Ordering Source #
All the various helper types
module Numerical.Array.Storage
module Numerical.Array.Locality
module Numerical.Array.Shape
module Numerical.Array.Range
module Numerical.Array.Address