Safe Haskell | None |
---|---|
Language | Haskell98 |
Dataflow (fusion operations)
- class Fusion r fr l sh => DefaultFusion r fr l sh | r -> fr where
- class IFusion r l fr fl sh => DefaultIFusion r l fr fl sh | r l -> fr where
- dzipWith :: (USource r1 l sh a, DefaultFusion r1 D l sh, USource D l sh a, USource r2 l sh b, DefaultFusion r2 D l sh, USource D l sh b, USource D l sh c, DefaultFusion D D l sh) => (a -> b -> c) -> UArray r1 l sh a -> UArray r2 l sh b -> UArray D l sh c
- dzipWith3 :: (USource r1 l sh a, DefaultFusion r1 D l sh, USource D l sh a, USource r2 l sh b, DefaultFusion r2 D l sh, USource D l sh b, USource r3 l sh c, DefaultFusion r3 D l sh, USource D l sh c, USource D l sh d, DefaultFusion D D l sh) => (a -> b -> c -> d) -> UArray r1 l sh a -> UArray r2 l sh b -> UArray r3 l sh c -> UArray D l sh d
- data D
- delay :: (USource r l sh a, USource D l sh a, Fusion r D l sh) => UArray r l sh a -> UArray D l sh a
- data SE r
- dmapElems :: (VecRegular r slr l sh v a, USource slr l sh a, USource fslr l sh b, DefaultFusion slr fslr l sh, Vector v2 b, Dim v ~ Dim v2) => VecList (Dim v) (a -> b) -> UArray r l sh (v a) -> UArray (SE fslr) l sh (v2 b)
- dmapElemsM :: (VecRegular r slr l sh v a, USource slr l sh a, USource fslr l sh b, DefaultFusion slr fslr l sh, Vector v2 b, Dim v ~ Dim v2) => VecList (Dim v) (a -> IO b) -> UArray r l sh (v a) -> UArray (SE fslr) l sh (v2 b)
- dzipElems2 :: (VecRegular r slr l sh v a, USource slr l sh a, VecRegular r slr l sh v b, USource slr l sh b, USource fslr l sh c, DefaultFusion slr fslr l sh, Vector v c) => VecList (Dim v) (a -> b -> c) -> UArray r l sh (v a) -> UArray r l sh (v b) -> UArray (SE fslr) l sh (v c)
- dzipElems2M :: (VecRegular r slr l sh v a, USource slr l sh a, VecRegular r slr l sh v b, USource slr l sh b, USource fslr l sh c, DefaultFusion slr fslr l sh, Vector v c) => VecList (Dim v) (a -> b -> IO c) -> UArray r l sh (v a) -> UArray r l sh (v b) -> UArray (SE fslr) l sh (v c)
- dzipElems3 :: (VecRegular r slr l sh v a, USource slr l sh a, VecRegular r slr l sh v b, USource slr l sh b, VecRegular r slr l sh v c, USource slr l sh c, USource fslr l sh d, DefaultFusion slr fslr l sh, Vector v d) => VecList (Dim v) (a -> b -> c -> d) -> UArray r l sh (v a) -> UArray r l sh (v b) -> UArray r l sh (v c) -> UArray (SE fslr) l sh (v d)
- dzipElems3M :: (VecRegular r slr l sh v a, USource slr l sh a, VecRegular r slr l sh v b, USource slr l sh b, VecRegular r slr l sh v c, USource slr l sh c, USource fslr l sh d, DefaultFusion slr fslr l sh, Vector v d) => VecList (Dim v) (a -> b -> c -> IO d) -> UArray r l sh (v a) -> UArray r l sh (v b) -> UArray r l sh (v c) -> UArray (SE fslr) l sh (v d)
- dzipElems :: (Vector v2 b, Arity m, m ~ S m0, VecRegular r slr l sh v a, USource slr l sh a, USource fslr l sh b, DefaultFusion slr fslr l sh) => VecList (Dim v2) (Fun m a b) -> VecList m (UArray r l sh (v a)) -> UArray (SE fslr) l sh (v2 b)
- dzipElemsM :: (Vector v2 b, Arity m, m ~ S m0, VecRegular r slr l sh v a, USource slr l sh a, USource fslr l sh b, DefaultFusion slr fslr l sh) => VecList (Dim v2) (Fun m a (IO b)) -> VecList m (UArray r l sh (v a)) -> UArray (SE fslr) l sh (v2 b)
- traverse :: (USource r l sh a, Shape sh') => (sh -> sh') -> ((sh -> IO a) -> sh' -> IO b) -> UArray r l sh a -> UArray D SH sh' b
- zipElems :: (Vector v a, USource r l sh (v a), USource fr l sh b, DefaultFusion r fr l sh) => Fn (Dim v) a b -> UArray r l sh (v a) -> UArray fr l sh b
- mapElems :: (VecRegular r slr l sh v a, USource slr l sh a, USource fslr l sh b, DefaultFusion slr fslr l sh, Vector v b) => (a -> b) -> UArray r l sh (v a) -> UArray (SE fslr) l sh (v b)
- mapElemsM :: (VecRegular r slr l sh v a, USource slr l sh a, USource fslr l sh b, DefaultFusion slr fslr l sh, Vector v b) => (a -> IO b) -> UArray r l sh (v a) -> UArray (SE fslr) l sh (v b)
- cartProduct2 :: (USource r1 l1 Dim1 a, USource r2 l2 Dim1 b) => (a -> b -> c) -> UArray r1 l1 Dim1 a -> UArray r2 l2 Dim1 b -> UArray D SH Dim2 c
- icartProduct2 :: (USource r1 l1 Dim1 a, USource r2 l2 Dim1 b) => (Dim2 -> a -> b -> c) -> UArray r1 l1 Dim1 a -> UArray r2 l2 Dim1 b -> UArray D SH Dim2 c
- icartProduct2M :: (USource r1 l1 Dim1 a, USource r2 l2 Dim1 b) => (Dim2 -> a -> b -> IO c) -> UArray r1 l1 Dim1 a -> UArray r2 l2 Dim1 b -> UArray D SH Dim2 c
- cartProduct3 :: (USource r1 l1 Dim1 a, USource r2 l2 Dim1 b, USource r3 l3 Dim1 c) => (a -> b -> c -> d) -> UArray r1 l1 Dim1 a -> UArray r2 l2 Dim1 b -> UArray r3 l3 Dim1 c -> UArray D SH Dim3 d
- icartProduct3 :: (USource r1 l1 Dim1 a, USource r2 l2 Dim1 b, USource r3 l3 Dim1 c) => (Dim3 -> a -> b -> c -> d) -> UArray r1 l1 Dim1 a -> UArray r2 l2 Dim1 b -> UArray r3 l3 Dim1 c -> UArray D SH Dim3 d
- icartProduct3M :: (USource r1 l1 Dim1 a, USource r2 l2 Dim1 b, USource r3 l3 Dim1 c) => (Dim3 -> a -> b -> c -> IO d) -> UArray r1 l1 Dim1 a -> UArray r2 l2 Dim1 b -> UArray r3 l3 Dim1 c -> UArray D SH Dim3 d
Basic fusion
class Fusion r fr l sh => DefaultFusion r fr l sh | r -> fr where Source #
This class abstracts pair of array types, which could be (preferably should be)
mapped (fused) one to another. Injective version of Fusion
class.
Parameters:
r
- source array representation. It determines result representation.fr
(fused repr) - result (fused) array representation. Result array isn't indeed presented in memory, finally it should becompute
d orLoad
ed toManifest
representation.l
- load type, common for source and fused arrayssh
- shape of arrays
All functions are already defined, using non-injective versions from Fusion
class.
The class doesn't have vector counterpart, it's role play top-level functions from Data.Yarr.Repr.Separate module.
dmap :: (USource r l sh a, USource fr l sh b) => (a -> b) -> UArray r l sh a -> UArray fr l sh b Source #
O(1) Pure element mapping.
Main basic "map" in Yarr.
dmapM :: (USource r l sh a, USource fr l sh b) => (a -> IO b) -> UArray r l sh a -> UArray fr l sh b Source #
O(1) Monadic element mapping.
dzip2 :: (USource r l sh a, USource r l sh b, USource fr l sh c) => (a -> b -> c) -> UArray r l sh a -> UArray r l sh b -> UArray fr l sh c Source #
O(1) Zipping 2 arrays of the same type indexes and shapes.
Example:
let productArr = dzip2 (*) arr1 arr2
dzip2M :: (USource r l sh a, USource r l sh b, USource fr l sh c) => (a -> b -> IO c) -> UArray r l sh a -> UArray r l sh b -> UArray fr l sh c Source #
O(1) Monadic version of dzip2
function.
dzip3 :: (USource r l sh a, USource r l sh b, USource r l sh c, USource fr l sh d) => (a -> b -> c -> d) -> UArray r l sh a -> UArray r l sh b -> UArray r l sh c -> UArray fr l sh d Source #
O(1) Zipping 3 arrays of the same type indexes and shapes.
dzip3M :: (USource r l sh a, USource r l sh b, USource r l sh c, USource fr l sh d) => (a -> b -> c -> IO d) -> UArray r l sh a -> UArray r l sh b -> UArray r l sh c -> UArray fr l sh d Source #
O(1) Monadic version of dzip3
function.
dzip :: (USource r l sh a, USource fr l sh b, Arity n, n ~ S n0) => Fun n a b -> VecList n (UArray r l sh a) -> UArray fr l sh b Source #
O(1) Generalized element zipping with pure function.
Zipper function is wrapped in Fun
for injectivity.
dzipM :: (USource r l sh a, USource fr l sh b, Arity n, n ~ S n0) => Fun n a (IO b) -> VecList n (UArray r l sh a) -> UArray fr l sh b Source #
O(1) Monadic version of dzip
function.
Shape sh => DefaultFusion D D SH sh Source # | |
DefaultFusion D D L sh Source # | |
DefaultFusion FS D L sh Source # | |
DefaultFusion F D L sh Source # | |
DefaultFusion MB D L sh Source # | |
DefaultFusion B D L sh Source # | |
Shape sh => DefaultFusion CV CV CVL sh Source # | |
(DefaultFusion r D l sh, Fusion (SE r) D l sh) => DefaultFusion (SE r) D l sh Source # | |
class IFusion r l fr fl sh => DefaultIFusion r l fr fl sh | r l -> fr where Source #
Like DefaultFusion
, this class abstracts the pair array types,
which should be fused one to another
on maps and zips which accept index of element
(several elements for zips) in array (arrays).
Parameters:
r
- source array representation. Determines result representation.l
- source load typefr
(fused repr) - result (fused) array representation. Result array isn't indeed presented in memory, finally it should becompute
d orLoad
ed toManifest
representation.fl
- result, "shaped" load typesh
- shape of arrays
All functions are already defined,
using non-injective versions from IFusion
class.
The class doesn't have vector counterpart.
imap :: (USource r l sh a, USource fr fl sh b) => (sh -> a -> b) -> UArray r l sh a -> UArray fr fl sh b Source #
O(1) Pure element mapping with array index.
imapM :: (USource r l sh a, USource fr fl sh b) => (sh -> a -> IO b) -> UArray r l sh a -> UArray fr fl sh b Source #
O(1) Monadic element mapping with index.
izip2 :: (USource r l sh a, USource r l sh b, USource fr fl sh c) => (sh -> a -> b -> c) -> UArray r l sh a -> UArray r l sh b -> UArray fr fl sh c Source #
O(1) Pure zipping of 2 arrays with index.
izip2M :: (USource r l sh a, USource r l sh b, USource fr fl sh c) => (sh -> a -> b -> IO c) -> UArray r l sh a -> UArray r l sh b -> UArray fr fl sh c Source #
O(1) Monadic zipping of 2 arrays with index.
izip3 :: (USource r l sh a, USource r l sh b, USource r l sh c, USource fr fl sh d) => (sh -> a -> b -> c -> d) -> UArray r l sh a -> UArray r l sh b -> UArray r l sh c -> UArray fr fl sh d Source #
O(1) Pure zipping of 3 arrays with index.
izip3M :: (USource r l sh a, USource r l sh b, USource r l sh c, USource fr fl sh d) => (sh -> a -> b -> c -> IO d) -> UArray r l sh a -> UArray r l sh b -> UArray r l sh c -> UArray fr fl sh d Source #
O(1) Monadic zipping of 3 arrays with index.
izip :: (USource r l sh a, USource fr fl sh b, Arity n, n ~ S n0) => (sh -> Fun n a b) -> VecList n (UArray r l sh a) -> UArray fr fl sh b Source #
O(1) Generalized pure element zipping with index in arrays.
Zipper function is wrapped in Fun
for injectivity.
izipM :: (USource r l sh a, USource fr fl sh b, Arity n, n ~ S n0) => (sh -> Fun n a (IO b)) -> VecList n (UArray r l sh a) -> UArray fr fl sh b Source #
O(1) Monadic version of izip
function.
Shape sh => DefaultIFusion D SH D SH sh Source # | |
Shape sh => DefaultIFusion D L D SH sh Source # | |
Shape sh => DefaultIFusion FS L D SH sh Source # | |
Shape sh => DefaultIFusion F L D SH sh Source # | |
Shape sh => DefaultIFusion MB L D SH sh Source # | |
Shape sh => DefaultIFusion B L D SH sh Source # | |
Shape sh => DefaultIFusion CV CVL CV CVL sh Source # | |
(DefaultIFusion r l D SH sh, IFusion (SE r) l D SH sh) => DefaultIFusion (SE r) l D SH sh Source # | |
Delayed flow and zipping shortcuts
:: (USource r1 l sh a, DefaultFusion r1 D l sh, USource D l sh a, USource r2 l sh b, DefaultFusion r2 D l sh, USource D l sh b, USource D l sh c, DefaultFusion D D l sh) | |
=> (a -> b -> c) | Pure zipping function |
-> UArray r1 l sh a | 1st source array |
-> UArray r2 l sh b | 2nd source array |
-> UArray D l sh c | Fused result array |
O(1) Generalized zipping of 2 arrays.
Main basic "zipWith" in Yarr.
Although sighature of this function has extremely big predicate,
it is more permissible than dzip2
counterpart, because source arrays
shouldn't be of the same type.
Implemented by means of delay
function (source arrays are simply
delayed before zipping).
:: (USource r1 l sh a, DefaultFusion r1 D l sh, USource D l sh a, USource r2 l sh b, DefaultFusion r2 D l sh, USource D l sh b, USource r3 l sh c, DefaultFusion r3 D l sh, USource D l sh c, USource D l sh d, DefaultFusion D D l sh) | |
=> (a -> b -> c -> d) | Pure zipping function |
-> UArray r1 l sh a | 1st source array |
-> UArray r2 l sh b | 2nd source array |
-> UArray r3 l sh c | 3rd source array |
-> UArray D l sh d | Result array |
O(1) Generalized zipping of 3 arrays, which shouldn't be of the same representation type.
Delayed representation is a wrapper for arbitrary indexing function.
instance holds linear getter (UArray
D L
sh a(Int -> IO a)
),
and
- shaped, "true" UArray
D SH
sh a(sh -> IO a)
index, respectively.
D
elayed arrays are most common recipients for fusion operations.
delay :: (USource r l sh a, USource D l sh a, Fusion r D l sh) => UArray r l sh a -> UArray D l sh a Source #
Load type preserving wrapping arbirtary array into D
elayed representation.
Vector fusion
SEparate meta array representation. Internally SEparate arrays
hold vector of it's slices (so, slices
is just getter for them).
Mostly useful for:
(DefaultFusion r D l sh, Fusion (SE r) D l sh) => DefaultFusion (SE r) D l sh Source # | |
(DefaultIFusion r l D SH sh, IFusion (SE r) l D SH sh) => DefaultIFusion (SE r) l D SH sh Source # | |
(UTarget tr tl sh e, Vector v e) => UVecTarget (SE tr) tr tl sh v e Source # | |
(USource r l sh e, Vector v e) => UVecSource (SE r) r l sh v e Source # | |
(Shape sh, Vector v e, Storable e) => UVecSource (SE F) F L sh v e Source # | |
(Shape sh, Vector v e, NFData e) => UVecSource (SE MB) MB L sh v e Source # | |
(Shape sh, Vector v e, NFData e) => UVecSource (SE B) B L sh v e Source # | |
(Regular r l sh e, Shape sh, Vector v e) => VecRegular (SE r) r l sh v e Source # | |
(UTarget tr tl sh e, Vector v e) => UTarget (SE tr) tl sh (v e) Source # | |
(USource r l sh e, Vector v e) => USource (SE r) l sh (v e) Source # | |
(Regular r l sh e, Vector v e) => Regular (SE r) l sh (v e) Source # | |
(Manifest r mr l sh e, Vector v e) => Manifest (SE r) (SE mr) l sh (v e) Source # | |
(NFData (UArray r l sh e), Shape sh, Vector v e) => NFData (UArray (SE r) l sh (v e)) Source # | |
data UArray (SE r) l sh (v e) Source # | |
:: (VecRegular r slr l sh v a, USource slr l sh a, USource fslr l sh b, DefaultFusion slr fslr l sh, Vector v2 b, Dim v ~ Dim v2) | |
=> VecList (Dim v) (a -> IO b) | Elemen-wise vector of monadic mappers |
-> UArray r l sh (v a) | Source array of vectors |
-> UArray (SE fslr) l sh (v2 b) | Result array |
O(1) Monadic vesion of dmapElems
function.
:: (VecRegular r slr l sh v a, USource slr l sh a, VecRegular r slr l sh v b, USource slr l sh b, USource fslr l sh c, DefaultFusion slr fslr l sh, Vector v c) | |
=> VecList (Dim v) (a -> b -> c) | . |
-> UArray r l sh (v a) | |
-> UArray r l sh (v b) | |
-> UArray (SE fslr) l sh (v c) |
:: (VecRegular r slr l sh v a, USource slr l sh a, VecRegular r slr l sh v b, USource slr l sh b, USource fslr l sh c, DefaultFusion slr fslr l sh, Vector v c) | |
=> VecList (Dim v) (a -> b -> IO c) | . |
-> UArray r l sh (v a) | |
-> UArray r l sh (v b) | |
-> UArray (SE fslr) l sh (v c) |
:: (VecRegular r slr l sh v a, USource slr l sh a, VecRegular r slr l sh v b, USource slr l sh b, VecRegular r slr l sh v c, USource slr l sh c, USource fslr l sh d, DefaultFusion slr fslr l sh, Vector v d) | |
=> VecList (Dim v) (a -> b -> c -> d) | . |
-> UArray r l sh (v a) | |
-> UArray r l sh (v b) | |
-> UArray r l sh (v c) | |
-> UArray (SE fslr) l sh (v d) |
:: (VecRegular r slr l sh v a, USource slr l sh a, VecRegular r slr l sh v b, USource slr l sh b, VecRegular r slr l sh v c, USource slr l sh c, USource fslr l sh d, DefaultFusion slr fslr l sh, Vector v d) | |
=> VecList (Dim v) (a -> b -> c -> IO d) | . |
-> UArray r l sh (v a) | |
-> UArray r l sh (v b) | |
-> UArray r l sh (v c) | |
-> UArray (SE fslr) l sh (v d) |
:: (Vector v2 b, Arity m, m ~ S m0, VecRegular r slr l sh v a, USource slr l sh a, USource fslr l sh b, DefaultFusion slr fslr l sh) | |
=> VecList (Dim v2) (Fun m a b) | Vector of wrapped |
-> VecList m (UArray r l sh (v a)) | Vector of source arrays of vectors |
-> UArray (SE fslr) l sh (v2 b) | Fused result array |
O(1) Generalized element-wise zipping of several arrays of vectors.
:: (Vector v2 b, Arity m, m ~ S m0, VecRegular r slr l sh v a, USource slr l sh a, USource fslr l sh b, DefaultFusion slr fslr l sh) | |
=> VecList (Dim v2) (Fun m a (IO b)) | Vector of wrapped |
-> VecList m (UArray r l sh (v a)) | Vector of source arrays of vectors |
-> UArray (SE fslr) l sh (v2 b) | Result array |
O(1) Generalized monadic element-wise zipping of several arrays of vectors
High level shortcuts
:: (USource r l sh a, Shape sh') | |
=> (sh -> sh') | Function to produce result extent from source extent. |
-> ((sh -> IO a) -> sh' -> IO b) | Function to produce elements of result array. Passed a lookup function to get elements of the source. |
-> UArray r l sh a | Source array itself |
-> UArray D SH sh' b | Result array |
O(1) Function from repa
.
:: (VecRegular r slr l sh v a, USource slr l sh a, USource fslr l sh b, DefaultFusion slr fslr l sh, Vector v b) | |
=> (a -> b) | Mapper function for all elements |
-> UArray r l sh (v a) | Source array of vectors |
-> UArray (SE fslr) l sh (v b) | Fused array of vectors |
O(1) Maps elements of vectors in array uniformly.
Don't confuse with dmapElems
, which accepts a vector of mapper
for each slice.
Typical use case -- type conversion:
let floatImage :: UArray F Dim2 Float
floatImage = mapElems fromIntegral
word8Image
:: (VecRegular r slr l sh v a, USource slr l sh a, USource fslr l sh b, DefaultFusion slr fslr l sh, Vector v b) | |
=> (a -> IO b) | Monadic mapper for all vector elements |
-> UArray r l sh (v a) | Source array of vectors |
-> UArray (SE fslr) l sh (v b) | Fused array of vectors |
O(1) Monadic version of mapElems
function.
Don't confuse with dmapElemsM
.
Example:
let domained = mapElemsM (clampM
0.0 1.0) floatImage
Cartesian products
cartProduct2 :: (USource r1 l1 Dim1 a, USource r2 l2 Dim1 b) => (a -> b -> c) -> UArray r1 l1 Dim1 a -> UArray r2 l2 Dim1 b -> UArray D SH Dim2 c Source #
icartProduct2 :: (USource r1 l1 Dim1 a, USource r2 l2 Dim1 b) => (Dim2 -> a -> b -> c) -> UArray r1 l1 Dim1 a -> UArray r2 l2 Dim1 b -> UArray D SH Dim2 c Source #
icartProduct2M :: (USource r1 l1 Dim1 a, USource r2 l2 Dim1 b) => (Dim2 -> a -> b -> IO c) -> UArray r1 l1 Dim1 a -> UArray r2 l2 Dim1 b -> UArray D SH Dim2 c Source #
cartProduct3 :: (USource r1 l1 Dim1 a, USource r2 l2 Dim1 b, USource r3 l3 Dim1 c) => (a -> b -> c -> d) -> UArray r1 l1 Dim1 a -> UArray r2 l2 Dim1 b -> UArray r3 l3 Dim1 c -> UArray D SH Dim3 d Source #