@@ -152,11 +152,24 @@ end
152
152
@inline unsafe_getindex (a:: AbstractArray , I... ) = (@inbounds ret = a[I... ]; ret)
153
153
@inline unsafe_setindex! (a:: AbstractArray , val, I... ) = (@inbounds a[I... ] = val; val)
154
154
155
- @inline unsafe_getindex (a:: OffsetArray , I:: Int... ) = ( @inbounds ret = parent (a)[ offset (a. offsets, I)... ]; ret )
156
- @inline unsafe_setindex! (a:: OffsetArray , val, I:: Int... ) = ( @inbounds parent (a)[ offset (a. offsets, I)... ] = val; val )
155
+ @inline unsafe_getindex (a:: OffsetArray , I:: Int... ) = unsafe_getindex ( parent (a), offset (a. offsets, I)... )
156
+ @inline unsafe_setindex! (a:: OffsetArray , val, I:: Int... ) = unsafe_setindex! ( parent (a), val, offset (a. offsets, I)... )
157
157
@inline unsafe_getindex (a:: OffsetArray , I... ) = unsafe_getindex (a, Base. IteratorsMD. flatten (I)... )
158
158
@inline unsafe_setindex! (a:: OffsetArray , val, I... ) = unsafe_setindex! (a, val, Base. IteratorsMD. flatten (I)... )
159
159
160
+ # Indexing a SubArray which has OffsetArray indices
161
+ typealias OffsetSubArray{T,N,P,I<: Tuple{OffsetArray,Vararg{OffsetArray}} } SubArray{T,N,P,I,false }
162
+ @inline function unsafe_getindex {T,N} (a:: OffsetSubArray{T,N} , I:: Vararg{Int,N} )
163
+ J = map (unsafe_getindex, a. indexes, I)
164
+ unsafe_getindex (parent (a), J... )
165
+ end
166
+ @inline function unsafe_setindex! {T,N} (a:: OffsetSubArray{T,N} , val, I:: Vararg{Int,N} )
167
+ J = map (unsafe_getindex, a. indexes, I)
168
+ unsafe_setindex! (parent (a), val, J... )
169
+ end
170
+ @inline unsafe_getindex (a:: OffsetSubArray , I:: Union{Integer,CartesianIndex} ...) = unsafe_getindex (a, Base. IteratorsMD. flatten (I)... )
171
+ @inline unsafe_setindex! (a:: OffsetSubArray , val, I:: Union{Integer,CartesianIndex} ...) = unsafe_setindex! (a, val, Base. IteratorsMD. flatten (I)... )
172
+
160
173
# Deprecations
161
174
import Base: zeros, ones
162
175
@deprecate zeros (T:: Type , inds:: UnitRange... ) fill! (OffsetArray {T} (inds), zero (T))
0 commit comments