@@ -179,64 +179,64 @@ end
179
179
180
180
# For `reinterpret(reshape, T, a)` where we're adding a channel dimension and with
181
181
# `IndexStyle(a) == IndexLinear()`, it's advantageous to retain pseudo-linear indexing.
182
- struct IndexSCartesian2{K,N } <: IndexStyle end # K = sizeof(S) ÷ sizeof(T), a static-sized 2d cartesian iterator
182
+ struct IndexSCartesian2{K} <: IndexStyle end # K = sizeof(S) ÷ sizeof(T), a static-sized 2d cartesian iterator
183
183
184
184
IndexStyle (:: Type{ReinterpretArray{T,N,S,A,false}} ) where {T,N,S,A<: AbstractArray{S,N} } = IndexStyle (A)
185
185
function IndexStyle (:: Type{ReinterpretArray{T,N,S,A,true}} ) where {T,N,S,A<: AbstractArray{S} }
186
186
if sizeof (T) < sizeof (S)
187
- IndexStyle (A) === IndexLinear () && return IndexSCartesian2 {sizeof(S) ÷ sizeof(T),N } ()
187
+ IndexStyle (A) === IndexLinear () && return IndexSCartesian2 {sizeof(S) ÷ sizeof(T)} ()
188
188
return IndexCartesian ()
189
189
end
190
190
return IndexStyle (A)
191
191
end
192
- IndexStyle (:: IndexSCartesian2{K,N } , :: IndexSCartesian2{K,N } ) where {K,N } = IndexSCartesian2 {K,N } ()
192
+ IndexStyle (:: IndexSCartesian2{K} , :: IndexSCartesian2{K} ) where {K} = IndexSCartesian2 {K} ()
193
193
194
- struct SCartesianIndex2{K,N} <: AbstractCartesianIndex{N}
194
+ struct SCartesianIndex2{K} # can't make <: AbstractCartesianIndex without N, and 2 would be a bit misleading
195
195
i:: Int
196
196
j:: Int
197
197
end
198
198
to_index (i:: SCartesianIndex2 ) = i
199
199
200
- struct SCartesianIndices2{K,N, R<: AbstractUnitRange{Int} } <: AbstractMatrix{SCartesianIndex2{K}}
200
+ struct SCartesianIndices2{K,R<: AbstractUnitRange{Int} } <: AbstractMatrix{SCartesianIndex2{K}}
201
201
indices2:: R
202
202
end
203
- SCartesianIndices2 {K,N } (indices2:: AbstractUnitRange{Int} ) where {K,N } = (@assert K:: Int > 1 ; SCartesianIndices2 {K,N ,typeof(indices2)} (indices2))
203
+ SCartesianIndices2 {K} (indices2:: AbstractUnitRange{Int} ) where {K} = (@assert K:: Int > 1 ; SCartesianIndices2 {K,typeof(indices2)} (indices2))
204
204
205
- eachindex (:: IndexSCartesian2{K,N } , A:: AbstractArray ) where {K,N } = SCartesianIndices2 {K,N } (eachindex (IndexLinear (), parent (A)))
205
+ eachindex (:: IndexSCartesian2{K} , A:: AbstractArray ) where {K} = SCartesianIndices2 {K} (eachindex (IndexLinear (), parent (A)))
206
206
207
207
size (iter:: SCartesianIndices2{K} ) where K = (K, length (iter. indices2))
208
208
axes (iter:: SCartesianIndices2{K} ) where K = (Base. OneTo (K), iter. indices2)
209
209
210
- first (iter:: SCartesianIndices2{K,N } ) where {K,N } = SCartesianIndex2 {K,N } (1 , first (iter. indices2))
211
- last (iter:: SCartesianIndices2{K,N } ) where {K,N } = SCartesianIndex2 {K,N } (K, last (iter. indices2))
210
+ first (iter:: SCartesianIndices2{K} ) where {K} = SCartesianIndex2 {K} (1 , first (iter. indices2))
211
+ last (iter:: SCartesianIndices2{K} ) where {K} = SCartesianIndex2 {K} (K, last (iter. indices2))
212
212
213
- @inline function getindex (iter:: SCartesianIndices2{K,N } , i:: Int , j:: Int ) where {K,N }
213
+ @inline function getindex (iter:: SCartesianIndices2{K} , i:: Int , j:: Int ) where {K}
214
214
@boundscheck checkbounds (iter, i, j)
215
- return SCartesianIndex2 {K,N } (i, iter. indices2[j])
215
+ return SCartesianIndex2 {K} (i, iter. indices2[j])
216
216
end
217
217
218
- function iterate (iter:: SCartesianIndices2{K,N } ) where {K,N }
218
+ function iterate (iter:: SCartesianIndices2{K} ) where {K}
219
219
ret = iterate (iter. indices2)
220
220
ret === nothing && return nothing
221
221
item2, state2 = ret
222
- return SCartesianIndex2 {K,N } (1 , item2), (1 , item2, state2)
222
+ return SCartesianIndex2 {K} (1 , item2), (1 , item2, state2)
223
223
end
224
224
225
- function iterate (iter:: SCartesianIndices2{K,N } , (state1, item2, state2)) where {K,N }
225
+ function iterate (iter:: SCartesianIndices2{K} , (state1, item2, state2)) where {K}
226
226
if state1 < K
227
227
item1 = state1 + 1
228
- return SCartesianIndex2 {K,N } (item1, item2), (item1, item2, state2)
228
+ return SCartesianIndex2 {K} (item1, item2), (item1, item2, state2)
229
229
end
230
230
ret = iterate (iter. indices2, state2)
231
231
ret === nothing && return nothing
232
232
item2, state2 = ret
233
- return SCartesianIndex2 {K,N } (1 , item2), (1 , item2, state2)
233
+ return SCartesianIndex2 {K} (1 , item2), (1 , item2, state2)
234
234
end
235
235
236
236
SimdLoop. simd_outer_range (iter:: SCartesianIndices2 ) = iter. indices2
237
237
SimdLoop. simd_inner_length (:: SCartesianIndices2{K} , :: Any ) where K = K
238
- @inline function SimdLoop. simd_index (:: SCartesianIndices2{K,N } , Ilast:: Int , I1:: Int ) where {K,N }
239
- SCartesianIndex2 {K,N } (I1+ 1 , Ilast)
238
+ @inline function SimdLoop. simd_index (:: SCartesianIndices2{K} , Ilast:: Int , I1:: Int ) where {K}
239
+ SCartesianIndex2 {K} (I1+ 1 , Ilast)
240
240
end
241
241
242
242
_maybe_reshape (:: IndexSCartesian2 , A:: ReshapedReinterpretArray , I... ) = A
0 commit comments