-
Notifications
You must be signed in to change notification settings - Fork 71
map
myArray.map(elementalFunction, arg1, arg2, ...)
Currently this API is invoked using mapSeq to get the JavaScript library version and map to get the optimized version. This is a temporary situation as we undergo some reworking of the API.
elementalFunction
described below
arg1
, arg2
, ... passed unchanged to elemental function
function (arg1, arg2, ...)
this
An element from the ParallelArray
arg1
, arg2
, ... Same as the optional arguments passed to map
The result of the function will be used as an element to be placed in the result at the same offset we found this
in the source array.
A freshly minted ParallelArray
Elements are the results of applying the elemental function to the elements in the original ParallelArray plus any optional arguments.
Other than combine, map does not provide a depth argument to steer the number of dimensions the map operation iterates over. Instead, flatten can be used to collapse the outer dimensions of an array into a single dimension. A consecutive application of map then iterates over all previously collapsed dimenions. Finally, partition can be used to restore the original shape of the array. For example,
result = pa.map(2, f);
where 2 would be the depth argument, can instead be expressed by
tmp = pa.flatten();
tmp = tmp.map(f);
result = tmp.partition(pa.getShape()[0]);
Note that this does not work for combine. As combine exposes the iteration index to the elemental function, collapsing the iteration space to a single index would be observable from the elemental function.
pa.map(function(){return this;})