1

I am currently writing a highly templated C++ helper class for vectorized operations and I need a name for a specific operation.

I have already 2 functions with very common names taken from vectorial languages :

  • apply() which apply a function to each element of a vector
  • reduce() which apply a reduction operation over the vector and returns a scalar

Now I would like to implement another function, which is a mix between these two : it takes several vectors as an input, and apply a reduction operation over each line, and returns a vector.

To illustrate that, we have :

  • apply(func, vec) -> returns {func(vec[0]), func(vec[1]), ..., func(vec[n])}
  • reduce(func, vec) -> returns func(vec[0], vec[1], ..., vec[n])

and :

  • something(func, vec1, vec2, ..., vecn) -> returns {func(vec0[0], vec1[0], ..., vecn[0]), func(vec0[1], vec1[1], ..., vecn[1]), ..., func(vec0[n], vec1[n], ..., vecn[n])}

What would be a common name for this function (a simple verb like apply or reduce) (compatible with other vectorial languages if such a function exists) ?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Vincent
  • 57,703
  • 61
  • 205
  • 388

1 Answers1

0

Maybe zip_with which I've seen used from Haskell?

Pubby
  • 51,882
  • 13
  • 139
  • 180
  • https://stackoverflow.com/questions/9729127/is-it-possible-to-write-a-generic-variadic-zipwith-in-c – alfC Oct 08 '18 at 03:48