Changes between Version 19 and Version 20 of DataParallel/Regular
 Timestamp:
 Jan 18, 2010 5:55:43 AM (7 years ago)
Legend:
 Unmodified
 Added
 Removed
 Modified

DataParallel/Regular
v19 v20 286 286 map:: (U.Elt a, U.Elt b, A.Shape dim) => (a > b) > DArray dim a > DArray dim b 287 287 }}} 288 We can't use `map`, however, to apply a function to all columns, rows, or other subarrays of288 We can't use this function, however, to apply a function to all columns, rows, or other subarrays of 289 289 a multidimensional array, and generalising `map` to be able to handle this wouldn't make sense 290 290 in this framework. Consider, for example, a function `filter`, which takes a onedimensional … … 293 293 not be a two dimensional array anymore, since each row might potentially have a different length. 294 294 Therefore, we restrict the class of functions that can be mapped over subarrays to functions where 295 the shape of the argument determines the shape of the result. In other words, it can't depend on the data 296 values. 295 the shape of the argument determines the shape of the result. All `mappable` functions can be implemented 296 such that they abstract over the exact dimensionality of their argument, and have the type 297 {{{ 298 f::(A.Shape dim, U.Elt e, U.Elt e') => DArray (dim :*: Int ..... :*: Int) e > DArray (dim :*: Int :*: .... :*: Int) e' 299 }}} 300 and those functions can be trivially mapped since 301 {{{ 302 map f = f 303 }}} 304 So, for example, we can write a mappable function which takes an array and selects every data element with 305 an even index: 306 {{{ 307 selectEven:: (A.Shape dim, U.Elt e) => DArray (dim :*: Int) e > DArray (dim :*: Int) e 308 selectEven (DArray (sh :*: n ) f = 309 DArray (sh :*: n `div` 2) (\(sh :*: n) > f (sh :*: 2*n) 310 }}} 311 312 313 314 315 316 297 317 298 318