Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data family MArray world rep lay (view :: Locality) (rank :: Nat) st el
- class PureArray (ArrPure marr) rank a => Array marr (rank :: Nat) a | marr -> rank where
- type ArrPure (marr :: * -> * -> *) :: * -> *
- type MArrayAddress (marr :: * -> * -> *) :: *
- basicUnsafeAffineAddressShift :: address ~ MArrayAddress marr => marr st a -> Int -> address -> address
- basicUnsafeFreeze :: (PrimMonad m, arr ~ ArrPure marr, marr ~ ArrMutable arr) => marr (PrimState m) a -> m (arr a)
- basicUnsafeThaw :: (PrimMonad m, marr ~ ArrMutable arr, arr ~ ArrPure marr) => arr a -> m (marr (PrimState m) a)
- basicShape :: marr st a -> Index rank
- basicCardinality :: address ~ MArrayAddress marr => marr st a -> Range address -> Int
- basicSparseIndexToAddress :: address ~ MArrayAddress marr => marr s a -> Index rank -> Maybe address
- basicAddressToIndex :: address ~ MArrayAddress marr => marr s a -> address -> Index rank
- basicAddressRange :: address ~ MArrayAddress marr => marr st a -> Maybe (Range address)
- basicSparseNextAddress :: address ~ MArrayAddress marr => marr st a -> address -> Maybe address
- basicSparseNextIndex :: address ~ MArrayAddress marr => marr st a -> Index rank -> Maybe address -> Maybe (Index rank, address)
- basicLocalAffineAddressRegion :: address ~ MArrayAddress marr => marr st a -> address -> AffineRange address
- basicOverlaps :: marr st a -> marr st a -> Bool
- basicClear :: PrimMonad m => marr (PrimState m) a -> m ()
- basicUnsafeAddressRead :: (PrimMonad m, address ~ MArrayAddress marr) => marr (PrimState m) a -> address -> m a
- basicUnsafeAddressWrite :: (PrimMonad m, address ~ MArrayAddress marr) => marr (PrimState m) a -> address -> a -> m ()
- basicUnsafeSparseRead :: PrimMonad m => marr (PrimState m) a -> Index rank -> m (Maybe a)
- class RectilinearArray marr rank a | marr -> rank where
- type MutableRectilinearOrientation marr :: *
- type MutableArrayDownRank marr (st :: *) a
- type MutableInnerContigArray (marr :: * -> * -> *) st a
- basicMutableSliceMajorAxis :: PrimMonad m => marr (PrimState m) a -> (Int, Int) -> m (marr (PrimState m) a)
- basicMutableProjectMajorAxis :: PrimMonad m => marr (PrimState m) a -> Int -> m (MutableArrayDownRank marr (PrimState m) a)
- basicMutableSlice :: PrimMonad m => marr (PrimState m) a -> Index rank -> Index rank -> m (MutableInnerContigArray marr (PrimState m) a)
- class DenseArray marr rank a => DenseArrayBuilder marr rank a where
- basicUnsafeNew :: PrimMonad m => Index rank -> m (marr (PrimState m) a)
- basicUnsafeReplicate :: PrimMonad m => Index rank -> a -> m (marr (PrimState m) a)
- class (Array marr rank a, PureDenseArray (ArrPure marr) rank a) => DenseArray marr rank a | marr -> rank where
- basicIndexInBounds :: marr st a -> Index rank -> Bool
- basicUnsafeDenseRead :: PrimMonad m => marr (PrimState m) a -> Index rank -> m a
- basicUnsafeDenseWrite :: PrimMonad m => marr (PrimState m) a -> Index rank -> a -> m ()
- basicNextAddress :: marr st a -> Address -> Address
- basicNextIndex :: marr st a -> Index rank -> Index rank
- data Boxed
- data Unboxed
- data Stored
- module Numerical.Array.Shape
Documentation
data family MArray world rep lay (view :: Locality) (rank :: Nat) st el Source #
MArray
is the generic data family that
Instances
(Buffer rep el, Layout (Format lay locality rank rep) rank) => Array (MArray Native rep lay locality rank) rank el Source # | |
Defined in Numerical.Array.Mutable type ArrPure (MArray Native rep lay locality rank) :: Type -> Type Source # type MArrayAddress (MArray Native rep lay locality rank) :: Type Source # basicUnsafeAffineAddressShift :: address ~ MArrayAddress (MArray Native rep lay locality rank) => MArray Native rep lay locality rank st el -> Int -> address -> address Source # basicUnsafeFreeze :: (PrimMonad m, arr ~ ArrPure (MArray Native rep lay locality rank), MArray Native rep lay locality rank ~ ArrMutable arr) => MArray Native rep lay locality rank (PrimState m) el -> m (arr el) Source # basicUnsafeThaw :: (PrimMonad m, MArray Native rep lay locality rank ~ ArrMutable arr, arr ~ ArrPure (MArray Native rep lay locality rank)) => arr el -> m (MArray Native rep lay locality rank (PrimState m) el) Source # basicShape :: MArray Native rep lay locality rank st el -> Index rank Source # basicCardinality :: address ~ MArrayAddress (MArray Native rep lay locality rank) => MArray Native rep lay locality rank st el -> Range address -> Int Source # basicSparseIndexToAddress :: address ~ MArrayAddress (MArray Native rep lay locality rank) => MArray Native rep lay locality rank s el -> Index rank -> Maybe address Source # basicAddressToIndex :: address ~ MArrayAddress (MArray Native rep lay locality rank) => MArray Native rep lay locality rank s el -> address -> Index rank Source # basicAddressRange :: address ~ MArrayAddress (MArray Native rep lay locality rank) => MArray Native rep lay locality rank st el -> Maybe (Range address) Source # basicSparseNextAddress :: address ~ MArrayAddress (MArray Native rep lay locality rank) => MArray Native rep lay locality rank st el -> address -> Maybe address Source # basicSparseNextIndex :: address ~ MArrayAddress (MArray Native rep lay locality rank) => MArray Native rep lay locality rank st el -> Index rank -> Maybe address -> Maybe (Index rank, address) Source # basicLocalAffineAddressRegion :: address ~ MArrayAddress (MArray Native rep lay locality rank) => MArray Native rep lay locality rank st el -> address -> AffineRange address Source # basicOverlaps :: MArray Native rep lay locality rank st el -> MArray Native rep lay locality rank st el -> Bool Source # basicClear :: PrimMonad m => MArray Native rep lay locality rank (PrimState m) el -> m () Source # basicUnsafeAddressRead :: (PrimMonad m, address ~ MArrayAddress (MArray Native rep lay locality rank)) => MArray Native rep lay locality rank (PrimState m) el -> address -> m el Source # basicUnsafeAddressWrite :: (PrimMonad m, address ~ MArrayAddress (MArray Native rep lay locality rank)) => MArray Native rep lay locality rank (PrimState m) el -> address -> el -> m () Source # basicUnsafeSparseRead :: PrimMonad m => MArray Native rep lay locality rank (PrimState m) el -> Index rank -> m (Maybe el) Source # | |
data MArray Native rep lay locality rank st el Source # | |
Defined in Numerical.Array.Mutable data MArray Native rep lay locality rank st el = MutableNativeArray {
| |
type ArrPure (MArray Native rep lay locality rank) Source # | |
type MArrayAddress (MArray Native rep lay locality rank) Source # | |
Defined in Numerical.Array.Mutable type MArrayAddress (MArray Native rep lay locality rank) = LayoutAddress (Format lay locality rank rep) |
class PureArray (ArrPure marr) rank a => Array marr (rank :: Nat) a | marr -> rank where Source #
type ArrPure (marr :: * -> * -> *) :: * -> * Source #
type MArrayAddress (marr :: * -> * -> *) :: * Source #
basicUnsafeAffineAddressShift :: address ~ MArrayAddress marr => marr st a -> Int -> address -> address Source #
basicUnsafeAffineAddressShift
is needed to handle abstracting access in popcount space
basicUnsafeFreeze :: (PrimMonad m, arr ~ ArrPure marr, marr ~ ArrMutable arr) => marr (PrimState m) a -> m (arr a) Source #
Unsafely convert a mutable Array to its immutable version without copying. The mutable Array may not be used after this operation. Assumed O(1) complexity
basicUnsafeThaw :: (PrimMonad m, marr ~ ArrMutable arr, arr ~ ArrPure marr) => arr a -> m (marr (PrimState m) a) Source #
Unsafely convert a pure Array to its mutable version without copying. the pure array may not be used after this operation. Assumed O(1) complexity
basicShape :: marr st a -> Index rank Source #
gives the shape, a rank
length list of the dimensions
basicCardinality :: address ~ MArrayAddress marr => marr st a -> Range address -> Int Source #
basicCardinality
reports the number of manifest addresses/entries are
in the array in a given address sub range.
This is useful for determining when to switch from a recursive algorithm
to a direct algorithm.
Should this be renamed to something like basicPopCount/
basicSparseIndexToAddress :: address ~ MArrayAddress marr => marr s a -> Index rank -> Maybe address Source #
basicAddressToIndex :: address ~ MArrayAddress marr => marr s a -> address -> Index rank Source #
basicMutableAddressToIndex
assumes you only give it legal manifest addresses
basicAddressRange :: address ~ MArrayAddress marr => marr st a -> Maybe (Range address) Source #
return the smallest and largest valid logical address
basicSparseNextAddress :: address ~ MArrayAddress marr => marr st a -> address -> Maybe address Source #
gives the next valid logical address undefined on invalid addresses and the greatest valid address. Note that for invalid addresses in between minAddress and maxAddress, will return the next valid address.
basicSparseNextIndex :: address ~ MArrayAddress marr => marr st a -> Index rank -> Maybe address -> Maybe (Index rank, address) Source #
gives the next valid array index, the least valid index that is or
basicLocalAffineAddressRegion :: address ~ MArrayAddress marr => marr st a -> address -> AffineRange address Source #
for a given valid address,
will return an AddressInterval
that contains basicAddressRegion
addr addr
. This will be a singleton when the "maximal uniform stride interval"
containing addr
has strictly less than 3 elements. Otherwise will return an Address range
covering the maximal interval that will have cardinality at least 3.
basicOverlaps :: marr st a -> marr st a -> Bool Source #
this doesn't quite fit in this class, but thats ok, will deal with that later
basicClear :: PrimMonad m => marr (PrimState m) a -> m () Source #
Reset all elements of the vector to some undefined value, clearing all
references to external objects. This is usually a noop for unboxed
vectors. This method should not be called directly, use clear
instead.
basicUnsafeAddressRead :: (PrimMonad m, address ~ MArrayAddress marr) => marr (PrimState m) a -> address -> m a Source #
basicUnsafeAddressWrite :: (PrimMonad m, address ~ MArrayAddress marr) => marr (PrimState m) a -> address -> a -> m () Source #
basicUnsafeSparseRead :: PrimMonad m => marr (PrimState m) a -> Index rank -> m (Maybe a) Source #
Yield the element at the given position. This method should not be
called directly, use unsafeSparseRead
instead.
Instances
(Buffer rep el, Layout (Format lay locality rank rep) rank) => Array (MArray Native rep lay locality rank) rank el Source # | |
Defined in Numerical.Array.Mutable type ArrPure (MArray Native rep lay locality rank) :: Type -> Type Source # type MArrayAddress (MArray Native rep lay locality rank) :: Type Source # basicUnsafeAffineAddressShift :: address ~ MArrayAddress (MArray Native rep lay locality rank) => MArray Native rep lay locality rank st el -> Int -> address -> address Source # basicUnsafeFreeze :: (PrimMonad m, arr ~ ArrPure (MArray Native rep lay locality rank), MArray Native rep lay locality rank ~ ArrMutable arr) => MArray Native rep lay locality rank (PrimState m) el -> m (arr el) Source # basicUnsafeThaw :: (PrimMonad m, MArray Native rep lay locality rank ~ ArrMutable arr, arr ~ ArrPure (MArray Native rep lay locality rank)) => arr el -> m (MArray Native rep lay locality rank (PrimState m) el) Source # basicShape :: MArray Native rep lay locality rank st el -> Index rank Source # basicCardinality :: address ~ MArrayAddress (MArray Native rep lay locality rank) => MArray Native rep lay locality rank st el -> Range address -> Int Source # basicSparseIndexToAddress :: address ~ MArrayAddress (MArray Native rep lay locality rank) => MArray Native rep lay locality rank s el -> Index rank -> Maybe address Source # basicAddressToIndex :: address ~ MArrayAddress (MArray Native rep lay locality rank) => MArray Native rep lay locality rank s el -> address -> Index rank Source # basicAddressRange :: address ~ MArrayAddress (MArray Native rep lay locality rank) => MArray Native rep lay locality rank st el -> Maybe (Range address) Source # basicSparseNextAddress :: address ~ MArrayAddress (MArray Native rep lay locality rank) => MArray Native rep lay locality rank st el -> address -> Maybe address Source # basicSparseNextIndex :: address ~ MArrayAddress (MArray Native rep lay locality rank) => MArray Native rep lay locality rank st el -> Index rank -> Maybe address -> Maybe (Index rank, address) Source # basicLocalAffineAddressRegion :: address ~ MArrayAddress (MArray Native rep lay locality rank) => MArray Native rep lay locality rank st el -> address -> AffineRange address Source # basicOverlaps :: MArray Native rep lay locality rank st el -> MArray Native rep lay locality rank st el -> Bool Source # basicClear :: PrimMonad m => MArray Native rep lay locality rank (PrimState m) el -> m () Source # basicUnsafeAddressRead :: (PrimMonad m, address ~ MArrayAddress (MArray Native rep lay locality rank)) => MArray Native rep lay locality rank (PrimState m) el -> address -> m el Source # basicUnsafeAddressWrite :: (PrimMonad m, address ~ MArrayAddress (MArray Native rep lay locality rank)) => MArray Native rep lay locality rank (PrimState m) el -> address -> el -> m () Source # basicUnsafeSparseRead :: PrimMonad m => MArray Native rep lay locality rank (PrimState m) el -> Index rank -> m (Maybe el) Source # |
class RectilinearArray marr rank a | marr -> rank where Source #
type MutableRectilinearOrientation marr :: * Source #
should equal Row or Column for any sane choice
of instance, because every MutableRectilinear instance will have a notion of
what the nominal major axix will be.
The intended use case is side condition constraints like
MutableRectilinearOrientation
marr
for operations where majorAxix projections are correct only for Row
major formats. Such as Row based forward/backward substitution (triangular solvers)MutableRectilinearOrientation
marr~Row)=> marr -> b
type MutableArrayDownRank marr (st :: *) a Source #
type MutableInnerContigArray (marr :: * -> * -> *) st a Source #
MutableInnerContigArray is the "meet" (minimum) of the locality level of marr and InnerContiguous. Thus both Contiguous and InnerContiguous are made InnerContiguous, and Strided stays Strided for now this makes sense to have in the MutableRectilinear class, though that may change. This could also be thought of as being the GLB (greatest lower bound) on locality
basicMutableSliceMajorAxis :: PrimMonad m => marr (PrimState m) a -> (Int, Int) -> m (marr (PrimState m) a) Source #
returns the sub array of the same rank,
with the outermost (ie major axis) dimension of arr restricted to the
(x,y) is an inclusive interval, MUST satisfy x<y , and be a valid
subinterval of the major axis of arr.basicSliceMajorAxis
arr (x,y)
basicMutableProjectMajorAxis :: PrimMonad m => marr (PrimState m) a -> Int -> m (MutableArrayDownRank marr (PrimState m) a) Source #
basicMutableSlice :: PrimMonad m => marr (PrimState m) a -> Index rank -> Index rank -> m (MutableInnerContigArray marr (PrimState m) a) Source #
picks out the (hyper) rectangle in dimension basicMutableSlice
arr ix1 ix2rank
where ix1 is the minimal corner and ix2
class DenseArray marr rank a => DenseArrayBuilder marr rank a where Source #
class (Array marr rank a, PureDenseArray (ArrPure marr) rank a) => DenseArray marr rank a | marr -> rank where Source #
basicIndexInBounds :: marr st a -> Index rank -> Bool Source #
for Dense arrays, it is always easy to check if a given index is valid. this operation better have O(1) complexity or else!
basicUnsafeDenseRead :: PrimMonad m => marr (PrimState m) a -> Index rank -> m a Source #
Yield the element at the given position. This method should not be
called directly, use unsafeRead
instead.
basicUnsafeDenseWrite :: PrimMonad m => marr (PrimState m) a -> Index rank -> a -> m () Source #
Replace the element at the given position. This method should not be
called directly, use unsafeWrite
instead.
basicNextAddress :: marr st a -> Address -> Address Source #
gives the next valid logical address undefined on invalid addresses and the greatest valid address. Note that for invalid addresses in between minAddress and maxAddress, will return the next valid address.
basicNextIndex :: marr st a -> Index rank -> Index rank Source #
gives the next valid array index undefined on invalid indices and the greatest valid index
Boxed
is the type index for Buffer
s that use the boxed data structure Vector
as the underlying storage representation.
Instances
Unboxed
is the type index for Buffer
s that use the unboxed data structure
Vector
as the underlying storage representation.
Instances
Stored
is the type index for Buffer
s that use the Storable
for values, in pinned byte array buffers, provided by Storable
Instances
module Numerical.Array.Shape