Spark's Work

Vectorizing a Function in

I recently refereed a paper for an R package, where the function base::Vectorize is used. The documentation is given here.

As its name suggests, the function vectorizes a customized function written only for scalars. Unfortunately, it does not given good performance improvement (see here).

I was quite surprised at first sight, but then I realized it is quite similar to broadcasting in julia. The latter is done more conveniently: Say the user has defined a function f(x) for a scalar input x, then f.(vec_x) vectorizes the same function to a vector input vec_x.