You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is appropriate for StridedArrays, where the parent is an Array, but it's counterproductive if the parent is one which does not efficiently support linear indexing. A more general implementation would look something like this:
The benchmarks in #5393 suggest that there may no longer be any in-principle performance disadvantages with this approach. (Currently r[i] for a range r is slow because the bounds check prevents inlining, but once #3796 gets merged I suspect this won't be a major barrier anymore, although ultimately we'll still want a way to turn off bounds-checking.)
The challenge would be slices: you'd want implementations like this:
getindex{T,A,I<:(Int,Ranges{Int})}(s::SubArray{T,1, A, I}, i::Integer) =
s.parent[s.indexes[1], s.indexes[2][i]]
That's a lot of functions, but we could generate them. Not quite sure how this works for arbitrary dimensions, though.
The text was updated successfully, but these errors were encountered:
The current implementation of
getindex
for SubArrays computes a linear index to access the parent array:This is appropriate for StridedArrays, where the parent is an Array, but it's counterproductive if the parent is one which does not efficiently support linear indexing. A more general implementation would look something like this:
The benchmarks in #5393 suggest that there may no longer be any in-principle performance disadvantages with this approach. (Currently
r[i]
for a ranger
is slow because the bounds check prevents inlining, but once #3796 gets merged I suspect this won't be a major barrier anymore, although ultimately we'll still want a way to turn off bounds-checking.)The challenge would be slices: you'd want implementations like this:
That's a lot of functions, but we could generate them. Not quite sure how this works for arbitrary dimensions, though.
The text was updated successfully, but these errors were encountered: