| 85 | |
| 86 | |
| 87 | === Representation, Order of Elements, and Lifted Values === |
| 88 | |
| 89 | As mentioned when introducing the functions `toIndex` and `range`, the following relationship should hold: |
| 90 | {{{ |
| 91 | map (toIndex sh) (range sh) = [:0..(size sh)-1:] |
| 92 | }}} |
| 93 | this means that, for example |
| 94 | {{{ |
| 95 | range (() :*: 2 :*: 3) = |
| 96 | [() :*: 0 :*: 0, () :*: 0 :*: 1, ..... |
| 97 | }}} |
| 98 | |
| 99 | A scalar value `c`is isomorphic to a zero-dimensional array |
| 100 | {{{ |
| 101 | DArray () (\_ -> c) |
| 102 | }}} |
| 103 | Lifting a scalar value over a shape `dim': |
| 104 | {{{ |
| 105 | Shape dim => DArray dim (\_ -> c) |
| 106 | }}} |
260 | | |
261 | | === Reordering, Shifting, Tiling === |
262 | | |
263 | | Backpermute and default backpermute are two very versatile operations which allow |
264 | | the programmer to express all structural operations which reorder or extract |
265 | | elements based on their position in the argument array: |
266 | | {{{ |
267 | | backpermute:: (U.Elt e, A.Shape dim, A.Shape dim') => |
268 | | DArray dim e -> dim' -> (dim' -> dim) -> DArray dim' e |
269 | | backpermuteDft::(U.Elt e, A.Shape dim, A.Shape dim') => |
270 | | DArray dim e -> e -> dim' -> (dim' -> Maybe dim) -> DArray dim' e |
271 | | }}} |
272 | | The function `backpermute` gets a source array, the shape of the new array, and |
273 | | a function which maps each index of the new array to an index of the source array (and |
274 | | thus indirectly provides a value for each index in the new array). Default backpermute is |
275 | | additionally provided with a default value which is inserted in the array in cases where the |
276 | | index function returns `Nothing`. (Remark: should probably be replaced by a default array instead of |
277 | | default value for more generality) |
278 | | |
279 | | `reshape arr newShape` returns a new array with the same value as the argument array, but a new shape. The |
280 | | new shape has to have the same size as the original shape. |
281 | | {{{ |
282 | | reshape:: (Shape dim', Shape dim, U.Elt e) => DArray dim e -> dim' -> DArray dim' e |
283 | | }}} |
284 | | |
| 282 | == Open Questions == |
| 283 | |
| 284 | === Do we need array comprehension on DArrays? === |
| 285 | |
| 286 | === Wave computations === |
| 287 | |
| 288 | ==== Generalised Stencil Operation === |
| 289 | |
| 290 | MapStencil is currently not lifted, and doesn't run in parallel. Need to come up with a generalised version. |