-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider adding "flat iterators" for arrays #22
Comments
Added a start of this in https://github.com/dsharlet/array/tree/flat-iterators, I am concerned performance will be bad though. |
Is this enhancement still under consideration? |
@jiawen was looking at it a while back, but I'm not sure about now. The problem is this isn't really hard to implement, but the performance of it is going to be bad, and I'm not sure how that can be avoided. This can only be fast if you assume the array can be flattened to a contiguous 1D array, which is a hard assumption to make. |
The issue I have (had?) is that there is no 'iterator' for shape index_type. I want to take an index_type, add to the lowest dimension, and increment the index across the shape. I've prototyped something that works by recursively adding to each dimension of the index_type up to extent and then breaking if there is no carry over to higher dimension. Performance likely isn't great but in my application that is not a problem. |
That sounds lot like the It’s definitely doable, I’m just hesitant to provide it because the performance will be terrible compared to |
It would be great to have "flat iterators" for arrays. Among other things, this could enable the standard
<algorithm>
algorithms to work on arrays where it makes sense, and we could get rid of our subset of these mirroring the STL. However, it is difficult to implement a performant flat iterator, due to the branchiness at each iteration required in the implementation.The text was updated successfully, but these errors were encountered: