dsharlet / array

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

Cropping via ranges results in an array with the same indices as the old array #24

Open dsharlet opened 4 years ago

dsharlet commented 4 years ago

In numpy and many other systems, b = a(interval(5, 12)) results in an array where b(x) == a(x + 5) and b has an extent of 7 (and a min of 0).

In array, this doesn't happen. b(x) == a(x), where b has a min of x.min() + 5 and an extent of 7. The only other system that is similar that I'm aware of is Halide.

This is very convenient for tiling algorithms transparently, but may not be what people would prefer to see in other use cases.

I lean towards the current behavior (which enables transparent tiling of algorithms), but it would be good to find a way to seamlessly enable the numpy style as well.

jiawen commented 1 year ago

I wonder if you can make operator()(interval i) a template template <enum CropBehavior> operator()(interval i).