dsharlet / array

C++ multidimensional arrays in the spirit of the STL
Apache License 2.0
198 stars 15 forks source link

Need a version of generate() that takes indices #57

Closed jiawen closed 1 year ago

jiawen commented 3 years ago

generate() works like std::generate() and needs to maintain state elsewhere. It'd be nice to have a function that does a fill based on "pattern function" that takes in indices instead:

Equivalent to something like:

for_each_index(image.shape(), [&](const typename Shape::index_type& i) {
  image(i) = std::apply(pattern, i);
});
jiawen commented 3 years ago

I don't have any good names though. fill() is already taken. fill_with_pattern? What's the dual of enumerate?

dsharlet commented 3 years ago

We might be able to just overload fill?

jiawen commented 1 year ago

Implemented in #69 as transform_index and transform_indices.