Changes between Version 22 and Version 23 of DataParallel/Regular


Ignore:
Timestamp:
Jan 19, 2010 12:36:57 PM (4 years ago)
Author:
gckeller
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DataParallel/Regular

    v22 v23  
    318318try and write function `selectEvenElems`, which selects all even elements from an array.  To determine the shape of the 
    319319result, it is not sufficient to look  at the shape of the argument. Instead, we have to calculate the new size by counting the 
    320 even elements in the array (1) using `fold`. The function `fold` is mappable, and returns an array. If the argument is a one-dimensional 
     320even elements in the array using `fold`. The function `fold` is mappable, and returns an array. If the argument is a one-dimensional 
    321321array, the result is a singular array, which then can be converted to a scalar using `toScalar`.  The necessary application of `toScalar`, 
    322322however, also restricts `sh`, which can now only be unit, and therefore the whole operation `selectEvenElems` is restricted to one-dimensional 
     
    325325  selectEvenElems (DArray  (sh :*: n) f) = DArray (sh :*: newSize) <......> 
    326326     where 
    327           newSize = toScalar $ fold (+) 0 $ map (\x -> if (even x) then 1 else 0) arr  -- (1) 
     327          newSize = toScalar $ fold (+) 0 $ map (\x -> if (even x) then 1 else 0) arr   
    328328}}} 
    329329