@@ -260,14 +260,25 @@ index_ndims(inds...) = Val(sum(index_ndim, inds))
260
260
select_vectorinds (a, b... ) = a
261
261
select_vectorinds (a:: Integer , b... ) = select_vectorinds (b... )
262
262
263
- combine_inds (inds:: Tuple , k) = (k, combine_inds (inds[2 : end ], k)... )
264
- combine_inds (inds:: Tuple{Integer,Vararg} , k) = (inds[1 ], combine_inds (inds[2 : end ], k)... )
265
- combine_inds (:: Tuple{} , k) = ()
263
+ replace_vector_by_scalar (inds:: Tuple , k) = (k, replace_vector_by_scalar (inds[2 : end ], k)... )
264
+ replace_vector_by_scalar (inds:: Tuple{Integer,Vararg} , k) = (inds[1 ], replace_vector_by_scalar (inds[2 : end ], k)... )
265
+ replace_vector_by_scalar (:: Tuple{} , k) = ()
266
266
267
267
defaultgetindex (B:: Operator , kj... ) = defaultgetindex (B, index_ndims (kj... ), kj... )
268
268
269
- defaultgetindex (op:: Operator , :: Val{1} , inds... ) =
270
- eltype (op)[op[combine_inds (inds, k)... ] for k in select_vectorinds (inds... )]
269
+ function defaultgetindex (op:: Operator , :: Val{1} , inds... )
270
+ indsvec = select_vectorinds (inds... )
271
+ # avoid stack-overflow if iterating over indsvec returns indsvec
272
+ # e.g. Blocks
273
+ k = first (indsvec)
274
+ indsscal = replace_vector_by_scalar (inds, k)
275
+ if typeof (indsscal) == typeof (inds)
276
+ T = typeof (op)
277
+ throw (ArgumentError (" please implement " *
278
+ " getindex(::$T , $(join (string .(" ::" , typeof .(inds)), " ," )) )" ))
279
+ end
280
+ eltype (op)[op[replace_vector_by_scalar (inds, k)... ] for k in indsvec]
281
+ end
271
282
272
283
function defaultgetindex (B:: Operator , :: Val{2} , inds... )
273
284
S = view (B,inds... )
0 commit comments