Changes between Version 19 and Version 20 of DataParallel/Regular


Ignore:
Timestamp:
Jan 18, 2010 5:55:43 AM (5 years ago)
Author:
gckeller
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DataParallel/Regular

    v19 v20  
    286286map:: (U.Elt a, U.Elt b, A.Shape dim) =>  (a -> b) -> DArray dim a -> DArray dim b 
    287287}}} 
    288 We can't use `map`, however, to apply a function to all columns, rows, or other sub-arrays of  
     288We can't use this function, however, to apply a function to all columns, rows, or other sub-arrays of  
    289289a multidimensional array, and generalising `map` to be able to handle this wouldn't make sense 
    290290in this framework. Consider, for example, a function `filter`, which takes a one-dimensional  
     
    293293not be a two dimensional array anymore, since each row might potentially have a different length.  
    294294Therefore, we restrict the class of functions that can be mapped over sub-arrays 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.  
     295the shape of the argument determines the shape of the result. All `mappable` functions can be implemented 
     296such that they abstract over the exact dimensionality of their argument, and have the type 
     297{{{ 
     298f::(A.Shape dim, U.Elt e, U.Elt e') => DArray (dim :*: Int ..... :*: Int) e ->  DArray (dim :*: Int :*: .... :*: Int) e' 
     299}}} 
     300and those functions can be trivially mapped since 
     301{{{ 
     302 map f = f 
     303}}} 
     304So, for example, we can write a mappable function which takes an array and selects every data element with  
     305an 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 
    297317 
    298318