yarr-1.3.2: Yet another array library

Safe HaskellNone

Data.Yarr.Fusion

Description

Fusion type system. Use re-exported in Data.Yarr.Flow functions.

Synopsis

Documentation

class Fusion r fr l sh whereSource

Generalized, non-injective version of DefaultFusion. Used internally.

Minimum complete defenition: fmapM, fzip2M, fzip3M and fzipM.

The class doesn't have vector counterpart, it's role play top-level functions from Data.Yarr.Repr.Separate module.

Methods

fmapSource

Arguments

:: (USource r l sh a, USource fr l sh b) 
=> (a -> b)

.

-> UArray r l sh a 
-> UArray fr l sh b 

fmapM :: (USource r l sh a, USource fr l sh b) => (a -> IO b) -> UArray r l sh a -> UArray fr l sh bSource

fzip2Source

Arguments

:: (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 

fzip2MSource

Arguments

:: (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 

fzip3Source

Arguments

:: (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 

fzip3MSource

Arguments

:: (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 

fzipSource

Arguments

:: (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 

fzipMSource

Arguments

:: (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 

Instances

IFusion r l fr l sh => Fusion r fr l sh 
Fusion r D L sh 

class Fusion r fr l sh => DefaultFusion r fr l sh | r -> fr whereSource

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 be computed or Loaded to Manifest representation.
  • l - load type, common for source and fused arrays
  • sh - 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.

Methods

dmapSource

Arguments

:: (USource r l sh a, USource fr l sh b) 
=> (a -> b)

Element mapper function

-> UArray r l sh a

Source array

-> UArray fr l sh b

Result array

O(1) Pure element mapping.

Main basic "map" in Yarr.

dmapMSource

Arguments

:: (USource r l sh a, USource fr l sh b) 
=> (a -> IO b)

Monadic element mapper function

-> UArray r l sh a

Source array

-> UArray fr l sh b

Result array

O(1) Monadic element mapping.

dzip2Source

Arguments

:: (USource r l sh a, USource r l sh b, USource fr l sh c) 
=> (a -> b -> c)

Pure element zipper function

-> UArray r l sh a

1st source array

-> UArray r l sh b

2nd source array

-> UArray fr l sh c

Fused result array

O(1) Zipping 2 arrays of the same type indexes and shapes.

Example:

 let productArr = dzip2 (*) arr1 arr2

dzip2MSource

Arguments

:: (USource r l sh a, USource r l sh b, USource fr l sh c) 
=> (a -> b -> IO c)

Monadic element zipper function

-> UArray r l sh a

1st source array

-> UArray r l sh b

2nd source array

-> UArray fr l sh c

Result array

O(1) Monadic version of dzip2 function.

dzip3Source

Arguments

:: (USource r l sh a, USource r l sh b, USource r l sh c, USource fr l sh d) 
=> (a -> b -> c -> d)

Pure element zipper function

-> UArray r l sh a

1st source array

-> UArray r l sh b

2nd source array

-> UArray r l sh c

3rd source array

-> UArray fr l sh d

Result array

O(1) Zipping 3 arrays of the same type indexes and shapes.

dzip3MSource

Arguments

:: (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)

Monadic element zipper function

-> UArray r l sh a

1st source array

-> UArray r l sh b

2nd source array

-> UArray r l sh c

3rd source array

-> UArray fr l sh d

Fused result array

O(1) Monadic version of dzip3 function.

dzipSource

Arguments

:: (USource r l sh a, USource fr l sh b, Arity n, n ~ S n0) 
=> Fun n a b

Wrapped function positionally accepts elements from source arrays and emits element for fused array

-> VecList n (UArray r l sh a)

Source arrays

-> UArray fr l sh b

Result array

O(1) Generalized element zipping with pure function. Zipper function is wrapped in Fun for injectivity.

dzipMSource

Arguments

:: (USource r l sh a, USource fr l sh b, Arity n, n ~ S n0) 
=> Fun n a (IO b)

Wrapped monadic zipper

-> VecList n (UArray r l sh a)

Source arrays

-> UArray fr l sh b

Result array

O(1) Monadic version of dzip function.

Instances

class PreferredWorkIndex fl sh sh => IFusion r l fr fl sh | r l fr -> fl whereSource

Like Fusion, for mappings/zippings with array index. Used to define functions in DefaultIFusion.

Minimum complete defenition: fimapM, fizip2M, fizip3M and fizipM.

The class doesn't have vector counterpart.

Methods

fimapSource

Arguments

:: (USource r l sh a, USource fr fl sh b) 
=> (sh -> a -> b)

.

-> UArray r l sh a 
-> UArray fr fl sh b 

fimapM :: (USource r l sh a, USource fr fl sh b) => (sh -> a -> IO b) -> UArray r l sh a -> UArray fr fl sh bSource

fizip2Source

Arguments

:: (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 

fizip2MSource

Arguments

:: (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 

fizip3Source

Arguments

:: (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 

fizip3MSource

Arguments

:: (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 

fizipSource

Arguments

:: (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 

fizipMSource

Arguments

:: (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 

Instances

Shape sh => IFusion r l D SH sh 
Shape sh => IFusion CV CVL CV CVL sh 

class IFusion r l fr fl sh => DefaultIFusion r l fr fl sh | r l -> fr whereSource

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 type
  • fr (fused repr) - result (fused) array representation. Result array isn't indeed presented in memory, finally it should be computed or Loaded to Manifest representation.
  • fl - result, "shaped" load type
  • sh - shape of arrays

All functions are already defined, using non-injective versions from IFusion class.

The class doesn't have vector counterpart.

Methods

imapSource

Arguments

:: (USource r l sh a, USource fr fl sh b) 
=> (sh -> a -> b)

Indexed mapping function

-> UArray r l sh a

Source array

-> UArray fr fl sh b

Fused result array

O(1) Pure element mapping with array index.

imapMSource

Arguments

:: (USource r l sh a, USource fr fl sh b) 
=> (sh -> a -> IO b)

Indexed monadic mapping function

-> UArray r l sh a

Source array

-> UArray fr fl sh b

Result fused array

O(1) Monadic element mapping with index.

izip2Source

Arguments

:: (USource r l sh a, USource r l sh b, USource fr fl sh c) 
=> (sh -> a -> b -> c)

Indexed zipping function

-> UArray r l sh a

1st source array

-> UArray r l sh b

2nd source array

-> UArray fr fl sh c

Fused result array

O(1) Pure zipping of 2 arrays with index.

izip2MSource

Arguments

:: (USource r l sh a, USource r l sh b, USource fr fl sh c) 
=> (sh -> a -> b -> IO c)

Indexed monadic zipping function

-> UArray r l sh a

1st source array

-> UArray r l sh b

2nd source array

-> UArray fr fl sh c

Fused result array

O(1) Monadic zipping of 2 arrays with index.

izip3Source

Arguments

:: (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)

Indexed zipping function

-> UArray r l sh a

1st source array

-> UArray r l sh b

2nd source array

-> UArray r l sh c

3rd source array

-> UArray fr fl sh d

Fused result array

O(1) Pure zipping of 3 arrays with index.

izip3MSource

Arguments

:: (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)

Indexed monadic zipping function

-> UArray r l sh a

1st source array

-> UArray r l sh b

2nd source array

-> UArray r l sh c

3rd source array

-> UArray fr fl sh d

Fused result array

O(1) Monadic zipping of 3 arrays with index.

izipSource

Arguments

:: (USource r l sh a, USource fr fl sh b, Arity n, n ~ S n0) 
=> (sh -> Fun n a b)

Accepts index in array and returns wrapped zipper, which positionally accepts elements from source arrays and emits element for the result array

-> VecList n (UArray r l sh a)

Bunch of source arrays

-> UArray fr fl sh b

Result fused array

O(1) Generalized pure element zipping with index in arrays. Zipper function is wrapped in Fun for injectivity.

izipMSource

Arguments

:: (USource r l sh a, USource fr fl sh b, Arity n, n ~ S n0) 
=> (sh -> Fun n a (IO b))

Monadic indexed zipper

-> VecList n (UArray r l sh a)

Source arrays

-> UArray fr fl sh b

Result fused array

O(1) Monadic version of izip function.

Instances

Shape sh => DefaultIFusion D SH D SH sh 
Shape sh => DefaultIFusion D L D SH sh 
Shape sh => DefaultIFusion FS L D SH sh 
Shape sh => DefaultIFusion F L D SH sh 
Shape sh => DefaultIFusion MB L D SH sh 
Shape sh => DefaultIFusion B L D SH sh 
Shape sh => DefaultIFusion CV CVL CV CVL sh 
(DefaultIFusion r l D SH sh, IFusion (SE r) l D SH sh) => DefaultIFusion (SE r) l D SH sh